mdj1412 commited on
Commit
dd21895
1 Parent(s): 63644af

Update app.py color

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -123,9 +123,17 @@ def builder(lang, text):
123
  logit = model(input_ids=tokenized_word['input_ids'],
124
  attention_mask=tokenized_word['attention_mask']).logits
125
  word_output = m(logit)
126
- if word_output[0][1] > 0.95:
 
 
 
 
127
  output_analysis.append( (word, '+') )
128
- elif word_output[0][1] < 0.05:
 
 
 
 
129
  output_analysis.append( (word, '-') )
130
  else:
131
  output_analysis.append( (word, None) )
@@ -148,7 +156,8 @@ def builder(lang, text):
148
  demo = gr.Interface(builder, inputs=[gr.inputs.Dropdown(['Any', 'Eng', 'Kor']), "text"],
149
  outputs=[ gr.Label(num_top_classes=3, label='Lang'),
150
  gr.Label(num_top_classes=2, label='Result'),
151
- gr.HighlightedText(label="Analysis", combine_adjacent=False).style(color_map={"+": "red", "-": "green"}) ],
 
152
  # outputs='label',
153
  title=title, description=description, examples=examples)
154
 
 
123
  logit = model(input_ids=tokenized_word['input_ids'],
124
  attention_mask=tokenized_word['attention_mask']).logits
125
  word_output = m(logit)
126
+ if word_output[0][1] > 0.99:
127
+ output_analysis.append( (word, '+++') )
128
+ elif word_output[0][1] > 0.9:
129
+ output_analysis.append( (word, '++') )
130
+ elif word_output[0][1] > 0.8:
131
  output_analysis.append( (word, '+') )
132
+ elif word_output[0][1] < 0.01:
133
+ output_analysis.append( (word, '---') )
134
+ elif word_output[0][1] < 0.1:
135
+ output_analysis.append( (word, '--') )
136
+ elif word_output[0][1] < 0.2:
137
  output_analysis.append( (word, '-') )
138
  else:
139
  output_analysis.append( (word, None) )
 
156
  demo = gr.Interface(builder, inputs=[gr.inputs.Dropdown(['Any', 'Eng', 'Kor']), "text"],
157
  outputs=[ gr.Label(num_top_classes=3, label='Lang'),
158
  gr.Label(num_top_classes=2, label='Result'),
159
+ gr.HighlightedText(label="Analysis", combine_adjacent=False)
160
+ .style(color_map={"+++": "#CF0000", "++": "#FF3232", "+": "#FFD4D4", "---": "#0600CF", "--": "#4C47FF", "-": "#BEBDFF"}) ],
161
  # outputs='label',
162
  title=title, description=description, examples=examples)
163