|
import gradio as gr
|
|
from transformers import pipeline
|
|
|
|
|
|
pipe = pipeline("text-classification", model="AbrorBalxiyev/my_awesome_model")
|
|
|
|
|
|
def classify_text(text):
|
|
results = pipe(text)
|
|
output = {result['label']: f"{result['score'] * 100:.2f}%" for result in results}
|
|
return output
|
|
|
|
|
|
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)
|
|
|
|
|
|
demo.launch() |