Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,22 @@
|
|
1 |
-
# Use a pipeline as a high-level helper
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
-
|
|
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
|
4 |
+
# Load the text classification pipeline
|
5 |
+
pipe = pipeline("text-classification", model="CAMeL-Lab/bert-base-arabic-camelbert-mix-sentiment")
|
6 |
|
7 |
+
# Define the function to classify text
|
8 |
+
def classify_text(text):
|
9 |
+
result = pipe(text)
|
10 |
+
return f"Label: {result[0]['label']}, Score: {result[0]['score']:.2f}"
|
11 |
+
|
12 |
+
# Create the Gradio interface
|
13 |
+
demo = gr.Interface(
|
14 |
+
fn=classify_text,
|
15 |
+
inputs="text",
|
16 |
+
outputs="text",
|
17 |
+
title="Arabic Text Classification",
|
18 |
+
description="Enter Arabic text to analyze its sentiment using CAMeL-Lab's Arabic BERT model."
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the Gradio app
|
22 |
+
demo.launch()
|