Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,7 +25,10 @@ def generate_image(prompt, prompt_name):
|
|
25 |
output = model(prompt=prompt, num_inference_steps=1, guidance_scale=0.0)
|
26 |
print(f"Model output for {prompt_name}: {output}")
|
27 |
|
28 |
-
if output
|
|
|
|
|
|
|
29 |
print(f"Image generated for {prompt_name}")
|
30 |
image = output.images[0]
|
31 |
buffered = BytesIO()
|
@@ -33,15 +36,13 @@ def generate_image(prompt, prompt_name):
|
|
33 |
image_bytes = buffered.getvalue()
|
34 |
return image_bytes
|
35 |
else:
|
36 |
-
|
37 |
-
return None
|
38 |
except Exception as e:
|
39 |
print(f"An error occurred while generating image for {prompt_name}: {e}")
|
40 |
return None
|
41 |
|
42 |
async def queue_api_calls(sentence_mapping, character_dict, selected_style):
|
43 |
print("Starting to queue API calls...")
|
44 |
-
print(f'sentence_mapping"{sentence_mapping}')
|
45 |
prompts = []
|
46 |
for paragraph_number, sentences in sentence_mapping.items():
|
47 |
combined_sentence = " ".join(sentences)
|
|
|
25 |
output = model(prompt=prompt, num_inference_steps=1, guidance_scale=0.0)
|
26 |
print(f"Model output for {prompt_name}: {output}")
|
27 |
|
28 |
+
if output is None:
|
29 |
+
raise ValueError(f"Model returned None for {prompt_name}")
|
30 |
+
|
31 |
+
if hasattr(output, 'images') and output.images:
|
32 |
print(f"Image generated for {prompt_name}")
|
33 |
image = output.images[0]
|
34 |
buffered = BytesIO()
|
|
|
36 |
image_bytes = buffered.getvalue()
|
37 |
return image_bytes
|
38 |
else:
|
39 |
+
raise ValueError(f"No images found in model output for {prompt_name}")
|
|
|
40 |
except Exception as e:
|
41 |
print(f"An error occurred while generating image for {prompt_name}: {e}")
|
42 |
return None
|
43 |
|
44 |
async def queue_api_calls(sentence_mapping, character_dict, selected_style):
|
45 |
print("Starting to queue API calls...")
|
|
|
46 |
prompts = []
|
47 |
for paragraph_number, sentences in sentence_mapping.items():
|
48 |
combined_sentence = " ".join(sentences)
|