Spaces:
Sleeping
Sleeping
Download app.py from s297941863/SentimentClassifier: direct link, hf CLI and curl.
- Browser
- Download file 405 Bytes
-
https://huggingface.co/spaces/s297941863/SentimentClassifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/s297941863/SentimentClassifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/s297941863/SentimentClassifier/resolve/main/app.py
405 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # 加载情感分析模型 | |
| classifier = pipeline("sentiment-analysis") | |
| # 定义处理用户输入的函数 | |
| def classify_text(text): | |
| # 使用模型进行情感分类 | |
| result = classifier(text) | |
| return result[0] | |
| # 创建Gradio界面 | |
| iface = gr.Interface(fn=classify_text, inputs="text", outputs="json") | |
| # 启动Gradio界面 | |
| iface.launch() | |