Spaces:
Build error
Build error
initial comment
Browse files- app.py +23 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Pipeline-ni o'rnatish
|
| 5 |
+
pipe = pipeline("text-classification", model="AbrorBalxiyev/my_awesome_model")
|
| 6 |
+
|
| 7 |
+
# Klassifikatsiya funksiyasi
|
| 8 |
+
def classify_text(text):
|
| 9 |
+
results = pipe(text)
|
| 10 |
+
output = {result['label']: f"{result['score'] * 100:.2f}%" for result in results}
|
| 11 |
+
return output
|
| 12 |
+
|
| 13 |
+
# Gradio interfeysini yaratish
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
gr.Markdown("## Text Classification Pipeline")
|
| 16 |
+
text_input = gr.Textbox(label="Enter Text", placeholder="Type something here...")
|
| 17 |
+
output_label = gr.Label(label="Classification Results")
|
| 18 |
+
classify_button = gr.Button("Classify")
|
| 19 |
+
|
| 20 |
+
classify_button.click(classify_text, inputs=text_input, outputs=output_label)
|
| 21 |
+
|
| 22 |
+
# Interfeysni ishga tushirish
|
| 23 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
gradio
|
| 3 |
+
torch
|