Sanster / tldream

A tiny little diffusion drawing app
Apache License 2.0
405 stars 23 forks source link

TypeError: unsupported operand type(s) for %: 'int' and 'NoneType' #7

Open pawamoy opened 2 months ago

pawamoy commented 2 months ago

I suspect it's another (#5) library incompatibility issue.

% tldream --model wyyadd/sd-1.5 --device cuda
/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/diffusers/utils/outputs.py:63: FutureWarning: `torch.utils._pytree._register_pytree_node` is deprecated. Please use `torch.utils._pytree.register_pytree_node` instead.
  torch.utils._pytree._register_pytree_node(
/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/diffusers/utils/outputs.py:63: FutureWarning: `torch.utils._pytree._register_pytree_node` is deprecated. Please use `torch.utils._pytree.register_pytree_node` instead.
  torch.utils._pytree._register_pytree_node(
/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/diffusers/utils/outputs.py:63: FutureWarning: `torch.utils._pytree._register_pytree_node` is deprecated. Please use `torch.utils._pytree.register_pytree_node` instead.
  torch.utils._pytree._register_pytree_node(
/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/xformers/ops/fmha/flash.py:211: FutureWarning: `torch.library.impl_abstract` was renamed to `torch.library.register_fake`. Please use that instead; we will remove `torch.library.impl_abstract` in a future version of PyTorch.
  @torch.library.impl_abstract("xformers_flash::flash_fwd")
/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/xformers/ops/fmha/flash.py:344: FutureWarning: `torch.library.impl_abstract` was renamed to `torch.library.register_fake`. Please use that instead; we will remove `torch.library.impl_abstract` in a future version of PyTorch.
  @torch.library.impl_abstract("xformers_flash::flash_bwd")
2024-09-09 13:43:38.703 | INFO     | tldream.server:main:153 - tldream 0.6.1
2024-09-09 13:43:38.703 | INFO     | tldream.server:main:154 - Model cache dir: /home/pawamoy/.cache/huggingface/hub
2024-09-09 13:43:38.719 | INFO     | tldream.util:init_pipe:102 - Loading model: wyyadd/sd-1.5
/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/huggingface_hub/file_download.py:1150: FutureWarning: `resume_download` is deprecated and will be removed in version 1.0.0. Downloads always resume when possible. If you want to force a new download, use `force_download=True`.
  warnings.warn(
Loading pipeline components...:  14%|████████████████████████▌                                                                                                                                                   | 1/7 [00:03<00:18,  3.02s/it]/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/transformers/models/clip/feature_extraction_clip.py:28: FutureWarning: The class CLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please use CLIPImageProcessor instead.
  warnings.warn(
Loading pipeline components...:  86%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▍                        | 6/7 [00:13<00:02,  2.53s/it]/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/transformers/tokenization_utils_base.py:1601: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted in transformers v4.45, and will be then set to `False` by default. For more details check this issue: https://github.com/huggingface/transformers/issues/31884
  warnings.warn(
Loading pipeline components...: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:13<00:00,  1.87s/it]
INFO:     Started server process [52511]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:4242 (Press CTRL+C to quit)
INFO:     127.0.0.1:35406 - "GET /tldraw-assets.json HTTP/1.1" 404 Not Found
2024-09-09 13:43:55.964 | INFO     | tldream.server:run:79 - {'steps': 15, 'guidance_scale': 9.0, 'prompt': 'best quality, extremely detailed shop house on the side of a rural road', 'negative_prompt': 'lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality', 'width': 512, 'height': 512}
2024-09-09 13:43:55.996 | INFO     | tldream.util:process:403 - Original image shape: (853, 1864, 3), Resized & Padded image shape: (512, 512, 3)
/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/diffusers/pipelines/controlnet/pipeline_controlnet.py:984: FutureWarning: `callback` is deprecated and will be removed in version 1.0.0. Passing `callback` as an input argument to `__call__` is deprecated, consider using `callback_on_step_end`
  deprecate(
  7%|█████████████▌                                                                                                                                                                                             | 1/15 [00:00<00:04,  3.06it/s]
2024-09-09 13:43:56.474 | INFO     | tldream.server:run:124 - process time: 484.905481338501ms
INFO:     127.0.0.1:35406 - "POST /run HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/uvicorn/protocols/http/httptools_impl.py", line 401, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in __call__
    return await self.app(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in __call__
    raise exc
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/middleware/cors.py", line 93, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    await self.app(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
    raise exc
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
    await app(scope, receive, sender)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/routing.py", line 715, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/routing.py", line 735, in app
    await route.handle(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
    raise exc
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
    await app(scope, receive, sender)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/fastapi/routing.py", line 214, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/starlette/concurrency.py", line 39, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread
    return await future
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 859, in run
    result = context.run(func, *args)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/tldream/server.py", line 100, in run
    res_rgb_img = process(
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/tldream/util.py", line 407, in process
    output = pipe(
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "/home/pawamoy/.local/share/uv/tools/tldream/lib/python3.10/site-packages/diffusers/pipelines/controlnet/pipeline_controlnet.py", line 1235, in __call__
    if callback is not None and i % callback_steps == 0:
TypeError: unsupported operand type(s) for %: 'int' and 'NoneType'
pawamoy commented 2 months ago

Haha I was able to fix it by changing line 1235 as if callback is not None and i % (callback_steps or 1) == 0: :joy: