File size: 1,029 Bytes
a2fc443 7581453 a2fc443 7581453 a2fc443 7581453 a2fc443 7581453 a2fc443 7581453 a2fc443 f45399c |
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 |
from transformers import pipeline
import gradio as gr
# Pipeline
pipe = pipeline("text-classification", model="AbrorBalxiyev/my_awesome_model", return_all_scores=True)
# Gradio interfeysi uchun funksiyani qayta yozish
def classify_text(text):
results = pipe(text)[0]
results.sort(key=lambda x: x["score"], reverse=True)
result = ""
for item in results:
percentage = item["score"] * 100
result += f"{item['label']}: {percentage:.1f}%\n"
return result
# Gradio interfeysi
iface = gr.Interface(
fn=classify_text,
inputs=gr.Textbox(placeholder="Enter text to classify...", label="Input Text"),
outputs=gr.Textbox(label="Classification Results"),
title="Text Category Classification",
description="Enter text to see its category classification percentages.",
examples=[
["Mercedes is one of the best quality cars."],
["Perevalda Damas va Lacetti avtomobillari avtoxalokatga uchradi"],
["Kitob o'qish foydali"]
]
)
iface.launch(share=True) |