Ghontooros / app.py
Ahmadjalalib's picture
Update app.py
d9198c9 verified
raw
history blame contribute delete
876 Bytes
import os
import gradio as gr
from transformers import pipeline
# اگر از سکرت استفاده کردی
# token = os.getenv("HF_TOKEN")
# مدل طبقه‌بندی فارسی اخبار
clf_pipeline = pipeline(
"text-classification",
model="HooshvareLab/bert-fa-base-uncased-clf-persiannews",
# use_auth_token=token # فقط اگر مدل خصوصی بود
)
def classify_text(text):
result = clf_pipeline(text)[0]
label = result["label"]
score = result["score"]
return f"برچسب: {label}\nدرصد اطمینان: {round(score * 100, 2)}٪"
iface = gr.Interface(fn=classify_text, inputs="text", outputs="text",
title="طبقه‌بندی اخبار فارسی",
description="یک متن خبری فارسی وارد کن تا مدل موضوع آن را تشخیص دهد.")
iface.launch()