File size: 652 Bytes
c050060
a6a3f41
c050060
a6a3f41
 
c050060
a6a3f41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from transformers import pipeline
import gradio as gr

# Load the text classification pipeline
pipe = pipeline("text-classification", model="CAMeL-Lab/bert-base-arabic-camelbert-mix-sentiment")

# Define the function to classify text
def classify_text(text):
    result = pipe(text)
    return f"Label: {result[0]['label']}, Score: {result[0]['score']:.2f}"

# Create the Gradio interface
demo = gr.Interface(
    fn=classify_text, 
    inputs="text", 
    outputs="text", 
    title="Arabic Text Classification",
    description="Enter Arabic text to analyze its sentiment using CAMeL-Lab's Arabic BERT model."
)

# Launch the Gradio app
demo.launch()