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
873 stars 102 forks source link

TypeError: slice indices must be integers or None or have an index method #5

Closed boricuapab closed 1 year ago

boricuapab commented 1 year ago

When trying to use my web cam after the latest updates to diffusers I'm getting the following error:


ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\fastapi\applications.py", line 1115, in __call__
    await super().__call__(scope, receive, send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\middleware\errors.py", line 184, in __call__
    raise exc
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\middleware\errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\middleware\cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__    raise exc
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__    await self.app(scope, receive, sender)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 20, in __call__
    raise e
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\routing.py", line 69, in app
    await response(scope, receive, send)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\responses.py", line 270, in __call__
    async with anyio.create_task_group() as task_group:
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\anyio\_backends\_asyncio.py", line 597, in __aexit__
    raise exceptions[0]
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\responses.py", line 273, in wrap
    await func()
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\starlette\responses.py", line 262, in stream_response
    async for chunk in self.body_iterator:
  File "C:\LCMRT\Real-Time-Latent-Consistency-Model\app-img2img.py", line 199, in generate
    image = predict(
  File "C:\LCMRT\Real-Time-Latent-Consistency-Model\app-img2img.py", line 105, in predict
    results = pipe(
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "C:\Users\Administrator\.cache\huggingface\modules\diffusers_modules\local\latent_consistency_img2img.py", line 368, in __call__
    self.scheduler.set_timesteps(strength, num_inference_steps, lcm_origin_steps)
  File "C:\ProgramData\miniconda3\envs\LCMRT\lib\site-packages\diffusers\schedulers\scheduling_lcm.py", line 377, in set_timesteps
    timesteps = lcm_origin_timesteps[::-skipping_step][:num_inference_steps]
TypeError: slice indices must be integers or None or have an __index__ method
radames commented 1 year ago

hi @boricuapab , yes that happens when the strength is to low, i.e. you have to increase the number of steps, or limit the strength > 0.1

boricuapab commented 1 year ago

Issue's fixed in latest commit d3237c996b173ed8915bd704796a58eb6576adbe