File size: 1,329 Bytes
e892275
 
 
 
 
 
 
 
 
 
 
 
 
 
bde7868
 
e892275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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()