artintel235 commited on
Commit
d6f3f1b
·
verified ·
1 Parent(s): e262f81

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -28
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
- #create thumbnail
356
- thumbnail = create_thumbnail(image)
357
-
358
- if thumbnail:
359
- # Upload thumbnail to cloud storage and store url
360
- thumbnail_url = upload_image_to_storage(thumbnail, st.session_state.current_user, is_thumbnail=True)
361
-
362
- if thumbnail_url:
363
- # Upload image to cloud storage and store url
364
- cloud_storage_url = upload_image_to_storage(image, st.session_state.current_user, is_thumbnail=False)
365
-
366
- if cloud_storage_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 high res image on top
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 image to cloud storage.")
380
- else:
381
- st.error("Failed to upload thumbnail to cloud storage.")
382
  else:
383
- st.error("Failed to create thumbnail")
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}")