Spaces:
Sleeping
Sleeping
Download app.py from olive100/text-classification: direct link, hf CLI and curl.
- Browser
- Download file 494 Bytes
-
https://huggingface.co/spaces/olive100/text-classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/olive100/text-classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/olive100/text-classification/resolve/main/app.py
494 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| pipe = pipeline("text-classification","uer/roberta-base-finetuned-jd-binary-chinese") | |
| def clf(text): | |
| result = pipe(text) | |
| label = result[0]['label'] | |
| score = result[0]['score'] | |
| res = {label:score,'positive' if label.startswith('negative') else 'negative': 1-score} | |
| return res | |
| demo = gr.Interface(fn=clf, inputs=gr.Textbox(label="输入文本"), outputs=gr.Label(label="输出结果")) | |
| gr.close_all() | |
| demo.launch() | |