agentsvalley commited on
Commit
05e7479
·
verified ·
1 Parent(s): ad4be6a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ # Load a food classification pipeline
6
+ food_pipeline = pipeline(task="image-classification", model="microsoft/resnet-50")
7
+
8
+ st.title("Food Recognition Agent 🍕")
9
+
10
+ # Upload the image
11
+ file_name = st.file_uploader("Upload a food image")
12
+
13
+ if file_name is not None:
14
+ col1, col2 = st.columns(2)
15
+
16
+ # Display the uploaded image
17
+ image = Image.open(file_name)
18
+ col1.image(image, use_container_width=True, caption="Uploaded Image")
19
+
20
+ # Make predictions
21
+ predictions = food_pipeline(image)
22
+
23
+ # Display probabilities
24
+ col2.header("Food Predictions 🍽️")
25
+ for p in predictions:
26
+ col2.subheader(f"{p['label']}: {round(p['score'] * 100, 1)}%")