OsBaran commited on
Commit
936bb70
·
1 Parent(s): 3287643

Add application file

Browse files
Files changed (1) hide show
  1. app.py +25 -4
app.py CHANGED
@@ -1,7 +1,28 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()