DrCyanide / cyanic-sd-krita

A Stable Diffusion plugin for Krita, compatible with A1111 and SD.Next
70 stars 4 forks source link

Krita crashes upon pressing "cancel" #10

Closed Miraihi closed 1 year ago

Miraihi commented 1 year ago

I think this is one of the most frustrating issues of the plugin and the reason it really needs auto-updating "image/mask" parameter, or al least some default value. Steps to reproduce:

  1. Fill any of the fields in img2img/inpaint/canvas
  2. Don't select the image, either as selection,
  3. Get stuck at 1%
  4. Crash upon pressing the "cancel"

The error log in Stable Diffusion is as follows:

*** API error: POST: http://127.0.0.1:7860/sdapi/v1/img2img {'error': 'AttributeError', 'detail': '', 'body': '', 'errors': "'NoneType' object has no attribute 'startswith'"}
    Traceback (most recent call last):
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\streams\memory.py", line 98, in receive
        return self.receive_nowait()
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\streams\memory.py", line 93, in receive_nowait
        raise WouldBlock
    anyio.WouldBlock

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 78, in call_next
        message = await recv_stream.receive()
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\streams\memory.py", line 118, in receive
        raise EndOfStream
    anyio.EndOfStream

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "E:\AI\stable-diffusion-webui\modules\api\api.py", line 187, in exception_handling
        return await call_next(request)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 84, in call_next
        raise app_exc
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 108, in __call__
        response = await self.dispatch_func(request, call_next)
      File "E:\AI\stable-diffusion-webui\modules\api\api.py", line 151, in log_and_time
        res: Response = await call_next(req)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 84, in call_next
        raise app_exc
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\base.py", line 70, in coro
        await self.app(scope, receive_or_disconnect, send_no_error)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\cors.py", line 84, in __call__
        await self.app(scope, receive, send)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\gzip.py", line 26, in __call__
        await self.app(scope, receive, send)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
        raise exc
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
        await self.app(scope, receive, sender)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
        raise e
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
        await self.app(scope, receive, send)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\routing.py", line 718, in __call__
        await route.handle(scope, receive, send)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\routing.py", line 276, in handle
        await self.app(scope, receive, send)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\routing.py", line 66, in app
        response = await func(request)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\fastapi\routing.py", line 237, in app
        raw_response = await run_endpoint_function(
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\fastapi\routing.py", line 165, in run_endpoint_function
        return await run_in_threadpool(dependant.call, **values)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\concurrency.py", line 41, in run_in_threadpool
        return await anyio.to_thread.run_sync(func, *args)
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\to_thread.py", line 33, in run_sync
        return await get_asynclib().run_sync_in_worker_thread(
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 877, in run_sync_in_worker_thread
        return await future
      File "E:\AI\stable-diffusion-webui\venv\lib\site-packages\anyio\_backends\_asyncio.py", line 807, in run
        result = context.run(func, *args)
      File "E:\AI\stable-diffusion-webui\modules\api\api.py", line 428, in img2imgapi
        p.init_images = [decode_base64_to_image(x) for x in init_images]
      File "E:\AI\stable-diffusion-webui\modules\api\api.py", line 428, in <listcomp>
        p.init_images = [decode_base64_to_image(x) for x in init_images]
      File "E:\AI\stable-diffusion-webui\modules\api\api.py", line 80, in decode_base64_to_image
        if encoding.startswith("http://") or encoding.startswith("https://"):
    AttributeError: 'NoneType' object has no attribute 'startswith'
DrCyanide commented 1 year ago

I think I've finally managed to track down the canceling bug and fix it.

Also, I've changed Img2Img and Inpaint to default to "Use Canvas" if the user tries to click generate without having selected either option. I know it's not quite to your ideal "use the current version of this layer as a mask" yet, but hopefully that reduces some of the pain.