File size: 835 Bytes
c3ada6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import gradio as gr
from transformers import pipeline

# Load the model from Hugging Face Hub
model_name = "yosrissa/AITA-D-BERT-classifier"  # Replace with your Hugging Face model name
classifier = pipeline("text-classification", model=model_name)

def classify_text(input_text):
    """
    Classify the input text using the model.
    """
    results = classifier(input_text)
    return results

# Create the Gradio interface
with gr.Blocks() as app:
    gr.Markdown("# Text Classification App")
    gr.Markdown("Enter text to classify:")
    
    input_text = gr.Textbox(label="Input Text")
    output = gr.JSON(label="Classification Results")
    submit_button = gr.Button("Classify")
    
    submit_button.click(classify_text, inputs=[input_text], outputs=[output])

# Launch the app
if __name__ == "__main__":
    app.launch()