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=None, lines=3 ) ], outputs=gr.HTML(), title="Text Category Classification", css=""" .gradio-container { font-family: Arial, sans-serif; } .gradio-interface { max-width: 800px !important; } #component-0 { border-radius: 8px; border: 1px solid #ddd; } .submit-button { background-color: #ff6b33 !important; } .clear-button { background-color: #f0f0f0 !important; color: #333 !important; } """, examples=[ ["Messi jahon chempioni bo'ldi"], ["Yangi iPhone 15 Pro Max sotuvga chiqdi"], ["Kitob o'qish foydali"], ["Toshkentda ob-havo issiq"] ] ) iface.launch(share=True)