Spaces:
Runtime error
Runtime error
dropdowns
Browse files
app.py
CHANGED
@@ -2,11 +2,22 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
from transformers import BartForConditionalGeneration, BartTokenizer
|
4 |
|
|
|
|
|
|
|
5 |
|
6 |
-
model
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
def genQuestion(context):
|
10 |
inputs = tok(context, return_tensors="pt")
|
11 |
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=2)
|
12 |
final_output = ''
|
@@ -15,6 +26,6 @@ def genQuestion(context):
|
|
15 |
final_output += [tok.decode(beam, skip_special_tokens=True, clean_up_tokenization_spaces=False) for beam in output][i] + "\n"
|
16 |
|
17 |
return final_output
|
18 |
-
|
19 |
-
iface = gr.Interface(fn=genQuestion, inputs="text", outputs="text")
|
20 |
iface.launch()
|
|
|
2 |
import torch
|
3 |
from transformers import BartForConditionalGeneration, BartTokenizer
|
4 |
|
5 |
+
# initialize model + tok variables
|
6 |
+
model = None
|
7 |
+
tok = None
|
8 |
|
9 |
+
# pass in Strings of model choice and input text for context
|
10 |
+
def genQuestion(model_choice, context):
|
11 |
+
if model_choice=="interview-question-remake":
|
12 |
+
model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-question-remake")
|
13 |
+
tok = BartTokenizer.from_pretrained("hyechanjun/interview-question-remake")
|
14 |
+
elif model_choice=="interview-length-tagged":
|
15 |
+
model = BartForConditionalGeneration.from_pretrained("hyechanjun/interview-length-tagged")
|
16 |
+
tok = BartTokenizer.from_pretrained("hyechanjun/interview-length-tagged")
|
17 |
+
elif model_choice=="reverse-interview-question":
|
18 |
+
model = BartForConditionalGeneration.from_pretrained("hyechanjun/reverse-interview-question")
|
19 |
+
tok = BartTokenizer.from_pretrained("hyechanjun/reverse-interview-question")
|
20 |
|
|
|
21 |
inputs = tok(context, return_tensors="pt")
|
22 |
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=2)
|
23 |
final_output = ''
|
|
|
26 |
final_output += [tok.decode(beam, skip_special_tokens=True, clean_up_tokenization_spaces=False) for beam in output][i] + "\n"
|
27 |
|
28 |
return final_output
|
29 |
+
|
30 |
+
iface = gr.Interface(fn=genQuestion, inputs=[gr.inputs.Dropdown(["interview-question-remake", "interview-length-tagged", "reverse-interview-question"]), "text"], outputs="text")
|
31 |
iface.launch()
|