File size: 757 Bytes
9ab3705
88f817e
 
 
 
 
 
9ab3705
22f4f99
0839ca1
363f9a0
88f817e
9ee2ab1
88f817e
9ab3705
88f817e
 
9ab3705
88f817e
 
 
 
22f4f99
88f817e
 
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
import streamlit as st
from transformers import pipeline
from PIL import Image
from transformers import (
    AutoImageProcessor,
    AutoModelForImageClassification
)

pre_process = AutoImageProcessor.from_pretrained("adwod/ViT_bluetab")


st.title("What is it?")

file_name = st.file_uploader("Upload a hot dog candidate image")

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

    image = Image.open(file_name)
    col1.image(image, use_column_width=True)
    inputs = pre_process(images=image, return_tensors="pt")
    input_pixels = inputs.pixel_values
    model = AutoModelForImageClassification.from_pretrained("adwod/ViT_bluetab")
    outputs = model(input_pixels)
    col2.header(model.config.id2label[outputs.logits.argmax(-1)  .item()])