Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,7 +63,10 @@ async def queue_api_calls(sentence_mapping, character_dict, selected_style):
|
|
| 63 |
model_actors = [ModelActor.remote() for _ in range(num_actors)]
|
| 64 |
tasks = [model_actors[i % num_actors].generate_image.remote(prompt, f"Prompt {paragraph_number}") for i, (paragraph_number, prompt) in enumerate(prompts)]
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
images = {paragraph_number: response for (paragraph_number, _), response in zip(prompts, responses)}
|
| 68 |
return images
|
| 69 |
|
|
|
|
| 63 |
model_actors = [ModelActor.remote() for _ in range(num_actors)]
|
| 64 |
tasks = [model_actors[i % num_actors].generate_image.remote(prompt, f"Prompt {paragraph_number}") for i, (paragraph_number, prompt) in enumerate(prompts)]
|
| 65 |
|
| 66 |
+
# Convert ray.get(task) to awaitable coroutines
|
| 67 |
+
async_tasks = [asyncio.wrap_future(ray.get(task)) for task in tasks]
|
| 68 |
+
responses = await asyncio.gather(*async_tasks)
|
| 69 |
+
|
| 70 |
images = {paragraph_number: response for (paragraph_number, _), response in zip(prompts, responses)}
|
| 71 |
return images
|
| 72 |
|