(extras_mode, image, image_folder, input_dir, output_dir, show_extras_results, \
input_video, output_frames, input_frames, output_fps, output_video, interpolate, \
*args, save_output: bool = True)
| 102 | |
| 103 | |
| 104 | def run_postprocessing(extras_mode, image, image_folder, input_dir, output_dir, show_extras_results, \ |
| 105 | input_video, output_frames, input_frames, output_fps, output_video, interpolate, \ |
| 106 | *args, save_output: bool = True): |
| 107 | devices.torch_gc() |
| 108 | |
| 109 | shared.state.begin(job="extras") |
| 110 | |
| 111 | outputs = [] |
| 112 | |
| 113 | if isinstance(image, dict): |
| 114 | image = image["composite"] |
| 115 | |
| 116 | def get_images(extras_mode, image, image_folder, input_dir): |
| 117 | if extras_mode == 1: |
| 118 | for img in image_folder: |
| 119 | if isinstance(img, Image.Image): |
| 120 | image = images.fix_image(img) |
| 121 | fn = '' |
| 122 | else: |
| 123 | image = images.read(os.path.abspath(img.name)) |
| 124 | fn = os.path.splitext(img.name)[0] |
| 125 | yield image, fn |
| 126 | elif extras_mode == 2: |
| 127 | assert not shared.cmd_opts.hide_ui_dir_config, '--hide-ui-dir-config option must be disabled' |
| 128 | assert input_dir, 'input directory not selected' |
| 129 | |
| 130 | image_list = shared.listfiles(input_dir) |
| 131 | for filename in image_list: |
| 132 | yield filename, filename |
| 133 | else: |
| 134 | assert image, 'image not selected' |
| 135 | yield image, None |
| 136 | |
| 137 | if extras_mode == 3: |
| 138 | output_text = '' |
| 139 | input_fps = 'unknown' |
| 140 | |
| 141 | if input_video != '': |
| 142 | if input_video[0] == '\"': |
| 143 | input_video = input_video[1:-1] |
| 144 | |
| 145 | input_fps = getVideoFPS(input_video) |
| 146 | |
| 147 | if input_video != '' and input_frames == '': |
| 148 | name = os.path.splitext(input_video) |
| 149 | ext = name[1].lower() |
| 150 | |
| 151 | if output_frames == '': |
| 152 | output_frames = name[0] + '_frames' |
| 153 | |
| 154 | # Create the frames folder if it doesn't exist |
| 155 | os.makedirs(output_frames, exist_ok=True) |
| 156 | |
| 157 | if ext == '.webp' or ext == '.apng' or ext == '.png': |
| 158 | #from gif2gif extension |
| 159 | with Image.open(input_video) as im: |
| 160 | frame_count = 0 |
| 161 | try: |
no test coverage detected