Spaces:
Running
Running
Download app.py from Kate-lf/emotion-classification: direct link, hf CLI and curl.
- Browser
- Download file 612 Bytes
-
https://huggingface.co/spaces/Kate-lf/emotion-classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/Kate-lf/emotion-classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Kate-lf/emotion-classification/resolve/main/app.py
612 Bytes
| from transformers import pipeline | |
| model = pipeline("text-classification", model="Kate-lf/emotion-classification") | |
| def predict(text): | |
| result = model(text)[0] | |
| return f"{result['label']} (置信度: {result['score']:.2%})" | |
| import gradio as gr | |
| gr.Interface( | |
| fn=predict, | |
| inputs="textbox", | |
| outputs="text", | |
| title="句子情绪分类", | |
| description="输入句子,判断属于 伤心 / 关心 / 厌恶 / 平静 / 惊讶 / 开心 / 生气 / 疑问", | |
| examples=[["曾经最好的朋友,现在连点赞都不会了。"], ["你在我最无助的时候给了我依靠!"]], | |
| ).launch() | |