hyechanjun commited on
Commit
b801c03
·
1 Parent(s): 95c95e8

back to gradio

Browse files
Files changed (2) hide show
  1. app.py +5 -15
  2. gradio-ver/app.py +0 -45
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import streamlit as st
2
  import torch
3
  from transformers import BartForConditionalGeneration, BartTokenizer
4
 
@@ -13,19 +13,6 @@ examples = [
13
  ["reverse-interview-question", "There are so many incredible musicians out there and so many really compelling big hits this year that it makes for a really interesting way to recap some of those big events."]
14
  ]
15
 
16
- # Title
17
- st.title("Interview AI Test Website")
18
-
19
- # Input field
20
- input = st.text_input('Context')
21
-
22
- option = st.selectbox(
23
- 'Please select a model.',
24
- ('interview-question-remake', 'interview-length-tagged', 'reverse-interview-question'))
25
-
26
- if st.button('Submit'):
27
- genQuestion(option, input)
28
-
29
  # Descriptions for each models
30
  # descriptions = "Interview question remake is a model that..."
31
 
@@ -52,4 +39,7 @@ def genQuestion(model_choice, context):
52
  for i in range(4):
53
  final_output += [tok.decode(beam, skip_special_tokens=True, clean_up_tokenization_spaces=False) for beam in output][i] + "\n"
54
 
55
- return final_output
 
 
 
 
1
+ import gradio as gr
2
  import torch
3
  from transformers import BartForConditionalGeneration, BartTokenizer
4
 
 
13
  ["reverse-interview-question", "There are so many incredible musicians out there and so many really compelling big hits this year that it makes for a really interesting way to recap some of those big events."]
14
  ]
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # Descriptions for each models
17
  # descriptions = "Interview question remake is a model that..."
18
 
 
39
  for i in range(4):
40
  final_output += [tok.decode(beam, skip_special_tokens=True, clean_up_tokenization_spaces=False) for beam in output][i] + "\n"
41
 
42
+ return final_output
43
+
44
+ iface = gr.Interface(fn=genQuestion, inputs=[gr.inputs.Dropdown(["interview-question-remake", "interview-length-tagged", "reverse-interview-question"]), "text"], examples=examples, outputs="text")
45
+ iface.launch()
gradio-ver/app.py DELETED
@@ -1,45 +0,0 @@
1
- import gradio as gr
2
- import torch
3
- from transformers import BartForConditionalGeneration, BartTokenizer
4
-
5
- # initialize model + tok variables
6
- model = None
7
- tok = None
8
-
9
- # Examples for each models
10
- examples = [
11
- ["interview-question-remake", "I have a cat named dolche and he's not very friendly with strangers. I've had him for 9 years now and it has been a pleasure to see him grow closer to us every year."],
12
- ["interview-length-tagged","Today's weather was really nice."],
13
- ["reverse-interview-question", "There are so many incredible musicians out there and so many really compelling big hits this year that it makes for a really interesting way to recap some of those big events."]
14
- ]
15
-
16
- # Descriptions for each models
17
- # descriptions = "Interview question remake is a model that..."
18
-
19
- # pass in Strings of model choice and input text for context
20
- def genQuestion(model_choice, context):
21
- # global descriptions
22
- if model_choice=="interview-question-remake":
23
- model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-question-remake")
24
- tok = BartTokenizer.from_pretrained("hyechanjun/interview-question-remake")
25
- # descriptions = "Interview question remake is a model that..."
26
- elif model_choice=="interview-length-tagged":
27
- model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-length-tagged")
28
- tok = BartTokenizer.from_pretrained("hyechanjun/interview-length-tagged")
29
- # descriptions = "Interview question tagged is a model that..."
30
- elif model_choice=="reverse-interview-question":
31
- model = BartForConditionalGeneration.from_pretrained("hyechanjun/reverse-interview-question")
32
- tok = BartTokenizer.from_pretrained("hyechanjun/reverse-interview-question")
33
- # descriptions = "Reverse interview question is a model that..."
34
-
35
- inputs = tok(context, return_tensors="pt")
36
- output = model.generate(inputs["input_ids"], num_beams=4, max_length=64, min_length=9, num_return_sequences=4, diversity_penalty =1.0, num_beam_groups=4)
37
- final_output = ''
38
-
39
- for i in range(4):
40
- final_output += [tok.decode(beam, skip_special_tokens=True, clean_up_tokenization_spaces=False) for beam in output][i] + "\n"
41
-
42
- return final_output
43
-
44
- iface = gr.Interface(fn=genQuestion, inputs=[gr.inputs.Dropdown(["interview-question-remake", "interview-length-tagged", "reverse-interview-question"]), "text"], examples=examples, outputs="text")
45
- iface.launch()