Spaces:
Sleeping
Sleeping
Download app.py from frankrobotics/Tags-Classification: direct link, hf CLI and curl.
- Browser
- Download file 625 Bytes
-
https://huggingface.co/spaces/frankrobotics/Tags-Classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/frankrobotics/Tags-Classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/frankrobotics/Tags-Classification/resolve/main/app.py
625 Bytes
| import gradio as gr | |
| import json | |
| from transformers import pipeline | |
| classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli") | |
| def tagging( | |
| text_input: str, | |
| tags: str, | |
| multi_label: bool | |
| ): | |
| try: | |
| candidate_labels = json.loads(tags) | |
| except error: | |
| raise gr.Error(f"Error {error}") | |
| output = classifier(text_input, candidate_labels, multi_label=True) | |
| return output | |
| app = gr.Interface(fn=tagging, inputs=[ | |
| gr.Textbox(label="Input here"), | |
| gr.Textbox(label="Mags here"), | |
| gr.Checkbox(label="Multi_label", value=True) | |
| ], outputs="text") | |
| app.launch() |