Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
#This is a pipeline for text classification using the Arabic MARBERT model for news article classification from Hugging Face.
|
4 |
+
Clasification = pipeline('text-classification', model='Ammar-alhaj-ali/arabic-MARBERT-news-article-classification')
|
5 |
+
#This function will take and input then return the label and the score of that sentence.
|
6 |
+
def classification_fun(news_article):
|
7 |
+
results = Clasification(news_article)
|
8 |
+
return results[0]['label'], results[0]['score']
|
9 |
+
|
10 |
+
my_model = gr.Interface(
|
11 |
+
fn=classification_fun,
|
12 |
+
inputs=gr.Textbox(label="News Articles", lines=10, placeholder="Enter your Article"),
|
13 |
+
outputs=[gr.Textbox(label="Label of the Article"), gr.Number(label="Confidence Score")],
|
14 |
+
)
|
15 |
+
|
16 |
+
my_model.launch()
|