Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
english_model = pipeline("text-classification", model="mrgmd01/Finetuned_siebert-sentiment-roberta-large-english")
|
| 5 |
+
urdu_model = pipeline("text-classification", model="mrgmd01/SA_Model_bert-base-multilingual-uncased")
|
| 6 |
+
|
| 7 |
+
def predict(text, language):
|
| 8 |
+
if language == "urdu" or language == "roman_urdu":
|
| 9 |
+
result = urdu_model(text)[0]
|
| 10 |
+
else:
|
| 11 |
+
result = english_model(text)[0]
|
| 12 |
+
return {"label": result["label"], "score": result["score"]}
|
| 13 |
+
|
| 14 |
+
gr.Interface(fn=predict, inputs=["text", "text"], outputs="json", api_name="predict").launch()
|