Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
|
6 |
+
from transformers import AutoFeatureExtractor, AutoModelForImageClassification
|
7 |
+
|
8 |
+
extractor = AutoFeatureExtractor.from_pretrained("Amite5h/convnext-tiny-finetuned-eurosat")
|
9 |
+
|
10 |
+
model = AutoModelForImageClassification.from_pretrained("Amite5h/convnext-tiny-finetuned-eurosat")
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
#pipeline = pipeline(task="image-classification", model="julien-c/hotdog-not-hotdog")
|
15 |
+
|
16 |
+
st.title("Hot Dog? Or Not?")
|
17 |
+
|
18 |
+
file_name = st.file_uploader("Upload a hot dog candidate image")
|
19 |
+
|
20 |
+
if file_name is not None:
|
21 |
+
col1, col2 = st.columns(2)
|
22 |
+
|
23 |
+
image = Image.open(file_name)
|
24 |
+
col1.image(image, use_column_width=True)
|
25 |
+
predictions = model(image)
|
26 |
+
|
27 |
+
col2.header("Probabilities")
|
28 |
+
for p in predictions:
|
29 |
+
col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
|