Spaces:
Sleeping
Sleeping
File size: 642 Bytes
aa0984e 597d35a |
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
pipe = pipeline("text-classification", model="CAMeL-Lab/bert-base-arabic-camelbert-ca-sentiment")
textbox = gr.Textbox(label="ادخل الجملة")
textoutput1 = gr.Textbox(label="الشعور")
textoutput2 = gr.Textbox(label="الدقة")
#fuction that takes the text and returns 2 values(sentiment and confidence)
def get_sentiment(text):
result = pipe(text)
sentiment = result[0]['label']
confidence = result[0]['score']
return sentiment, confidence
#interface Gradio
gr.Interface(fn=get_sentiment, inputs=textbox, outputs=[textoutput1, textoutput2]).launch()
|