Download app.py from fs-bohn/toolbox: direct link, hf CLI and curl.
- Browser
- Download file 796 Bytes
-
https://huggingface.co/spaces/fs-bohn/toolbox/resolve/main/app.py
- Command line
-
hf download hf://spaces/fs-bohn/toolbox/app.py
-
curl -L -o app.py https://huggingface.co/spaces/fs-bohn/toolbox/resolve/main/app.py
796 Bytes
| import gradio as gr | |
| from transformers.tools.text_classification import TextClassificationTool | |
| classifier = TextClassificationTool() | |
| labels = ["Star Wars", "Star Trek", "MCU", "LOTR", "Babylon 5", "DC Comics"] | |
| iface = gr.Interface( | |
| fn=lambda s: classifier(s, labels=labels), | |
| inputs="text", | |
| outputs="text") | |
| with gr.Blocks() as app: | |
| story=gr.TextArea( | |
| label='Story', | |
| placeholder='The space pirate drew his trusty blaster. This might be his last night in Mos Eisley') | |
| output=gr.Textbox(label='Fandom') | |
| note=gr.Markdown(f"I know {', '.join(labels)}") | |
| button = gr.Button('Classify') | |
| button.click( | |
| fn=lambda s: classifier(s, labels=labels), | |
| inputs=story, | |
| outputs=output, | |
| api_name="fandom") | |
| app.launch() |