Spaces:
Running
Running
Add application file
Browse files
app.py
CHANGED
@@ -1,7 +1,28 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline
|
3 |
|
4 |
+
# Buraya İngilizce modelinizi yazın
|
5 |
+
model_en = AutoModelForSequenceClassification.from_pretrained("OsBaran/Roberta-Classification-Model")
|
6 |
+
tokenizer_en = AutoTokenizer.from_pretrained("roberta-base")
|
7 |
+
classifier_en = pipeline("sentiment-analysis", model=model_en, tokenizer=tokenizer_en)
|
8 |
|
9 |
+
# Türkçe modelini yükle
|
10 |
+
model_tr_name = "dbmdz/bert-base-turkish-cased" # Buraya Türkçe modelinizi yazın
|
11 |
+
model_tr = AutoModelForSequenceClassification.from_pretrained(model_tr_name)
|
12 |
+
tokenizer_tr = AutoTokenizer.from_pretrained(model_tr_name)
|
13 |
+
classifier_tr = pipeline("sentiment-analysis", model=model_tr, tokenizer=tokenizer_tr)
|
14 |
+
|
15 |
+
# Gradio ile API oluştur
|
16 |
+
def predict(text, language):
|
17 |
+
if language == "en":
|
18 |
+
result = classifier_en(text)
|
19 |
+
elif language == "tr":
|
20 |
+
result = classifier_tr(text)
|
21 |
+
else:
|
22 |
+
result = {"error": "Unsupported language"}
|
23 |
+
return result
|
24 |
+
|
25 |
+
# Arayüz
|
26 |
+
gr.Interface(fn=predict,
|
27 |
+
inputs=[gr.Textbox(label="Text Input"), gr.Dropdown(["en", "tr"], label="Language")],
|
28 |
+
outputs="json").launch()
|