Skip to content

Commit

Permalink
fix(app): diffusers callback cannot be async; use asyncio.run()
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Apr 17, 2023
1 parent e87f7e7 commit 7854649
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,14 @@ async def inference(all_inputs: dict, response) -> dict:
callback = None
if model_inputs.get("callback_steps", None):

async def callback(step: int, timestep: int, latents: torch.FloatTensor):
await send(
"inference",
"progress",
{"startRequestId": startRequestId, "step": step},
send_opts,
def callback(step: int, timestep: int, latents: torch.FloatTensor):
asyncio.run(
send(
"inference",
"progress",
{"startRequestId": startRequestId, "step": step},
send_opts,
)
)

with torch.inference_mode():
Expand Down

0 comments on commit 7854649

Please sign in to comment.