AbrorBalxiyev's picture
add share=True
f45399c verified
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)