OedoSoldier / sd-webui-image-sequence-toolkit

Extension for AUTOMATIC111's WebUI
Apache License 2.0
564 stars 41 forks source link

Reprocess the image after interruption #23

Open souvenp opened 1 year ago

souvenp commented 1 year ago

处理到一半断开,从中断的位置继续任务,或者选择第三列的帧的位置(就是第一帧),单独把剩下的图片处理 When processing is disconnected, continue the task from the interrupted position, or select the position of the frame in the third column (usually the first frame) and process the remaining images separately.

OedoSoldier commented 1 year ago

用 Files to process 指定就行了

souvenp commented 1 year ago

用 Files to process 指定就行了

我输入了输入文件夹的某一个文件名,扩展名删掉也试了都会出现FileNotFoundError错误 line 220, in run raise FileNotFoundError

OedoSoldier commented 1 year ago

用 Files to process 指定就行了

我输入了输入文件夹的某一个文件名,扩展名删掉也试了都会出现FileNotFoundError错误 line 220, in run raise FileNotFoundError

只处理一张要用 文件名-文件名 的形式

souvenp commented 1 year ago

用 Files to process 指定就行了

我输入了输入文件夹的某一个文件名,扩展名删掉也试了都会出现FileNotFoundError错误 line 220, in run raise FileNotFoundError

只处理一张要用 文件名-文件名 的形式

00001.png-00001.png或者00001.png-00002.png 我按了这个输入的,是输入文件夹的图片,还是报那个错用逗号也一样

souvenp commented 1 year ago

我参考chatgpt修改了这部分代码,运行是可以的, 只做了一种情况,就是单个文件名,从这个文件处理到结束。 就是这里下标[2]才是开始处理的图片,有点怪但是不影响把 reference_imgs = [images_in_folder_dict[start - interval_img], images_in_folder_dict[max(0, start - interval_img)]] + images

if given_file:
            images = []
            images_in_folder = [os.path.join(input_dir, f) for f in os.listdir(input_dir) if re.match(r'.+\.(jpg|png)$', f)]
            try:
                images_idx = [int(re.findall(re_findidx, j)[0]) for j in images_in_folder]
            except BaseException:
                images_idx = [re.findall(re_findname, j)[0] for j in images_in_folder]
            images_in_folder_dict = dict(zip(images_idx, images_in_folder))
            sep = ',' if ',' in specified_filename else ' '
            print("aaaaaaaaaaaaa")
            print(images_idx)
            images_idx = sorted(images_idx)
            interval_img = images_idx[1] - images_idx[0]
            start = None
            print(images_in_folder_dict.values())
            for i in specified_filename.split(sep):
                for value in images_in_folder_dict.values():
                    if i in value:
                        images.append(value)
                        print("ddddddddddddddd")
                        if len(specified_filename.split(sep)) == 1:
                            end = images_idx[-1]
                        else:
                            end = i
                        if not start:
                            start = i
                else:
                    try:
                        match = re.search(r'(^\d*)-(\d*$)', i)
                        if match:
                            start, end = match.groups()
                            if start == '':
                                start = images_idx[0]
                            if end == '':
                                end = images_idx[-1]
                            images += [images_in_folder_dict[j] for j in list(range(int(start), int(end) + 1))]
                    except BaseException:
                        try:
                            images.append(images_in_folder_dict[int(i)])
                        except KeyError:
                            pass
            if len(images) == 0:
                raise FileNotFoundError(f"No valid image found in specified file: {specified_filename}")
            start = int(start.split('.')[0].lstrip('0'))
            if isinstance(end, int):
                end = str(end)
            end = int(end.split('.')[0].lstrip('0'))
            images += [images_in_folder_dict[j]
                for j in list(range(int(start + interval_img), int(end) + interval_img, interval_img))]

            reference_imgs = [images_in_folder_dict[start - interval_img], images_in_folder_dict[max(0, start - interval_img)]] + images
            history_imgs = [images_in_folder_dict[images_idx[0]], images_in_folder_dict[max(images_idx[0], start - 2*interval_img)], images_in_folder_dict[max(0, start - interval_img)]]
            history_imgs = [images_in_folder_dict[images_idx[0]]] + [os.path.join(output_dir, os.path.basename(f)) for f in history_imgs]`