Update app.py
Browse files
app.py
CHANGED
@@ -27,6 +27,10 @@ model.to(device)
|
|
27 |
tokenizer = GPT2Tokenizer.from_pretrained('gpt2-medium')
|
28 |
tokenizer.pad_token = tokenizer.eos_token
|
29 |
|
|
|
|
|
|
|
|
|
30 |
|
31 |
examples = [
|
32 |
["Is string theory right?"],
|
@@ -35,7 +39,7 @@ examples = [
|
|
35 |
]
|
36 |
|
37 |
demo = gr.Interface(
|
38 |
-
fn =
|
39 |
inputs=gr.inputs.Textbox(lines=5, label="Arbitrary Input Text"),
|
40 |
outputs=gr.outputs.Textbox(label="Generated Prompt for Visualizations"),
|
41 |
examples=examples
|
|
|
27 |
tokenizer = GPT2Tokenizer.from_pretrained('gpt2-medium')
|
28 |
tokenizer.pad_token = tokenizer.eos_token
|
29 |
|
30 |
+
def generate(text):
|
31 |
+
result =generate(text,model,tokenizer,do_sample=True,device=device)
|
32 |
+
return result
|
33 |
+
|
34 |
|
35 |
examples = [
|
36 |
["Is string theory right?"],
|
|
|
39 |
]
|
40 |
|
41 |
demo = gr.Interface(
|
42 |
+
fn =generate,
|
43 |
inputs=gr.inputs.Textbox(lines=5, label="Arbitrary Input Text"),
|
44 |
outputs=gr.outputs.Textbox(label="Generated Prompt for Visualizations"),
|
45 |
examples=examples
|