File size: 508 Bytes
ed70bf2
9a8d35c
ed70bf2
 
 
9a8d35c
 
ed70bf2
 
 
9a8d35c
ed70bf2
 
 
 
 
 
 
 
 
 
 
 
 
9a8d35c
ed70bf2
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
26
27
import gradio as gr
from PIL import Image
from transformers import pipeline

pipeline = pipeline(
    "image-classification",
    model="fauzanardh/anime-time-beit_classifier",
)


def classify_image(input_img: Image.Image) -> dict:
    data = pipeline(input_img, top_k=4)
    out = {}
    for d in data:
        out[d["label"]] = d["score"]
    return out


demo = gr.Interface(
    fn=classify_image,
    inputs=gr.Image(type="pil"),
    outputs=gr.Label(label="Prediction"),
)

demo.queue()
demo.launch()