Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -352,35 +352,35 @@ def main_app():
|
|
352 |
if isinstance(image_result, tuple) and len(image_result) == 2 and image_result[0] is not None:
|
353 |
image, image_url = image_result
|
354 |
|
355 |
-
#
|
356 |
-
|
357 |
-
|
358 |
-
if
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
else:
|
383 |
-
st.error("Failed to
|
384 |
|
385 |
else:
|
386 |
st.error(f"Image generation failed: {image_result}")
|
|
|
352 |
if isinstance(image_result, tuple) and len(image_result) == 2 and image_result[0] is not None:
|
353 |
image, image_url = image_result
|
354 |
|
355 |
+
# Upload the high-resolution image first
|
356 |
+
cloud_storage_url = upload_image_to_storage(image, st.session_state.current_user, is_thumbnail=False)
|
357 |
+
|
358 |
+
if cloud_storage_url:
|
359 |
+
# Create thumbnail from the high-resolution image
|
360 |
+
thumbnail = create_thumbnail(image)
|
361 |
+
|
362 |
+
if thumbnail:
|
363 |
+
# Upload thumbnail to cloud storage and store url
|
364 |
+
thumbnail_url = upload_image_to_storage(thumbnail, st.session_state.current_user, is_thumbnail=True)
|
365 |
+
|
366 |
+
if thumbnail_url:
|
367 |
+
# Store image data in database
|
368 |
+
store_image_data_in_db(st.session_state.current_user, prompt, aspect_ratio, realism, cloud_storage_url, thumbnail_url)
|
369 |
+
st.success("Image stored to database successfully!")
|
370 |
+
with st.container(border=True):
|
371 |
+
st.image(image, use_column_width=True) # Display the (now thumbnailed) image here - consider fetching original for display
|
372 |
+
st.write(f"**Prompt:** {prompt}")
|
373 |
+
st.write(f"**Aspect Ratio:** {aspect_ratio}")
|
374 |
+
st.write(f"**Realism:** {realism}")
|
375 |
+
download_path = download_image(image_url)
|
376 |
+
if download_path:
|
377 |
+
st.download_button(label="Download Image", data = open(download_path, "rb"), file_name = f"image.png", key=f"download_high_res_{uuid.uuid4()}")
|
378 |
+
else:
|
379 |
+
st.error("Failed to upload thumbnail to cloud storage.")
|
380 |
+
else:
|
381 |
+
st.error("Failed to create thumbnail")
|
382 |
else:
|
383 |
+
st.error("Failed to upload image to cloud storage.")
|
384 |
|
385 |
else:
|
386 |
st.error(f"Image generation failed: {image_result}")
|