|
import streamlit as st |
|
from transformers import pipeline |
|
from PIL import Image |
|
|
|
|
|
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!") |
|
|
|
|
|
uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"]) |
|
|
|
if uploaded_file is not None: |
|
col1, col2 = st.columns(2) |
|
|
|
|
|
image = Image.open(uploaded_file) |
|
col1.image(image, caption="Uploaded Image", use_container_width=True) |
|
|
|
|
|
predictions = classifier(image) |
|
|
|
|
|
col2.header("Prediction Results") |
|
for p in predictions: |
|
col2.subheader(f"{p['label']}: {round(p['score'] * 100, 2)}%") |
|
|