continue-revolution / sd-webui-segment-anything

Segment Anything for Stable Diffusion WebUI
3.41k stars 206 forks source link

[Bug]: 使用了copy to inpaint进行图生图重绘后无法保存图片 #29

Closed watersliang closed 1 year ago

watersliang commented 1 year ago

Is there an existing issue for this?

Have you updated WebUI and this extension to the newest version?

What happened?

image 勾选了copy to inpaint 进行重绘后,对生成的图片进行保存,发生报错,图片无法被正确的保存。在不使用本插件进行图生图能正确保存,但如果已经报错了,后面即使不使用本插件,也一样无法进行保存。

Steps to reproduce the problem

  1. 上传一张图片到图生图
  2. 把这张图片也上传到seganything插件生成蒙版
  3. 勾选copy to inpaint
  4. 填写tag和参数进行重绘
  5. 正确完成了图片重绘
  6. 点击保存按钮,进行图片保存,发生了报错,图片没有被保存

What should have happened?

应当正确将图片保存到指定目录

Commit where the problem happens

webui: sd-webui extension: multidiffusion-upscaler-for-automatic1111,同时使用了这个插件

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

NO

Console logs

Initializing SAM
Running SAM Inference (1024, 512, 3)
Creating output image
Initializing SAM
Running SAM Inference (1024, 512, 3)
Creating output image
Initializing SAM
Running SAM Inference (1024, 512, 3)
Creating output image
[Tiled VAE] VAE is on CPU. Please enable 'Move VAE to GPU' to use Tiled VAE.

Error completing request
Arguments: ('{"prompt": "blue hair,(pixel art:1.4), (retro aesthetics:1.2), nostalgic charm, blocky textures, limited color palette, digital design, 8-bit style", "all_prompts": ["blue hair,(pixel art:1.4), (retro aesthetics:1.2), nostalgic charm, blocky textures, limited color palette, digital design, 8-bit style"], "negative_prompt": "(EasyNegative),(worst quality, low quality:1.4), (bad anatomy), (inaccurate limb:1.2),poorly eyes, extra digit,fewer digits,six fingers,(extra arms,extra legs:1.2),text,cropped,jpegartifacts,(signature), (watermark), username,blurry,more than five fingers in one palm,no thumb,no nails, title, multiple view, Reference sheet, curvy, plump, fat, muscular female, strabismus,", "all_negative_prompts": ["(EasyNegative),(worst quality, low quality:1.4), (bad anatomy), (inaccurate limb:1.2),poorly eyes, extra digit,fewer digits,six fingers,(extra arms,extra legs:1.2),text,cropped,jpegartifacts,(signature), (watermark), username,blurry,more than five fingers in one palm,no thumb,no nails, title, multiple view, Reference sheet, curvy, plump, fat, muscular female, strabismus,"], "seed": 1033529053, "all_seeds": [1033529053], "subseed": 374074384, "all_subseeds": [374074384], "subseed_strength": 0, "width": 512, "height": 1024, "sampler_name": "DPM++ 2M Karras", "cfg_scale": 9, "steps": 70, "batch_size": 1, "restore_faces": false, "face_restoration_model": null, "sd_model_hash": "1d1e459f9f", "seed_resize_from_w": 0, "seed_resize_from_h": 0, "denoising_strength": 0.6, "extra_generation_params": {}, "index_of_first_image": 0, "infotexts": ["blue hair,(pixel art:1.4), (retro aesthetics:1.2), nostalgic charm, blocky textures, limited color palette, digital design, 8-bit style\\nNegative prompt: (EasyNegative),(worst quality, low quality:1.4), (bad anatomy), (inaccurate limb:1.2),poorly eyes, extra digit,fewer digits,six fingers,(extra arms,extra legs:1.2),text,cropped,jpegartifacts,(signature), (watermark), username,blurry,more than five fingers in one palm,no thumb,no nails, title, multiple view, Reference sheet, curvy, plump, fat, muscular female, strabismus,\\nSteps: 70, Sampler: DPM++ 2M Karras, CFG scale: 9, Seed: 1033529053, Size: 512x1024, Model hash: 1d1e459f9f, Denoising strength: 0.6, Clip skip: 2, ENSD: 31337"], "styles": [], "job_timestamp": "20230415105520", "clip_skip": 2, "is_using_inpainting_conditioning": false}', [{'name': 'C:\\Users\\admin\\AppData\\Local\\Temp\\tmps6i6f9i1.png', 'data': 'http://127.0.0.1:7860/file=C:\\Users\\admin\\AppData\\Local\\Temp\\tmps6i6f9i1.png', 'is_file': True}], False, 5) {}
Traceback (most recent call last):
  File "F:\SD_WebUI_launcher\modules\call_queue.py", line 56, in f
    res = list(func(*args, **kwargs))
  File "F:\SD_WebUI_launcher\modules\ui_common.py", line 56, in save_files
    images = [images[index]]
IndexError: list index out of range
提示:Python 运行时抛出了一个异常。请检查疑难解答页面。

Additional information

推测可能和生成的蒙版图片有关?

continue-revolution commented 1 year ago

我刚刚试了一下,可以保存,可能是这两个插件有冲突。我需要你另一个插件的所有参数才能尝试复现这个毛病。你可以先试试如果不用那个插件,我的插件能否正常使用保存功能。

xam0482 commented 1 year ago

我推测你的错误不在这里 应该是上面还有调试输出 很可能是爆显存了 图片小一点就不出现了

watersliang commented 1 year ago

我只启用了本插件,别的插件我都检查了,还是生成图片后无法保存。 image image image image image image

image image

continue-revolution commented 1 year ago

你点的是左起第一个还是第二个按钮,我目前在本地没办法复现你的问题。

watersliang commented 1 year ago

我使用的是 图生图-局部重绘(上传蒙版)。 补充一些信息: 1.“C:\Users\admin\AppData\Local\Temp\tmp6uf67cse.png”是存在的,这个路径确实找了那张生成的蓝色头发的图片。 2.我做了一组对照实验,我重启了webui后,不启用插件,依然使用同样的参数,在局部重绘(上传蒙版)中,我把前面seganything生成的蒙版手动上传了,使用同样的种子,再次生成。顺利生成了之前的图,而且能正常保存。 image

所以,图片保存的问题应该和本插件存在一定的关联性。我也再次检查了webui中其他插件,我都没有勾选启用。

continue-revolution commented 1 year ago

我意思是你点的是那个文件夹图标还是“保存”,是一点保存就出了问题还是点完保存后点那个文件名出了问题。

watersliang commented 1 year ago

我意思是你点的是那个文件夹图标还是“保存”,是一点保存就出了问题还是点完保存后点那个文件名出了问题。

我是点“保存”按钮后出现的问题。

continue-revolution commented 1 year ago

我今天晚上会再帮你试试,但是我至少上一次自己测试是无法复现你这个问题

xam0482 commented 1 year ago

我是点 “保存”按钮 出现的问题

可能是权限问题,用管理员权限启动一下 webui 现在不在temp保存临时图片了

watersliang commented 1 year ago

我今天晚上会再帮你试试,但是我至少上一次自己测试是无法复现你这个问题

好的 非常感谢

watersliang commented 1 year ago

我是点 “保存”按钮 出现的问题

可能是权限问题,用管理员权限启动一下 webui 现在不在temp保存临时图片了

好的 我试试

watersliang commented 1 year ago

我是点 “保存”按钮 出现的问题

可能是权限问题,用管理员权限启动一下 webui 现在不在temp保存临时图片了

我用管理员模式启动了,也再次做了对照实验。还是在启用"Copy to Inpaint Upload"后顺利生成,但保存报错。不使用本插件,手动上传蒙版生成,可以正常保存。

应该和权限无关,推测可能和“保存”按钮的相关逻辑有关。由于本人没有代码基础,无法自己查看代码,实在抱歉。

continue-revolution commented 1 year ago

在我发现原因之前我先提供一个workaround

你的图片会被默认保存在{webui}/outputs/img2img/{日期}文件夹,你可以去那里看看你要的图片。

watersliang commented 1 year ago

在我发现原因之前我先提供一个workaround

你的图片会被默认保存在{webui}/outputs/img2img/{日期}文件夹,你可以去那里看看你要的图片。

非常感谢

xam0482 commented 1 year ago

100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:03<00:00, 5.77it/s] Error completing request Arguments: ('{"prompt": "", "all_prompts": [""], "negative_prompt": "nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry", "all_negative_prompts": ["nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"], "seed": 4186578577, "all_seeds": [4186578577], "subseed": 3718522383, "all_subseeds": [3718522383], "subseed_strength": 0, "width": 512, "height": 512, "sampler_name": "Euler a", "cfg_scale": 7, "steps": 20, "batch_size": 1, "restore_faces": false, "face_restoration_model": null, "sd_model_hash": "5415fd85c7", "seed_resize_from_w": 0, "seed_resize_from_h": 0, "denoising_strength": 0.75, "extra_generation_params": {}, "index_of_first_image": 0, "infotexts": ["Negative prompt: nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry\nSteps: 20, Sampler: Euler a, CFG scale: 7, Seed: 4186578577, Size: 512x512, Model hash: 5415fd85c7, Model: \u79d1\u7384\u5e7b_dreamshaper_5PrunedNovae_dreamshaper_5PrunedNovae, Denoising strength: 0.75, ENSD: 31337"], "styles": [], "job_timestamp": "20230417164210", "clip_skip": 1, "is_using_inpainting_conditioning": false}', [{'name': 'G:\StableDiffusionRetardGUI\outputs\img2img-images\20230417\20230417_164218_426791-4186578577-20.png', 'data': 'http://127.0.0.1:8888/file=G:\\StableDiffusionRetardGUI\\outputs\\img2img-images\\20230417\\20230417_164218_426791-4186578577-20.png', 'is_file': True}], False, 4) {} Traceback (most recent call last): File "G:\StableDiffusionRetardGUI\stable-diffusion-webui2.1torch2.0\modules\call_queue.py", line 62, in f res = list(func(*args, **kwargs)) File "G:\StableDiffusionRetardGUI\stable-diffusion-webui2.1torch2.0\modules\ui_common.py", line 56, in save_files images = [images[index]] IndexError: list index out of range

我复现了这个错误, 可能确实就代码 bug

watersliang commented 1 year ago

100%|██████████████████████████████████████████████████████████████████████████████████| 20/20 [00:03<00:00, 5.77it/s] Error completing request Arguments: ('{"prompt": "", "all_prompts": [""], "negative_prompt": "nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry", "all_negative_prompts": ["nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"], "seed": 4186578577, "all_seeds": [4186578577], "subseed": 3718522383, "all_subseeds": [3718522383], "subseed_strength": 0, "width": 512, "height": 512, "sampler_name": "Euler a", "cfg_scale": 7, "steps": 20, "batch_size": 1, "restore_faces": false, "face_restoration_model": null, "sd_model_hash": "5415fd85c7", "seed_resize_from_w": 0, "seed_resize_from_h": 0, "denoising_strength": 0.75, "extra_generation_params": {}, "index_of_first_image": 0, "infotexts": ["Negative prompt: nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry\nSteps: 20, Sampler: Euler a, CFG scale: 7, Seed: 4186578577, Size: 512x512, Model hash: 5415fd85c7, Model: \u79d1\u7384\u5e7b_dreamshaper_5PrunedNovae_dreamshaper_5PrunedNovae, Denoising strength: 0.75, ENSD: 31337"], "styles": [], "job_timestamp": "20230417164210", "clip_skip": 1, "is_using_inpainting_conditioning": false}', [{'name': 'G:\StableDiffusionRetardGUI\outputs\img2img-images\20230417\20230417_164218_426791-4186578577-20.png', 'data': 'http://127.0.0.1:8888/file=G:\StableDiffusionRetardGUI\outputs\img2img-images\20230417\20230417_164218_426791-4186578577-20.png', 'is_file': True}], False, 4) {} Traceback (most recent call last): File "G:\StableDiffusionRetardGUI\stable-diffusion-webui2.1torch2.0\modules\call_queue.py", line 62, in f res = list(func(*args, **kwargs)) File "G:\StableDiffusionRetardGUI\stable-diffusion-webui2.1torch2.0\modules\ui_common.py", line 56, in save_files images = [images[index]] IndexError: list index out of range

我复现了这个错误, 可能确实就代码 bug

太好了,能复现,那就容易找问题了

continue-revolution commented 1 year ago

你的问题应该是A1111 sd-webui的js偷懒了。如果你没有在preview那里选中任何一张图,应该就可以保存。你要不先试试

watersliang commented 1 year ago

你的问题应该是A1111 sd-webui的js偷懒了。如果你没有在preview那里选中任何一张图,应该就可以保存。你要不先试试

确实如你所说,不选择preview里的图,就能正常保存。

continue-revolution commented 1 year ago

A1111已经很久没有更新了,所以我也没啥办法能解决这个问题。你要不暂时先用这个办法吧。

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/javascript/ui.js#L10 从这里开始的几个函数筛query筛得太偷懒了。

watersliang commented 1 year ago

A1111已经很久没有更新了,所以我也没啥办法能解决这个问题。你要不暂时先用这个办法吧。

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/javascript/ui.js#L10 从这里开始的几个函数筛query筛得太偷懒了。

恩 我先每次保存前 注意下,不选就好了。改代码对我来说还不现实。 感谢大佬~

xam0482 commented 1 year ago

GroundingDINO 的这个能力太牛X了 ,不枉我花了很长时间编译了 20230417_174004_105883-1784385587-20 20230417_173934_396290-555586742-20 20230417_174015_154433-315991978-20

watersliang commented 1 year ago

GroundingDINO 的这个能力太牛X了 ,不枉我花了很长时间编译了 20230417_174004_105883-1784385587-20 20230417_173934_396290-555586742-20 20230417_174015_154433-315991978-20

我也试试,我现在还没成功安装上