Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +13 -7
src/streamlit_app.py
CHANGED
|
@@ -197,7 +197,7 @@ Style: Photorealistic, magazine-quality food photography that would be used in h
|
|
| 197 |
|
| 198 |
result = client.images.generate(**gen_params)
|
| 199 |
|
| 200 |
-
if not result or not result.data or
|
| 201 |
st.error(f"No image data returned for {dish_name}")
|
| 202 |
return None, None
|
| 203 |
|
|
@@ -214,7 +214,7 @@ Style: Photorealistic, magazine-quality food photography that would be used in h
|
|
| 214 |
# Create a data URL for display purpose
|
| 215 |
image_url = f"data:image/jpeg;base64,{image_base64}"
|
| 216 |
|
| 217 |
-
return
|
| 218 |
except Exception as e:
|
| 219 |
st.error(f"Error generating food image for {dish_name}: {str(e)}")
|
| 220 |
return None, None
|
|
@@ -337,7 +337,7 @@ if client:
|
|
| 337 |
|
| 338 |
status_text.text(f"Generating food photo for {dish_name} ({i+1}/{total_dishes})")
|
| 339 |
|
| 340 |
-
#
|
| 341 |
image_bytes, image_url = generate_food_image(
|
| 342 |
dish_name,
|
| 343 |
description,
|
|
@@ -345,6 +345,13 @@ if client:
|
|
| 345 |
image_style
|
| 346 |
)
|
| 347 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
# Get nutritional information
|
| 349 |
if include_nutrition:
|
| 350 |
nutritional_data[dish_name] = get_nutrinutional_info(dish_name, menu_data.get('cuisine_type', "Fine Dining"))
|
|
@@ -353,8 +360,7 @@ if client:
|
|
| 353 |
progress_bar.progress((i+1)/total_dishes)
|
| 354 |
|
| 355 |
progress_bar.progress(1.0)
|
| 356 |
-
status_text.
|
| 357 |
-
st.success("Visual menu generation complete!")
|
| 358 |
|
| 359 |
# Display results
|
| 360 |
st.markdown("### Your Visual Menu Results")
|
|
@@ -474,7 +480,7 @@ else:
|
|
| 474 |
st.info("Please enter OpenAI key to get started!.")
|
| 475 |
|
| 476 |
st.markdown("""
|
| 477 |
-
### Trasform you Menu with AI
|
| 478 |
|
| 479 |
### **Upload Any Menu Photo**
|
| 480 |
- Take a picture of your menu and we'll extract all items automatically!
|
|
@@ -484,4 +490,4 @@ else:
|
|
| 484 |
|
| 485 |
### **Download Your Menu Report**
|
| 486 |
- Download detailed report of your menu with all details!
|
| 487 |
-
""")
|
|
|
|
| 197 |
|
| 198 |
result = client.images.generate(**gen_params)
|
| 199 |
|
| 200 |
+
if not result or not result.data or len(result.data) == 0:
|
| 201 |
st.error(f"No image data returned for {dish_name}")
|
| 202 |
return None, None
|
| 203 |
|
|
|
|
| 214 |
# Create a data URL for display purpose
|
| 215 |
image_url = f"data:image/jpeg;base64,{image_base64}"
|
| 216 |
|
| 217 |
+
return image_url, image_bytes
|
| 218 |
except Exception as e:
|
| 219 |
st.error(f"Error generating food image for {dish_name}: {str(e)}")
|
| 220 |
return None, None
|
|
|
|
| 337 |
|
| 338 |
status_text.text(f"Generating food photo for {dish_name} ({i+1}/{total_dishes})")
|
| 339 |
|
| 340 |
+
# When you generate the image
|
| 341 |
image_bytes, image_url = generate_food_image(
|
| 342 |
dish_name,
|
| 343 |
description,
|
|
|
|
| 345 |
image_style
|
| 346 |
)
|
| 347 |
|
| 348 |
+
# Store the image data in the dish_images dictionary
|
| 349 |
+
if image_bytes and image_url:
|
| 350 |
+
dish_images[dish_name] = {
|
| 351 |
+
'bytes': image_bytes,
|
| 352 |
+
'url': image_url
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
# Get nutritional information
|
| 356 |
if include_nutrition:
|
| 357 |
nutritional_data[dish_name] = get_nutrinutional_info(dish_name, menu_data.get('cuisine_type', "Fine Dining"))
|
|
|
|
| 360 |
progress_bar.progress((i+1)/total_dishes)
|
| 361 |
|
| 362 |
progress_bar.progress(1.0)
|
| 363 |
+
status_text.text("Visual menu generation complete!")
|
|
|
|
| 364 |
|
| 365 |
# Display results
|
| 366 |
st.markdown("### Your Visual Menu Results")
|
|
|
|
| 480 |
st.info("Please enter OpenAI key to get started!.")
|
| 481 |
|
| 482 |
st.markdown("""
|
| 483 |
+
### Trasform you Menu with AI
|
| 484 |
|
| 485 |
### **Upload Any Menu Photo**
|
| 486 |
- Take a picture of your menu and we'll extract all items automatically!
|
|
|
|
| 490 |
|
| 491 |
### **Download Your Menu Report**
|
| 492 |
- Download detailed report of your menu with all details!
|
| 493 |
+
""")
|