Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the model from Hugging Face Hub
|
5 |
+
model_name = "yosrissa/AITA-D-BERT-classifier" # Replace with your Hugging Face model name
|
6 |
+
classifier = pipeline("text-classification", model=model_name)
|
7 |
+
|
8 |
+
def classify_text(input_text):
|
9 |
+
"""
|
10 |
+
Classify the input text using the model.
|
11 |
+
"""
|
12 |
+
results = classifier(input_text)
|
13 |
+
return results
|
14 |
+
|
15 |
+
# Create the Gradio interface
|
16 |
+
with gr.Blocks() as app:
|
17 |
+
gr.Markdown("# Text Classification App")
|
18 |
+
gr.Markdown("Enter text to classify:")
|
19 |
+
|
20 |
+
input_text = gr.Textbox(label="Input Text")
|
21 |
+
output = gr.JSON(label="Classification Results")
|
22 |
+
submit_button = gr.Button("Classify")
|
23 |
+
|
24 |
+
submit_button.click(classify_text, inputs=[input_text], outputs=[output])
|
25 |
+
|
26 |
+
# Launch the app
|
27 |
+
if __name__ == "__main__":
|
28 |
+
app.launch()
|