Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -41,7 +41,9 @@ if "start_index" not in st.session_state:
|
|
41 |
st.session_state.start_index = 0
|
42 |
if "batch_size" not in st.session_state:
|
43 |
st.session_state.batch_size = 6
|
44 |
-
|
|
|
|
|
45 |
TOKEN = os.getenv("TOKEN0")
|
46 |
API_URL = os.getenv("API_URL")
|
47 |
token_id = 0
|
@@ -285,6 +287,8 @@ def login_form():
|
|
285 |
login_identifier = st.text_input("Email or Username", key="login_identifier")
|
286 |
password = st.text_input("Password", type="password", key="login_password")
|
287 |
submit_button = st.form_submit_button("Login", on_click=login_callback)
|
|
|
|
|
288 |
def main_app():
|
289 |
st.subheader(f"Welcome, {st.session_state.display_name}!")
|
290 |
st.write("Enter a prompt below to generate an image.")
|
@@ -356,72 +360,6 @@ def main_app():
|
|
356 |
# Logout button
|
357 |
if st.button("Logout", on_click=logout_callback):
|
358 |
pass
|
359 |
-
# Main app screen (after login)
|
360 |
-
# def main_app():
|
361 |
-
# st.subheader(f"Welcome, {st.session_state.display_name}!")
|
362 |
-
# st.write("Enter a prompt below to generate an image.")
|
363 |
-
|
364 |
-
# # Input fields
|
365 |
-
# prompt = st.text_input("Prompt", key="image_prompt", placeholder="Describe the image you want to generate")
|
366 |
-
# aspect_ratio = st.radio(
|
367 |
-
# "Aspect Ratio",
|
368 |
-
# options=["1:1", "3:4", "4:3", "9:16", "16:9", "9:21", "21:9"],
|
369 |
-
# index=5
|
370 |
-
# )
|
371 |
-
# realism = st.checkbox("Realism", value=False)
|
372 |
-
|
373 |
-
# if st.button("Generate Image"):
|
374 |
-
# if prompt:
|
375 |
-
# with st.spinner("Generating Image..."):
|
376 |
-
# image_result = generate_image(prompt, aspect_ratio, realism)
|
377 |
-
# if isinstance(image_result, tuple) and len(image_result) == 2 and image_result[0] is not None:
|
378 |
-
# image, image_url = image_result
|
379 |
-
# st.image(image, caption="Generated Image", use_column_width=True)
|
380 |
-
|
381 |
-
# # Upload image to cloud storage and store url
|
382 |
-
# cloud_storage_url = upload_image_to_storage(image, st.session_state.current_user)
|
383 |
-
|
384 |
-
# if cloud_storage_url:
|
385 |
-
# # Store image data in database
|
386 |
-
# store_image_data_in_db(st.session_state.current_user, prompt, aspect_ratio, realism, cloud_storage_url)
|
387 |
-
# st.success("Image stored to database successfully!")
|
388 |
-
|
389 |
-
# download_path = download_image(image_url)
|
390 |
-
# if download_path:
|
391 |
-
# st.download_button(label="Download Image", data = open(download_path, "rb"), file_name = f"image.png")
|
392 |
-
# else:
|
393 |
-
# st.error(f"Image generation failed: {image_result}")
|
394 |
-
# else:
|
395 |
-
# st.warning("Please enter a prompt to generate an image.")
|
396 |
-
|
397 |
-
# st.header("Your Generated Images")
|
398 |
-
# # Load initial batch of images
|
399 |
-
# if st.session_state.images_data == []:
|
400 |
-
# st.session_state.images_data = load_image_data(st.session_state.current_user, st.session_state.start_index, st.session_state.batch_size)
|
401 |
-
|
402 |
-
# if st.session_state.images_data:
|
403 |
-
# for image_data in st.session_state.images_data:
|
404 |
-
# col1, col2 = st.columns([1,2])
|
405 |
-
# with col1:
|
406 |
-
# st.image(image_data['image_url'], width = 150)
|
407 |
-
# with col2:
|
408 |
-
# st.write(f"**Prompt:** {image_data['prompt']}")
|
409 |
-
# st.write(f"**Aspect Ratio:** {image_data['aspect_ratio']}")
|
410 |
-
# st.write(f"**Realism:** {image_data['realism']}")
|
411 |
-
# st.markdown("---")
|
412 |
-
|
413 |
-
# # Load more button
|
414 |
-
# if st.button("Load More Images"):
|
415 |
-
# st.session_state.start_index += st.session_state.batch_size
|
416 |
-
# new_images = load_image_data(st.session_state.current_user, st.session_state.start_index, st.session_state.batch_size)
|
417 |
-
# if new_images:
|
418 |
-
# st.session_state.images_data.extend(new_images)
|
419 |
-
# else:
|
420 |
-
# st.write("No more images available")
|
421 |
-
|
422 |
-
# # Logout button
|
423 |
-
# if st.button("Logout", on_click=logout_callback):
|
424 |
-
# pass
|
425 |
|
426 |
# Render the appropriate screen based on login status
|
427 |
if st.session_state.logged_in:
|
|
|
41 |
st.session_state.start_index = 0
|
42 |
if "batch_size" not in st.session_state:
|
43 |
st.session_state.batch_size = 6
|
44 |
+
if "load_more_pressed" not in st.session_state:
|
45 |
+
st.session_state.load_more_pressed = False # Initialize load_more_pressed
|
46 |
+
|
47 |
TOKEN = os.getenv("TOKEN0")
|
48 |
API_URL = os.getenv("API_URL")
|
49 |
token_id = 0
|
|
|
287 |
login_identifier = st.text_input("Email or Username", key="login_identifier")
|
288 |
password = st.text_input("Password", type="password", key="login_password")
|
289 |
submit_button = st.form_submit_button("Login", on_click=login_callback)
|
290 |
+
|
291 |
+
# Main app screen (after login)
|
292 |
def main_app():
|
293 |
st.subheader(f"Welcome, {st.session_state.display_name}!")
|
294 |
st.write("Enter a prompt below to generate an image.")
|
|
|
360 |
# Logout button
|
361 |
if st.button("Logout", on_click=logout_callback):
|
362 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
|
364 |
# Render the appropriate screen based on login status
|
365 |
if st.session_state.logged_in:
|