Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +16 -16
src/streamlit_app.py
CHANGED
|
@@ -187,16 +187,18 @@ Technical Requirements:
|
|
| 187 |
Style: Photorealistic, magazine-quality food photography that would be used in high-end restaurant menu or food advertising.
|
| 188 |
"""
|
| 189 |
try:
|
| 190 |
-
|
| 191 |
-
model
|
| 192 |
-
prompt
|
| 193 |
-
size
|
| 194 |
-
quality
|
| 195 |
-
n
|
| 196 |
-
|
|
|
|
|
|
|
| 197 |
|
| 198 |
if not result or not result.data or not len(result.data) == 0:
|
| 199 |
-
st.error(f"
|
| 200 |
return None, None
|
| 201 |
|
| 202 |
# Get base64 image data directly ( it should work directly )
|
|
@@ -204,7 +206,7 @@ Style: Photorealistic, magazine-quality food photography that would be used in h
|
|
| 204 |
|
| 205 |
# Check if base64 data is valid
|
| 206 |
if not image_base64:
|
| 207 |
-
st.error(f"
|
| 208 |
return None, None
|
| 209 |
|
| 210 |
image_bytes = base64.b64decode(image_base64)
|
|
@@ -378,12 +380,10 @@ if client:
|
|
| 378 |
|
| 379 |
if include_nutrition and dish_name in nutritional_data:
|
| 380 |
nutrition = nutritional_data[dish_name]
|
| 381 |
-
st.markdown(
|
| 382 |
-
f"**Nutrition** {nutrition.get('calories', 'N/A')} cal, {nutrition.get('protein', 'N/A')} protein"
|
| 383 |
-
)
|
| 384 |
|
| 385 |
if item.get('description'):
|
| 386 |
-
st.markdown(f"
|
| 387 |
|
| 388 |
|
| 389 |
# Download Options
|
|
@@ -420,8 +420,8 @@ if client:
|
|
| 420 |
col_download1, col_download2 = st.columns(2)
|
| 421 |
|
| 422 |
with col_download1:
|
| 423 |
-
st.markdown("**Bulk Download**")
|
| 424 |
-
st.info("Individual photos available above, or use menu report for compelete details")
|
| 425 |
|
| 426 |
with col_download2:
|
| 427 |
menu_summary = f"""VISUAL MENU GENERATED REPORT
|
|
@@ -442,7 +442,7 @@ Menu Items Generated: {total_dishes}
|
|
| 442 |
menu_summary += f"- {item['name']} - {item.get('price', 'N/A')}\n"
|
| 443 |
if include_nutrition and item['name'] in nutritional_data:
|
| 444 |
nutrition = nutritional_data[item['name']]
|
| 445 |
-
menu_summary += f"
|
| 446 |
|
| 447 |
menu_summary += f"""
|
| 448 |
Generation Statistics:
|
|
|
|
| 187 |
Style: Photorealistic, magazine-quality food photography that would be used in high-end restaurant menu or food advertising.
|
| 188 |
"""
|
| 189 |
try:
|
| 190 |
+
gen_params = {
|
| 191 |
+
"model": "gpt-image-1",
|
| 192 |
+
"prompt": food_prompt,
|
| 193 |
+
"size": "1024x1024",
|
| 194 |
+
"quality": "high",
|
| 195 |
+
"n": 1
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
result = client.images.generate(**gen_params)
|
| 199 |
|
| 200 |
if not result or not result.data or not len(result.data) == 0:
|
| 201 |
+
st.error(f"No image data returned for {dish_name}")
|
| 202 |
return None, None
|
| 203 |
|
| 204 |
# Get base64 image data directly ( it should work directly )
|
|
|
|
| 206 |
|
| 207 |
# Check if base64 data is valid
|
| 208 |
if not image_base64:
|
| 209 |
+
st.error(f"No base64 image returned for {dish_name}")
|
| 210 |
return None, None
|
| 211 |
|
| 212 |
image_bytes = base64.b64decode(image_base64)
|
|
|
|
| 380 |
|
| 381 |
if include_nutrition and dish_name in nutritional_data:
|
| 382 |
nutrition = nutritional_data[dish_name]
|
| 383 |
+
st.markdown(f"**Nutrition** {nutrition.get('calories', 'N/A')} cal, {nutrition.get('protein', 'N/A')} protein")
|
|
|
|
|
|
|
| 384 |
|
| 385 |
if item.get('description'):
|
| 386 |
+
st.markdown(f"*{item['description']}*")
|
| 387 |
|
| 388 |
|
| 389 |
# Download Options
|
|
|
|
| 420 |
col_download1, col_download2 = st.columns(2)
|
| 421 |
|
| 422 |
with col_download1:
|
| 423 |
+
st.markdown(f"**Bulk Download**")
|
| 424 |
+
st.info(f"Individual photos available above, or use menu report for compelete details")
|
| 425 |
|
| 426 |
with col_download2:
|
| 427 |
menu_summary = f"""VISUAL MENU GENERATED REPORT
|
|
|
|
| 442 |
menu_summary += f"- {item['name']} - {item.get('price', 'N/A')}\n"
|
| 443 |
if include_nutrition and item['name'] in nutritional_data:
|
| 444 |
nutrition = nutritional_data[item['name']]
|
| 445 |
+
menu_summary += f"Nutrition: {nutrition.get('calories', 'N/A')} cal, {nutrition.get('protein', 'N/A')} protein\n"
|
| 446 |
|
| 447 |
menu_summary += f"""
|
| 448 |
Generation Statistics:
|