File size: 986 Bytes
b79c919
 
 
 
 
 
 
 
d9f9642
b79c919
 
 
 
 
 
 
 
f655b71
d853b4c
b79c919
 
 
48afb07
b79c919
 
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 gradio as gr
from transformers import AutoModelForSequenceClassification, AutoTokenizer, TextClassificationPipeline

tokenizer = AutoTokenizer.from_pretrained("daspartho/anime-or-not")
model = AutoModelForSequenceClassification.from_pretrained("daspartho/anime-or-not") # i've uploaded the model on HuggingFace :)

label_map = {
    'LABEL_0':"That's not Anime enough!",
    'LABEL_1':"That's an Anime!",
}

pipe = TextClassificationPipeline(model=model, tokenizer=tokenizer)

def classify_text(plot):
    return label_map[pipe(plot)[0]['label']]

iface = gr.Interface(
    description = "Write a plot, and the model will determine whether it's anime enough",
    article = "<p style='text-align: center'><a href='https://github.com/daspartho/anime-or-not' target='_blank'>Github</a></p>",
    fn=classify_text, 
    inputs=gr.inputs.Textbox(label="Type the plot here",), 
    outputs=gr.outputs.Textbox(label='What the model thinks'),
    enable_queue=True,
    )
iface.launch()