Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,59 +1,55 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
"
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
app.launch()
|
| 57 |
-
|
| 58 |
-
if __name__ == "__main__":
|
| 59 |
-
main()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Dictionary to store images for each dish and portion size
|
| 4 |
+
dish_data = {
|
| 5 |
+
"Pizza": {
|
| 6 |
+
"main": "images/pizza_main.jpg",
|
| 7 |
+
"small": "images/pizza_small.jpg",
|
| 8 |
+
"medium": "images/pizza_medium.jpg",
|
| 9 |
+
"large": "images/pizza_large.jpg",
|
| 10 |
+
},
|
| 11 |
+
"Burger": {
|
| 12 |
+
"main": "images/burger_main.jpg",
|
| 13 |
+
"small": "images/burger_small.jpg",
|
| 14 |
+
"medium": "images/burger_medium.jpg",
|
| 15 |
+
"large": "images/burger_large.jpg",
|
| 16 |
+
},
|
| 17 |
+
"Pasta": {
|
| 18 |
+
"main": "images/pasta_main.jpg",
|
| 19 |
+
"small": "images/pasta_small.jpg",
|
| 20 |
+
"medium": "images/pasta_medium.jpg",
|
| 21 |
+
"large": "images/pasta_large.jpg",
|
| 22 |
+
},
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
# Function to display the main image and portion size image
|
| 26 |
+
def display_images(dish, portion):
|
| 27 |
+
if dish in dish_data:
|
| 28 |
+
main_image = dish_data[dish]["main"]
|
| 29 |
+
portion_image = dish_data[dish].get(portion, main_image) # Default to main image if portion not found
|
| 30 |
+
return main_image, portion_image
|
| 31 |
+
return "", ""
|
| 32 |
+
|
| 33 |
+
# Gradio interface
|
| 34 |
+
dish_list = list(dish_data.keys())
|
| 35 |
+
portion_sizes = ["small", "medium", "large"]
|
| 36 |
+
|
| 37 |
+
with gr.Blocks() as demo:
|
| 38 |
+
gr.Markdown("### Select a Dish and Portion Size")
|
| 39 |
+
|
| 40 |
+
with gr.Row():
|
| 41 |
+
dish_dropdown = gr.Dropdown(choices=dish_list, label="Select Dish")
|
| 42 |
+
portion_dropdown = gr.Dropdown(choices=portion_sizes, label="Select Portion Size")
|
| 43 |
+
|
| 44 |
+
with gr.Row():
|
| 45 |
+
main_image_display = gr.Image(label="Main Image")
|
| 46 |
+
portion_image_display = gr.Image(label="Portion Image")
|
| 47 |
+
|
| 48 |
+
# Button to trigger image display
|
| 49 |
+
submit_button = gr.Button("Show Images")
|
| 50 |
+
|
| 51 |
+
# Update images based on selections
|
| 52 |
+
submit_button.click(display_images, inputs=[dish_dropdown, portion_dropdown], outputs=[main_image_display, portion_image_display])
|
| 53 |
+
|
| 54 |
+
# Launch the application
|
| 55 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|