Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -105,14 +105,6 @@ def register_callback():
|
|
| 105 |
except Exception as e:
|
| 106 |
st.error(f"Registration failed: {e}")
|
| 107 |
|
| 108 |
-
# Callback for logout
|
| 109 |
-
def logout_callback():
|
| 110 |
-
st.session_state.logged_in = False
|
| 111 |
-
st.session_state.current_user = None
|
| 112 |
-
st.session_state.display_name = None
|
| 113 |
-
st.session_state.selected_image = None
|
| 114 |
-
st.info("Logged out successfully!")
|
| 115 |
-
|
| 116 |
# Callback for login
|
| 117 |
def login_callback():
|
| 118 |
login_identifier = st.session_state.login_identifier
|
|
@@ -168,6 +160,14 @@ def login_callback():
|
|
| 168 |
except Exception as e:
|
| 169 |
st.error(f"Login failed: {e}")
|
| 170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
# Function to get image from url
|
| 172 |
def get_image_from_url(url):
|
| 173 |
"""
|
|
@@ -266,7 +266,7 @@ def upload_image_to_storage(image, user_id, is_thumbnail = False):
|
|
| 266 |
if is_thumbnail:
|
| 267 |
file_path = f"user_images/{user_id}/thumbnails/{image_id}.png" # path for thumbnail
|
| 268 |
else:
|
| 269 |
-
file_path = f"
|
| 270 |
blob = bucket.blob(file_path)
|
| 271 |
|
| 272 |
# Convert PIL Image to BytesIO object
|
|
@@ -372,7 +372,7 @@ def main_app():
|
|
| 372 |
st.write(f"**Realism:** {realism}")
|
| 373 |
download_path = download_image(image_url)
|
| 374 |
if download_path:
|
| 375 |
-
st.download_button(label="Download Image", data = open(download_path, "rb"), file_name = f"image.png")
|
| 376 |
else:
|
| 377 |
st.error("Failed to upload image to cloud storage.")
|
| 378 |
else:
|
|
@@ -449,7 +449,7 @@ def main_app():
|
|
| 449 |
st.write(f"**Realism:** {st.session_state.selected_image['realism']}")
|
| 450 |
download_path = download_image(st.session_state.selected_image['image_url'])
|
| 451 |
if download_path:
|
| 452 |
-
st.download_button(label="Download Image", data = open(download_path, "rb"), file_name = f"image.png")
|
| 453 |
|
| 454 |
if st.button("Close"):
|
| 455 |
st.session_state.selected_image = None # close the modal when "close" is clicked
|
|
|
|
| 105 |
except Exception as e:
|
| 106 |
st.error(f"Registration failed: {e}")
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
# Callback for login
|
| 109 |
def login_callback():
|
| 110 |
login_identifier = st.session_state.login_identifier
|
|
|
|
| 160 |
except Exception as e:
|
| 161 |
st.error(f"Login failed: {e}")
|
| 162 |
|
| 163 |
+
# Callback for logout
|
| 164 |
+
def logout_callback():
|
| 165 |
+
st.session_state.logged_in = False
|
| 166 |
+
st.session_state.current_user = None
|
| 167 |
+
st.session_state.display_name = None
|
| 168 |
+
st.session_state.selected_image = None
|
| 169 |
+
st.info("Logged out successfully!")
|
| 170 |
+
|
| 171 |
# Function to get image from url
|
| 172 |
def get_image_from_url(url):
|
| 173 |
"""
|
|
|
|
| 266 |
if is_thumbnail:
|
| 267 |
file_path = f"user_images/{user_id}/thumbnails/{image_id}.png" # path for thumbnail
|
| 268 |
else:
|
| 269 |
+
file_path = f"user_images/{user_id}/{image_id}.png" # path for high resolution images
|
| 270 |
blob = bucket.blob(file_path)
|
| 271 |
|
| 272 |
# Convert PIL Image to BytesIO object
|
|
|
|
| 372 |
st.write(f"**Realism:** {realism}")
|
| 373 |
download_path = download_image(image_url)
|
| 374 |
if download_path:
|
| 375 |
+
st.download_button(label="Download Image", data = open(download_path, "rb"), file_name = f"image.png", key=f"download_high_res_{uuid.uuid4()}")
|
| 376 |
else:
|
| 377 |
st.error("Failed to upload image to cloud storage.")
|
| 378 |
else:
|
|
|
|
| 449 |
st.write(f"**Realism:** {st.session_state.selected_image['realism']}")
|
| 450 |
download_path = download_image(st.session_state.selected_image['image_url'])
|
| 451 |
if download_path:
|
| 452 |
+
st.download_button(label="Download Image", data = open(download_path, "rb"), file_name = f"image.png", key=f"download_overlay_{uuid.uuid4()}")
|
| 453 |
|
| 454 |
if st.button("Close"):
|
| 455 |
st.session_state.selected_image = None # close the modal when "close" is clicked
|