dschandra commited on
Commit
3808896
·
verified ·
1 Parent(s): 4c57820

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from image_processing import preprocess_image
3
+ from food_identification import identify_food
4
+ from nutritional_analysis import get_nutritional_info
5
+ from portion_size_analysis import estimate_portion_size
6
+
7
+ def analyze_food(image):
8
+ # Step 1: Preprocess the image
9
+ preprocessed_image = preprocess_image(image)
10
+
11
+ # Step 2: Identify food items
12
+ food_items = identify_food(preprocessed_image)
13
+
14
+ # Step 3: Fetch nutritional information
15
+ nutrition_data = get_nutritional_info(food_items)
16
+
17
+ # Step 4: Estimate portion size
18
+ portion_size = estimate_portion_size(image)
19
+
20
+ return {"Food Items": food_items, "Nutrition": nutrition_data, "Portion Size": portion_size}
21
+
22
+ # Gradio Interface
23
+ iface = gr.Interface(
24
+ fn=analyze_food,
25
+ inputs=gr.Image(type="pil"),
26
+ outputs="json",
27
+ title="Diet Nutrition Analyzer",
28
+ description="Upload an image of your food plate to analyze nutrition and portion size."
29
+ )
30
+
31
+ if __name__ == "__main__":
32
+ iface.launch()