1010import math
1111from tqdm import tqdm
1212from PIL import ImageDraw , Image
13+ from nunif .initializer import gc_collect
1314from nunif .utils .image_loader import ImageLoader
1415from nunif .utils .pil_io import load_image_simple
1516from nunif .models import load_model # , compile_model
@@ -1673,10 +1674,12 @@ def iw3_main(args):
16731674 if not args .recursive :
16741675 image_files = ImageLoader .listdir (args .input )
16751676 process_images (image_files , args .output , args , depth_model , side_model , title = "Images" )
1677+ gc_collect ()
16761678 for video_file in VU .list_videos (args .input ):
16771679 if args .state ["stop_event" ] is not None and args .state ["stop_event" ].is_set ():
16781680 return args
16791681 process_video (video_file , args .output , args , depth_model , side_model )
1682+ gc_collect ()
16801683 else :
16811684 subdirs = list_subdir (args .input , include_root = True , excludes = args .output )
16821685 for input_dir in subdirs :
@@ -1685,10 +1688,12 @@ def iw3_main(args):
16851688 if image_files :
16861689 process_images (image_files , output_dir , args , depth_model , side_model ,
16871690 title = path .relpath (input_dir , args .input ))
1691+ gc_collect ()
16881692 for video_file in VU .list_videos (input_dir ):
16891693 if args .state ["stop_event" ] is not None and args .state ["stop_event" ].is_set ():
16901694 return args
16911695 process_video (video_file , output_dir , args , depth_model , side_model )
1696+ gc_collect ()
16921697
16931698 elif is_yaml (args .input ):
16941699 config = export_config .ExportConfig .load (args .input )
@@ -1712,6 +1717,7 @@ def iw3_main(args):
17121717 if args .state ["stop_event" ] is not None and args .state ["stop_event" ].is_set ():
17131718 return args
17141719 process_video (video_file , args .output , args , depth_model , side_model )
1720+ gc_collect ()
17151721 elif is_video (args .input ):
17161722 process_video (args .input , args .output , args , depth_model , side_model )
17171723 elif is_image (args .input ):
0 commit comments