Spaces:
Sleeping
Sleeping
Create app.ny
Browse files
app.ny
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
!pip install gradio --quiet
|
2 |
+
!pip install transformers --quiet
|
3 |
+
|
4 |
+
from transformers import pipeline
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
|
8 |
+
pipe = pipeline("text-classification", model="CAMeL-Lab/bert-base-arabic-camelbert-ca-sentiment")
|
9 |
+
textbox = gr.Textbox(label="ادخل الجملة")
|
10 |
+
textoutput1 = gr.Textbox(label="الشعور")
|
11 |
+
textoutput2 = gr.Textbox(label="الدقة")
|
12 |
+
|
13 |
+
#fuction that takes the text and returns 2 values(sentiment and confidence)
|
14 |
+
def get_sentiment(text):
|
15 |
+
result = pipe(text)
|
16 |
+
sentiment = result[0]['label']
|
17 |
+
confidence = result[0]['score']
|
18 |
+
return sentiment, confidence
|
19 |
+
|
20 |
+
#interface Gradio
|
21 |
+
gr.Interface(fn=get_sentiment, inputs=textbox, outputs=[textoutput1, textoutput2]).launch()
|
22 |
+
|