Ertugrul commited on
Commit
4dadc70
1 Parent(s): 52f8887

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -19
app.py CHANGED
@@ -2,35 +2,42 @@ from transformers import TextClassificationPipeline, AutoTokenizer, AutoModelFor
2
  import gradio as gr
3
  import os
4
 
5
- # def get_model(model_name='Overfit-GM/temp_dist'):
6
- # id2label = {0: 'INSULT', 1: 'OTHER',
7
- # 2: 'PROFANITY', 3: 'RACIST', 4: 'SEXIST'}
8
- # label2id = {v: k for k, v in id2label.items()}
9
- # tokenizer = AutoTokenizer.from_pretrained(model_name)
10
- # model = AutoModelForSequenceClassification.from_pretrained(model_name,
11
- # problem_type="single_label_classification",
12
- # id2label=id2label,
13
- # label2id=label2id,
14
- # num_labels=5,
15
- # output_hidden_states=False,
16
- # )
17
- # return model, tokenizer
18
-
19
-
20
  models = [
21
- "Overfit-GM/temp_dist",
22
- "Overfit-GM/bert-base-turkish-cased-offensive"
 
 
 
 
 
 
 
 
 
 
 
23
  ]
24
 
25
  model_box=[
26
  gr.load(models[0], src='models', hf_token=os.environ['API_KEY']),
27
  gr.load(models[1], src='models', hf_token=os.environ['API_KEY']),
 
 
 
 
 
 
 
 
 
 
 
28
  ]
29
 
30
  def sentiment_analysis(text, model_choice):
31
 
32
- a_variable = model_box[model_choice]
33
- output = a_variable(text)
34
  return output
35
 
36
  with gr.Blocks() as demo:
 
2
  import gradio as gr
3
  import os
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  models = [
6
+ "Overfit-GM/bert-base-turkish-cased-offensive",
7
+ "Overfit-GM/bert-base-turkish-uncased-offensive",
8
+ "Overfit-GM/bert-base-turkish-128k-cased-offensive",
9
+ "Overfit-GM/bert-base-turkish-128k-uncased-offensive",
10
+ "Overfit-GM/convbert-base-turkish-mc4-cased-offensive",
11
+ "Overfit-GM/convbert-base-turkish-mc4-uncased-offensive",
12
+ "Overfit-GM/convbert-base-turkish-cased-offensive",
13
+ "Overfit-GM/distilbert-base-turkish-cased-offensive",
14
+ "Overfit-GM/electra-base-turkish-cased-discriminator-offensive",
15
+ "Overfit-GM/electra-base-turkish-mc4-cased-discriminator-offensive",
16
+ "Overfit-GM/electra-base-turkish-mc4-uncased-discriminator-offensive",
17
+ "Overfit-GM/xlm-roberta-large-turkish-offensive",
18
+ "Overfit-GM/mdeberta-v3-base-offensive"
19
  ]
20
 
21
  model_box=[
22
  gr.load(models[0], src='models', hf_token=os.environ['API_KEY']),
23
  gr.load(models[1], src='models', hf_token=os.environ['API_KEY']),
24
+ gr.load(models[2], src='models', hf_token=os.environ['API_KEY']),
25
+ gr.load(models[3], src='models', hf_token=os.environ['API_KEY']),
26
+ gr.load(models[4], src='models', hf_token=os.environ['API_KEY']),
27
+ gr.load(models[5], src='models', hf_token=os.environ['API_KEY']),
28
+ gr.load(models[6], src='models', hf_token=os.environ['API_KEY']),
29
+ gr.load(models[7], src='models', hf_token=os.environ['API_KEY']),
30
+ gr.load(models[8], src='models', hf_token=os.environ['API_KEY']),
31
+ gr.load(models[9], src='models', hf_token=os.environ['API_KEY']),
32
+ gr.load(models[10], src='models', hf_token=os.environ['API_KEY']),
33
+ gr.load(models[11], src='models', hf_token=os.environ['API_KEY']),
34
+ gr.load(models[12], src='models', hf_token=os.environ['API_KEY'])
35
  ]
36
 
37
  def sentiment_analysis(text, model_choice):
38
 
39
+ model = model_box[model_choice]
40
+ output = model(text)
41
  return output
42
 
43
  with gr.Blocks() as demo: