File size: 884 Bytes
2f29325
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e20f877
2f29325
 
 
 
 
 
 
 
1
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
import streamlit as st
from transformers import pipeline
from PIL import Image

# Load the pre-trained fast food classifier model from Hugging Face
classifier = pipeline(task="image-classification", model="AryanKaushik/fastfood-classifier")

st.title("πŸ” Fast Food Classifier")
st.write("Upload an image and find out if it's a burger, pizza, cupcake, fries, or waffle!")

# Upload an image
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])

if uploaded_file is not None:
    col1, col2 = st.columns(2)

    # Show the image
    image = Image.open(uploaded_file)
    col1.image(image, caption="Uploaded Image", use_container_width=True)  

    # Run prediction
    predictions = classifier(image)

    # Show results
    col2.header("Prediction Results")
    for p in predictions:
        col2.subheader(f"{p['label']}: {round(p['score'] * 100, 2)}%")