FPRT/Image_Classifier
0
1import streamlit as st2from transformers import pipeline3from transformers import BeitFeatureExtractor, BeitForImageClassification4from PIL import Image5import requests6 7pipeline = pipeline(task = "image-classification", model = "microsoft/beit-base-patch16-224-pt22k-ft22k")8 9st.title("Predict the class of an image")10 11file_name = st.file_uploader("Upload an image here")12 13if file_name is not None:14 col1, col2 = st.columns(2)15 16 image = Image.open(file_name)17 col1.image(image, use_column_width=True)18 predictions = pipeline(image)19 20 col2.header("Probabilities")21 for p in predictions:22 col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")23 24 