viyiviyi / sd-encrypt-image

stable-diffusion-webui 图片加密插件
GNU Affero General Public License v3.0
56 stars 27 forks source link

[Bug/Error]: sd-encrypt-image 与 sd_civitai_extension 冲突 #14

Open SonicSaber opened 3 months ago

SonicSaber commented 3 months ago

你好,当我同时使用 https://github.com/civitai/sd_civitai_extension 扩展和 sd-encrypt-image 时,一开始就会出现这个错误。

---
*** API error: GET: https://eddie-andale-interracial-ware.trycloudflare.com/sd_extra_networks/cover-images?page=lora&item=Sakimichan2_style {'error': 'ValueError', 'detail': '', 'body': '', 'errors': 'File cannot be fetched: Sakimichan2_style. Failed to load cover image.'}
    Traceback (most recent call last):
      File "/kaggle/venv/lib/python3.10/site-packages/PIL/Image.py", line 2409, in save
        format = EXTENSION[ext]
    KeyError: ''

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "/kaggle/working/asd/modules/ui_extra_networks.py", line 133, in fetch_cover_images
        image.save(buffer, format=image.format)
      File "/kaggle/working/asd/extensions/sd-encrypt-image/scripts/encrypt_image.py", line 138, in save
        super().save(fp, format = format, **params)
      File "/kaggle/venv/lib/python3.10/site-packages/PIL/Image.py", line 2412, in save
        raise ValueError(msg) from e
    ValueError: unknown file extension: 

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "/kaggle/working/asd/modules/api/api.py", line 186, in exception_handling
        return await call_next(request)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 84, in call_next
        raise app_exc
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 108, in __call__
        response = await self.dispatch_func(request, call_next)
      File "/kaggle/working/asd/modules/api/api.py", line 150, in log_and_time
        res: Response = await call_next(req)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 84, in call_next
        raise app_exc
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/cors.py", line 84, in __call__
        await self.app(scope, receive, send)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 24, in __call__
        await responder(scope, receive, send)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/gzip.py", line 44, in __call__
        await self.app(scope, receive, self.send_with_gzip)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
        raise exc
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
        await self.app(scope, receive, sender)
      File "/kaggle/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 21, in __call__
        raise e
      File "/kaggle/venv/lib/python3.10/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
        await self.app(scope, receive, send)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/routing.py", line 718, in __call__
        await route.handle(scope, receive, send)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/routing.py", line 276, in handle
        await self.app(scope, receive, send)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/routing.py", line 66, in app
        response = await func(request)
      File "/kaggle/venv/lib/python3.10/site-packages/fastapi/routing.py", line 237, in app
        raw_response = await run_endpoint_function(
      File "/kaggle/venv/lib/python3.10/site-packages/fastapi/routing.py", line 165, in run_endpoint_function
        return await run_in_threadpool(dependant.call, **values)
      File "/kaggle/venv/lib/python3.10/site-packages/starlette/concurrency.py", line 41, in run_in_threadpool
        return await anyio.to_thread.run_sync(func, *args)
      File "/kaggle/venv/lib/python3.10/site-packages/anyio/to_thread.py", line 33, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(
      File "/kaggle/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread
        return await future
      File "/kaggle/venv/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 807, in run
        result = context.run(func, *args)
      File "/kaggle/working/asd/modules/ui_extra_networks.py", line 136, in fetch_cover_images
        raise ValueError(f"File cannot be fetched: {item}. Failed to load cover image.") from err
    ValueError: File cannot be fetched: Sakimichan2_style. Failed to load cover image.

---

另外,pnginfo 不同,缺少一些来自 webui 的内容 没有 sd-encrypt-image 时: image

启用 sd-encrypt-image 后:,还要注意 Schedule type 值是错误的 image

并且在保存图像时,我在末尾遇到了这个错误

saving image as downscaled JPG: InvalidImageDataError
Traceback (most recent call last):
  File "/kaggle/working/asd/modules/images.py", line 754, in save_image
    _atomically_save_image(image, fullfn_without_extension, ".jpg")
  File "/kaggle/working/asd/modules/images.py", line 718, in _atomically_save_image
    save_image_with_geninfo(image_to_save, info, temp_file_path, extension, existing_pnginfo=params.pnginfo, pnginfo_section_name=pnginfo_section_name)
  File "/kaggle/working/asd/modules/images.py", line 606, in save_image_with_geninfo
    piexif.insert(exif_bytes, filename)
  File "/kaggle/venv/lib/python3.10/site-packages/piexif/_insert.py", line 39, in insert
    raise InvalidImageDataError
piexif._exceptions.InvalidImageDataError
viyiviyi commented 2 months ago

jpg格式的图片是确定不能用的,一定会报错。 和插件冲突这个我测试一下。 pnginfo不一样这个我也需要测试一下,理论上是不会变的,因为压根没改。

viyiviyi commented 2 months ago

我测试第一个和第二个问题都不存在,请检查是不是启动的时候还有另外的插件因为这个插件报错了。

SonicSaber commented 2 months ago

我测试第一个和第二个问题都不存在,请检查是不是启动的时候还有另外的插件因为这个插件报错了。

我不知道怎么回事,但在测试了这个分支 https://github.com/gutris1/sd-encrypt-image 之后,错误变得很少,我得到了所有附带正确 Schedule Type 的png信息,感谢你的回复。