SarahMarzouq's picture
Update app.py
bde7868 verified
from transformers import pipeline
import gradio as gr
#This is a pipeline for text classification using the Arabic MARBERT model for news article classification from Hugging Face.
Clasification = pipeline('text-classification', model='Ammar-alhaj-ali/arabic-MARBERT-news-article-classification')
#This function will take and input then return the label and the score of that sentence.
def classification_fun(news_article):
results = Clasification(news_article)
return results[0]['label'], results[0]['score']
#CSS styling for the Gradio interface
custom_css = """
textarea, .gradio-output {
direction: rtl;
# background-color: black;
# color: white;
border: 2px solid #800020;
border-radius: 5px;
padding: 10px;
}
label {
font-size: 18px;
font-weight: bold;
text-align: center;
background-color: #800020;
color: white;
box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
padding: 5px;
display: block;
margin: 10px 0;
}
.gradio-container {
background-color: black;
padding: 20px;
box-sizing: border-box;
}
"""
my_model = gr.Interface(
fn=classification_fun,
inputs=gr.Textbox(label="News Articles", lines=10, placeholder="Enter your Article"),
outputs=[gr.Textbox(label="Label of the Article"), gr.Number(label="Confidence Score")],
css=custom_css
)
my_model.launch()