Download app.py from thorszon/hamidtest: direct link, hf CLI and curl.
- Browser
- Download file 611 Bytes
-
https://huggingface.co/spaces/thorszon/hamidtest/resolve/main/app.py
- Command line
-
hf download hf://spaces/thorszon/hamidtest/app.py
-
curl -L -o app.py https://huggingface.co/spaces/thorszon/hamidtest/resolve/main/app.py
611 Bytes
| # app.py | |
| import gradio as gr | |
| from transformers import pipeline | |
| from transformers import AutoTokenizer, AutoModelForSequenceClassification | |
| #Defining the classify function which takes text as input and returns the label of the sentiment | |
| def classify(text): | |
| # Initializing the pipeline for sentiment analysis | |
| cls = pipeline('text-classification', model='RJuro/dk_emotion_bert_in_class') | |
| # Predicting the sentiment label for the input text | |
| return cls(text)[0]['label'] | |
| #Creating the Gradio interface with input textbox and output text | |
| gr.Interface(fn=classify, inputs=["textbox"], outputs="text").launch() |