Spaces:
Runtime error
Runtime error
Download app.py from Tirendaz/Text-Classification: direct link, hf CLI and curl.
- Browser
- Download file 971 Bytes
-
https://huggingface.co/spaces/Tirendaz/Text-Classification/resolve/83004efbb91d400a11e11094dfd1e87f3bffd59f/app.py
- Command line
-
hf download hf://spaces/Tirendaz/Text-Classification@83004efbb91d400a11e11094dfd1e87f3bffd59f/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Tirendaz/Text-Classification/resolve/83004efbb91d400a11e11094dfd1e87f3bffd59f/app.py
971 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| classifier = pipeline("sentiment-analysis", model="Tirendaz/my_distilbert_model") | |
| def text_classification(text): | |
| result= classifier(text) | |
| sentiment_label = result[0]['label'] | |
| sentiment_score = result[0]['score'] | |
| formatted_output = f"This sentiment is {sentiment_label} with the probability {sentiment_score*100:.2f}%" | |
| return formatted_output | |
| examples=["This is wonderful movie!", "The movie was really bad; I didn't like it."] | |
| io = gr.Interface(fn=text_classification, | |
| inputs= gr.Textbox(lines=2, label="Text", placeholder="Enter title here..."), | |
| outputs=gr.Textbox(lines=2, label="Text Classification Result"), | |
| title="Text Classification", | |
| description="Enter a text and see the text classification result!", | |
| examples=examples) | |
| io.launch(inline=False, share=True) | |