for scum and villainy
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: 🐨
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
|
@@ -10,4 +10,7 @@ pinned: false
|
|
| 10 |
license: cc-by-sa-3.0
|
| 11 |
---
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Fandom Classifier with TextClassificationTool
|
| 3 |
emoji: 🐨
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
|
|
|
| 10 |
license: cc-by-sa-3.0
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Fandom Classifier
|
| 14 |
+
|
| 15 |
+
This is the Fandom Classifier, a demo of the transformers TextClassificationTool.
|
| 16 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
from transformers.tools.text_classification import TextClassificationTool
|
| 4 |
+
|
| 5 |
+
classifier = TextClassificationTool()
|
| 6 |
+
labels = ["Star Wars", "Star Trek", "MCU", "LOTR", "Babylon 5", "DC Comics"]
|
| 7 |
+
|
| 8 |
+
iface = gr.Interface(
|
| 9 |
+
fn=lambda s: classifier(s, labels=labels),
|
| 10 |
+
inputs="text",
|
| 11 |
+
outputs="text")
|
| 12 |
+
with gr.Blocks() as app:
|
| 13 |
+
story=gr.TextArea(
|
| 14 |
+
label='Story',
|
| 15 |
+
placeholder='The space pirate drew his trusty blaster. This might be his last night in Mos Eisley')
|
| 16 |
+
output=gr.Textbox(label='Fandom')
|
| 17 |
+
note=gr.Markdown(f"I know {', '.join(labels)}")
|
| 18 |
+
button = gr.Button('Classify')
|
| 19 |
+
button.click(
|
| 20 |
+
fn=lambda s: classifier(s, labels=labels),
|
| 21 |
+
inputs=story,
|
| 22 |
+
outputs=output,
|
| 23 |
+
api_name="fandom")
|
| 24 |
+
|
| 25 |
+
app.launch()
|