Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,13 +12,6 @@ print("Loading the model...")
|
|
12 |
model = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo")
|
13 |
print("Model loaded successfully.")
|
14 |
|
15 |
-
def initialize_model():
|
16 |
-
global model
|
17 |
-
if 'model' not in globals():
|
18 |
-
print("Loading the model in worker...")
|
19 |
-
model = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo")
|
20 |
-
print("Model loaded in worker successfully.")
|
21 |
-
|
22 |
def generate_image(prompt, prompt_name, num_inference_steps=1):
|
23 |
try:
|
24 |
print(f"Generating response for {prompt_name} with prompt: {prompt}")
|
@@ -59,7 +52,7 @@ async def queue_api_calls(sentence_mapping, character_dict, selected_style):
|
|
59 |
max_workers = min(len(prompts), multiprocessing.cpu_count())
|
60 |
|
61 |
# Generate images for each prompt in parallel using multiprocessing
|
62 |
-
with ProcessPoolExecutor(max_workers=max_workers
|
63 |
loop = asyncio.get_running_loop()
|
64 |
tasks = [loop.run_in_executor(executor, generate_image, prompt, f"Prompt {paragraph_number}") for paragraph_number, prompt in prompts]
|
65 |
print("Tasks created for image generation.")
|
|
|
12 |
model = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo")
|
13 |
print("Model loaded successfully.")
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
def generate_image(prompt, prompt_name, num_inference_steps=1):
|
16 |
try:
|
17 |
print(f"Generating response for {prompt_name} with prompt: {prompt}")
|
|
|
52 |
max_workers = min(len(prompts), multiprocessing.cpu_count())
|
53 |
|
54 |
# Generate images for each prompt in parallel using multiprocessing
|
55 |
+
with ProcessPoolExecutor(max_workers=max_workers) as executor:
|
56 |
loop = asyncio.get_running_loop()
|
57 |
tasks = [loop.run_in_executor(executor, generate_image, prompt, f"Prompt {paragraph_number}") for paragraph_number, prompt in prompts]
|
58 |
print("Tasks created for image generation.")
|