Spaces:
Sleeping
Sleeping
swcrazyfan
commited on
Commit
•
0fac84d
1
Parent(s):
e076c74
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,8 @@ def tokenize_data(text):
|
|
18 |
"attention_mask": tokenized_inputs['attention_mask']}
|
19 |
return inputs
|
20 |
|
21 |
-
def generate_answers(text, max_length, min_length, num_beams):
|
|
|
22 |
inputs = tokenize_data(text)
|
23 |
results= model.generate(input_ids= inputs['input_ids'], attention_mask=inputs['attention_mask'], do_sample=True,
|
24 |
num_beams=num_beams,
|
@@ -29,5 +30,7 @@ def generate_answers(text, max_length, min_length, num_beams):
|
|
29 |
answer = tokenizer.decode(results[0], skip_special_tokens=True)
|
30 |
return answer
|
31 |
|
32 |
-
iface = gr.Interface(title="DeKingify", description="Write anything below. Then, click submit to 'DeKingify' it.", fn=generate_answers, inputs=[gr.inputs.Textbox(label="Original Text",lines=10), gr.inputs.Slider(label="Maximum Length", minimum=1, maximum=512, default=512, step=1), gr.inputs.Slider(label="Minimum Length", minimum=1, maximum=512, default=1, step=1), gr.inputs.Slider(label="Number of Beams", minimum=1, maximum=
|
|
|
|
|
33 |
iface.launch(inline=False)
|
|
|
18 |
"attention_mask": tokenized_inputs['attention_mask']}
|
19 |
return inputs
|
20 |
|
21 |
+
#def generate_answers(text, max_length, min_length, num_beams):
|
22 |
+
def generate_answers(text, max_length, num_beams):
|
23 |
inputs = tokenize_data(text)
|
24 |
results= model.generate(input_ids= inputs['input_ids'], attention_mask=inputs['attention_mask'], do_sample=True,
|
25 |
num_beams=num_beams,
|
|
|
30 |
answer = tokenizer.decode(results[0], skip_special_tokens=True)
|
31 |
return answer
|
32 |
|
33 |
+
#iface = gr.Interface(title="DeKingify", description="Write anything below. Then, click submit to 'DeKingify' it.", fn=generate_answers, inputs=[gr.inputs.Textbox(label="Original Text",lines=10), gr.inputs.Slider(label="Maximum Length", minimum=1, maximum=512, default=512, step=1), gr.inputs.Slider(label="Minimum Length", minimum=1, maximum=512, default=1, step=1), gr.inputs.Slider(label="Number of Beams", minimum=1, maximum=50, default=5, step=1)], outputs=["text"])
|
34 |
+
|
35 |
+
iface = gr.Interface(title="DeKingify", description="Write anything below. Then, click submit to 'DeKingify' it.", fn=generate_answers, inputs=[gr.inputs.Textbox(label="Original Text",lines=10), gr.inputs.Slider(label="Maximum Length", minimum=1, maximum=512, default=512, step=1), gr.inputs.Slider(label="Number of Beams", minimum=1, maximum=50, default=5, step=1)], outputs=["text"])
|
36 |
iface.launch(inline=False)
|