hipnologo commited on
Commit
d0c8cff
1 Parent(s): a967e1a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -1,16 +1,15 @@
1
  import gradio as gr
2
  #gr.Interface.load("models/hipnologo/gpt2-imdb-finetune").launch()
3
- import gradio as gr
4
 
5
- def postprocess_label(label):
6
- if label == "LABEL_0":
 
7
  return "Negative"
8
- elif label == "LABEL_1":
9
  return "Positive"
10
  else:
11
  return "Unknown label"
12
 
13
  iface = gr.Interface.load("models/hipnologo/gpt2-imdb-finetune")
14
- iface.update(outputs=gr.outputs.Textbox(label="Sentiment", postprocess=postprocess_label))
15
-
16
  iface.launch()
 
1
  import gradio as gr
2
  #gr.Interface.load("models/hipnologo/gpt2-imdb-finetune").launch()
 
3
 
4
+ def postprocess_label(model, inp):
5
+ result = model(inp)
6
+ if result == "LABEL_0":
7
  return "Negative"
8
+ elif result == "LABEL_1":
9
  return "Positive"
10
  else:
11
  return "Unknown label"
12
 
13
  iface = gr.Interface.load("models/hipnologo/gpt2-imdb-finetune")
14
+ iface.fn = lambda inp: postprocess_label(iface.fn, inp)
 
15
  iface.launch()