Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,12 +4,16 @@ from generate_prompts import generate_prompt
|
|
4 |
from diffusers import AutoPipelineForText2Image
|
5 |
from io import BytesIO
|
6 |
import gradio as gr
|
|
|
7 |
|
8 |
# Load the model once outside of the function
|
9 |
print("Loading the model...")
|
10 |
model = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo")
|
11 |
print("Model loaded successfully.")
|
12 |
|
|
|
|
|
|
|
13 |
def generate_image(prompt, prompt_name):
|
14 |
try:
|
15 |
print(f"Generating response for {prompt_name} with prompt: {prompt}")
|
@@ -68,6 +72,9 @@ def process_prompt(sentence_mapping, character_dict, selected_style):
|
|
68 |
asyncio.set_event_loop(loop)
|
69 |
print("Event loop created.")
|
70 |
|
|
|
|
|
|
|
71 |
# This sends the prompts to function that sets up the async calls. Once all the calls to the API complete, it returns a list of the gr.Textbox with value= set.
|
72 |
cmpt_return = loop.run_until_complete(queue_api_calls(sentence_mapping, character_dict, selected_style))
|
73 |
print(f"process_prompt completed with return value: {cmpt_return}")
|
|
|
4 |
from diffusers import AutoPipelineForText2Image
|
5 |
from io import BytesIO
|
6 |
import gradio as gr
|
7 |
+
import threading
|
8 |
|
9 |
# Load the model once outside of the function
|
10 |
print("Loading the model...")
|
11 |
model = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo")
|
12 |
print("Model loaded successfully.")
|
13 |
|
14 |
+
# Create a thread-local storage object
|
15 |
+
thread_local = threading.local()
|
16 |
+
|
17 |
def generate_image(prompt, prompt_name):
|
18 |
try:
|
19 |
print(f"Generating response for {prompt_name} with prompt: {prompt}")
|
|
|
72 |
asyncio.set_event_loop(loop)
|
73 |
print("Event loop created.")
|
74 |
|
75 |
+
# Initialize thread-local variables
|
76 |
+
thread_local.step = 0
|
77 |
+
|
78 |
# This sends the prompts to function that sets up the async calls. Once all the calls to the API complete, it returns a list of the gr.Textbox with value= set.
|
79 |
cmpt_return = loop.run_until_complete(queue_api_calls(sentence_mapping, character_dict, selected_style))
|
80 |
print(f"process_prompt completed with return value: {cmpt_return}")
|