daspartho commited on
Commit
b79c919
·
1 Parent(s): cfe7de7
Files changed (2) hide show
  1. app.py +26 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, TextClassificationPipeline
3
+
4
+ tokenizer = AutoTokenizer.from_pretrained("daspartho/anime-or-not")
5
+ model = AutoModelForSequenceClassification.from_pretrained("daspartho/anime-or-not") # i've uploaded the model on HuggingFace :)
6
+
7
+ label_map = {
8
+ 'LABEL_0':"That's not Anime enough!",
9
+ 'LABEL_1':"That's a Anime!",
10
+ }
11
+
12
+ pipe = TextClassificationPipeline(model=model, tokenizer=tokenizer)
13
+
14
+ def classify_text(plot):
15
+ return label_map[pipe(plot)[0]['label']]
16
+
17
+ iface = gr.Interface(
18
+ description = "Write a plot, and the model will tell if you if it's anime-worthy",
19
+ article = "<p style='text-align: center'><a href='https://github.com/daspartho/anime-worthy' target='_blank'>Github</a></p>",
20
+ fn=classify_text,
21
+ inputs=gr.inputs.Textbox(label="Type the plot here",),
22
+ outputs=gr.outputs.Textbox(label='What the model thinks'),
23
+ live=True,
24
+ enable_queue=True
25
+ )
26
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio