mdj1412 commited on
Commit
4f2c346
1 Parent(s): 6c5db00

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -1,11 +1,13 @@
1
  import gradio as gr
 
 
2
  from transformers import AutoModelForSequenceClassification
3
  from transformers import AutoTokenizer
 
4
  import random
5
  import numpy as np
6
  import pandas as pd
7
  import torch
8
- import fasttext
9
 
10
 
11
 
@@ -14,8 +16,8 @@ label2id = {"NEGATIVE": 0, "POSITIVE": 1}
14
 
15
 
16
  title = "Movie Review Score Discriminator"
17
- description = "It is a program that classifies whether it is positive or negative by entering movie reviews. \
18
- You can choose between the Korean version and the English version. \
19
  It also provides a version called Any, which determines whether it is Korean or English and predicts it."
20
 
21
 
@@ -94,8 +96,6 @@ def builder(lang, text):
94
  with torch.no_grad():
95
  logits = model(input_ids=inputs['input_ids'],
96
  attention_mask=inputs['attention_mask']).logits
97
-
98
-
99
 
100
  m = torch.nn.Softmax(dim=1)
101
  output = m(logits)
@@ -109,7 +109,7 @@ def builder(lang, text):
109
 
110
 
111
  demo = gr.Interface(builder, inputs=[gr.inputs.Dropdown(['Any', 'Eng', 'Kor']), "text"],
112
- outputs=gr.Label(num_top_classes=2, label='Res', color='CadetBlue'),
113
  # outputs='label',
114
  title=title, description=description, examples=examples)
115
 
@@ -118,7 +118,6 @@ demo = gr.Interface(builder, inputs=[gr.inputs.Dropdown(['Any', 'Eng', 'Kor']),
118
  # title=title, theme="peach",
119
  # allow_flagging="auto",
120
  # description=description, examples=examples)
121
- output = []
122
 
123
  if __name__ == "__main__":
124
  # print(examples)
 
1
  import gradio as gr
2
+ import fasttext
3
+
4
  from transformers import AutoModelForSequenceClassification
5
  from transformers import AutoTokenizer
6
+
7
  import random
8
  import numpy as np
9
  import pandas as pd
10
  import torch
 
11
 
12
 
13
 
 
16
 
17
 
18
  title = "Movie Review Score Discriminator"
19
+ description = "It is a program that classifies whether it is positive or negative by entering movie reviews. \
20
+ You can choose between the Korean version and the English version. \
21
  It also provides a version called Any, which determines whether it is Korean or English and predicts it."
22
 
23
 
 
96
  with torch.no_grad():
97
  logits = model(input_ids=inputs['input_ids'],
98
  attention_mask=inputs['attention_mask']).logits
 
 
99
 
100
  m = torch.nn.Softmax(dim=1)
101
  output = m(logits)
 
109
 
110
 
111
  demo = gr.Interface(builder, inputs=[gr.inputs.Dropdown(['Any', 'Eng', 'Kor']), "text"],
112
+ outputs=gr.Label(num_top_classes=2, label='Result', color='CadetBlue'),
113
  # outputs='label',
114
  title=title, description=description, examples=examples)
115
 
 
118
  # title=title, theme="peach",
119
  # allow_flagging="auto",
120
  # description=description, examples=examples)
 
121
 
122
  if __name__ == "__main__":
123
  # print(examples)