Spaces:
Sleeping
Sleeping
File size: 941 Bytes
832b1d7 e2dfb46 832b1d7 e2dfb46 832b1d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
tokenizer = AutoTokenizer.from_pretrained("coppercitylabs/uzbek-news-category-classifier")
model = AutoModelForSequenceClassification.from_pretrained("coppercitylabs/uzbek-news-category-classifier")
def prediction(news):
# create pipeline
clasifer = pipeline("sentiment-analysis", tokenizer=tokenizer, model=model, return_all_scores=True)
preds = clasifer(news)
preds_dict={}
for pred in preds[0]:
preds_dict[pred['label']] = pred['score']
return preds_dict
gradio_ui = gr.Interface(
fn=prediction,
title="O'zbek Yangiliklari Klassifikatsiyasi",
description=f"",
inputs=gr.inputs.Textbox(lines=10, label="Yangilik matnini kiriting"),
outputs=gr.outputs.Label(num_top_classes=5, type="auto", label="Yangiliklar ko'rsatkichi"),
theme="huggingface",
)
gradio_ui.launch() |