Spaces:
Sleeping
Sleeping
Download app.py from cloundmlszh/View_point: direct link, hf CLI and curl.
- Browser
- Download file 813 Bytes
-
https://huggingface.co/spaces/cloundmlszh/View_point/resolve/main/app.py
- Command line
-
hf download hf://spaces/cloundmlszh/View_point/app.py
-
curl -L -o app.py https://huggingface.co/spaces/cloundmlszh/View_point/resolve/main/app.py
813 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load pre-trained sentiment analysis model | |
| sentiment_model = pipeline("sentiment-analysis") | |
| # Function to process input sentences and return sentiment | |
| def get_sentiment(sentence): | |
| result = sentiment_model(sentence) | |
| sentiment_label = result[0]["label"] | |
| return sentiment_label | |
| # Create Gradio UI components | |
| input_text = gr.inputs.Textbox(lines=2, placeholder="Enter your sentence here...") | |
| output_text = gr.outputs.Textbox() | |
| # Create Gradio Interface | |
| iface = gr.Interface( | |
| fn=get_sentiment, | |
| inputs=input_text, | |
| outputs=output_text, | |
| title="Sentiment Analysis", | |
| description="Enter a sentence to analyze its sentiment (positive, negative, or neutral)." | |
| ) | |
| # Launch Gradio Interface | |
| if __name__ == "__main__": | |
| iface.launch() | |