Spaces:
Sleeping
Sleeping
Commit
·
8b2f708
1
Parent(s):
2a74599
Update main.py
Browse files
main.py
CHANGED
@@ -21,7 +21,7 @@ def generate_and_upscale_image(text_prompt, clipdrop_api_key, stability_api_key,
|
|
21 |
|
22 |
if response.status_code != 200:
|
23 |
print(f"Request failed with status code {response.status_code}")
|
24 |
-
return None
|
25 |
|
26 |
with open('generated_image.png', 'wb') as f:
|
27 |
f.write(response.content)
|
@@ -67,9 +67,12 @@ def generate_and_upscale_image(text_prompt, clipdrop_api_key, stability_api_key,
|
|
67 |
)
|
68 |
|
69 |
response = requests.get(output)
|
|
|
|
|
|
|
70 |
final_img = Image.open(io.BytesIO(response.content))
|
71 |
img_byte_arr = io.BytesIO()
|
72 |
final_img.save(img_byte_arr, format='PNG')
|
73 |
img_byte_arr = img_byte_arr.getvalue()
|
74 |
|
75 |
-
return img_byte_arr
|
|
|
21 |
|
22 |
if response.status_code != 200:
|
23 |
print(f"Request failed with status code {response.status_code}")
|
24 |
+
return None, f"Request failed with status code {response.status_code}"
|
25 |
|
26 |
with open('generated_image.png', 'wb') as f:
|
27 |
f.write(response.content)
|
|
|
67 |
)
|
68 |
|
69 |
response = requests.get(output)
|
70 |
+
if response.status_code != 200:
|
71 |
+
return None, f"Failed to fetch upscaled image. Status code {response.status_code}"
|
72 |
+
|
73 |
final_img = Image.open(io.BytesIO(response.content))
|
74 |
img_byte_arr = io.BytesIO()
|
75 |
final_img.save(img_byte_arr, format='PNG')
|
76 |
img_byte_arr = img_byte_arr.getvalue()
|
77 |
|
78 |
+
return img_byte_arr, None
|