radames / Real-Time-Latent-Consistency-Model

App showcasing multiple real-time diffusion models pipelines with Diffusers
https://huggingface.co/spaces/radames/Real-Time-Latent-Consistency-Model
Apache License 2.0
862 stars 101 forks source link

ValueError: `num_inference_steps`: 4 cannot be larger than `original_inference_steps` #9

Closed korymath closed 10 months ago

korymath commented 11 months ago

Catching this error when playing with the different inference steps slides.

Trace

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/fastapi/applications.py", line 1115, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/middleware/cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/routing.py", line 69, in app
    await response(scope, receive, send)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/responses.py", line 270, in __call__
    async with anyio.create_task_group() as task_group:
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 597, in __aexit__
    raise exceptions[0]
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/responses.py", line 273, in wrap
    await func()
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/starlette/responses.py", line 262, in stream_response
    async for chunk in self.body_iterator:
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/app-txt2img.py", line 196, in generate
    image = predict(params)
            ^^^^^^^^^^^^^^^
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/app-txt2img.py", line 110, in predict
    results = pipe(
              ^^^^^
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/diffusers/pipelines/latent_consistency_models/pipeline_latent_consistency_text2img.py", line 670, in __call__
    self.scheduler.set_timesteps(num_inference_steps, device, original_inference_steps=original_inference_steps)
  File "/Users/korymath/Documents/code/Real-Time-Latent-Consistency-Model/venv/lib/python3.11/site-packages/diffusers/schedulers/scheduling_lcm.py", line 364, in set_timesteps
    raise ValueError(
ValueError: `num_inference_steps`: 4 cannot be larger than `original_inference_steps`: 2 because the final timestep schedule will be a subset of the `original_inference_steps`-sized initial timestep schedule.
radames commented 11 months ago

thanks for reporting @korymath, we need to set bound to the scheduler so you won't get unexpected error, I've opened an issue on diffusers https://github.com/huggingface/diffusers/issues/5711

patrickvonplaten commented 10 months ago

Generally original_inference_steps should not be changed

radames commented 10 months ago

removed the original_inference_steps option, using img2img or controlnet pipeline we still get an error if the strength is too low