File size: 794 Bytes
7938776
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

# Pipeline-ni o'rnatish
pipe = pipeline("text-classification", model="AbrorBalxiyev/my_awesome_model")

# Klassifikatsiya funksiyasi
def classify_text(text):
    results = pipe(text)
    output = {result['label']: f"{result['score'] * 100:.2f}%" for result in results}
    return output

# Gradio interfeysini yaratish
with gr.Blocks() as demo:
    gr.Markdown("## Text Classification Pipeline")
    text_input = gr.Textbox(label="Enter Text", placeholder="Type something here...")
    output_label = gr.Label(label="Classification Results")
    classify_button = gr.Button("Classify")
    
    classify_button.click(classify_text, inputs=text_input, outputs=output_label)

# Interfeysni ishga tushirish
demo.launch()