Spaces:
Sleeping
Sleeping
Download app.py from NhanSoHocCode/vn-toxic-classifier: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/spaces/NhanSoHocCode/vn-toxic-classifier/resolve/main/app.py
- Command line
-
hf download hf://spaces/NhanSoHocCode/vn-toxic-classifier/app.py
-
curl -L -o app.py https://huggingface.co/spaces/NhanSoHocCode/vn-toxic-classifier/resolve/main/app.py
721 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| model_id = "NhanSoHocCode/vi-toxic-comment" | |
| classifier = pipeline("text-classification", model=model_id) | |
| def classify_text(text): | |
| predictions = classifier(text, top_k=None) | |
| formatted_result = {p['label']: round(p['score'], 4) for p in predictions} | |
| return formatted_result | |
| iface = gr.Interface( | |
| fn=classify_text, | |
| inputs=gr.Textbox(lines=5, placeholder="Nhập bình luận tiếng Việt vào đây..."), | |
| outputs="label", | |
| title="Phân loại bình luận độc hại", | |
| description="Đây là ứng dụng demo cho mô hình NhanSoHocCode/vi-toxic-comment. Hãy nhập một bình luận để kiểm tra." | |
| ) | |
| iface.queue().launch() |