Spaces:
Runtime error
Runtime error
Commit ·
2431fc3
1
Parent(s): 0dfb5f1
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,14 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
from PIL import Image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
pipeline = pipeline(task="image-classification", model="javierrf91/Streamlite_ViT_2000")
|
| 6 |
st.title("What is it?")
|
| 7 |
|
| 8 |
file_name = st.file_uploader("Upload a hot dog candidate image")
|
|
@@ -11,9 +17,8 @@ if file_name is not None:
|
|
| 11 |
col1, col2 = st.columns(2)
|
| 12 |
|
| 13 |
image = Image.open(file_name)
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
col2.subheader(f"{ p['label'] }: { round(p['score'] * 100, 1)}%")
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
from PIL import Image
|
| 4 |
+
from transformers import (
|
| 5 |
+
AutoImageProcessor,
|
| 6 |
+
AutoModelForImageClassification
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
pre_process = AutoImageProcessor.from_pretrained('javierrf91/Streamlite_ViT_2000')
|
| 10 |
+
|
| 11 |
|
|
|
|
| 12 |
st.title("What is it?")
|
| 13 |
|
| 14 |
file_name = st.file_uploader("Upload a hot dog candidate image")
|
|
|
|
| 17 |
col1, col2 = st.columns(2)
|
| 18 |
|
| 19 |
image = Image.open(file_name)
|
| 20 |
+
inputs = pre_process(images=image, return_tensors="pt")
|
| 21 |
+
input_pixels = inputs.pixel_values
|
| 22 |
+
model = AutoModelForImageClassification.from_pretrained('G:\Mi unidad\output')
|
| 23 |
+
outputs = model(input_pixels)
|
| 24 |
+
print("Predicted class:", model.config.id2label[outputs.logits.argmax(-1) .item()])
|
|
|