Prabhsimran09 commited on
Commit
2f29325
·
verified ·
1 Parent(s): 3e9acbb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ from PIL import Image
4
+
5
+ # Load the pre-trained fast food classifier model from Hugging Face
6
+ classifier = pipeline(task="image-classification", model="AryanKaushik/fastfood-classifier")
7
+
8
+ st.title("🍔 Fast Food Classifier")
9
+ st.write("Upload an image and find out if it's a burger, pizza, cupcake, fries, or waffle!")
10
+
11
+ # Upload an image
12
+ uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
13
+
14
+ if uploaded_file is not None:
15
+ col1, col2 = st.columns(2)
16
+
17
+ # Show the image
18
+ image = Image.open(uploaded_file)
19
+ col1.image(image, caption="Uploaded Image", use_column_width=True)
20
+
21
+ # Run prediction
22
+ predictions = classifier(image)
23
+
24
+ # Show results
25
+ col2.header("Prediction Results")
26
+ for p in predictions:
27
+ col2.subheader(f"{p['label']}: {round(p['score'] * 100, 2)}%")