Update app.py
Browse files
app.py
CHANGED
@@ -9,15 +9,20 @@ def generate(starting_text):
|
|
9 |
seed = random.randint(1, 100000)
|
10 |
set_seed(seed)
|
11 |
response = gpt2_pipe(starting_text, max_length=30, num_return_sequences=random.randint(5, 15))
|
12 |
-
response_list =
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
txt = grad.Textbox(lines=1, label="English", placeholder="English Text here")
|
17 |
out = grad.Textbox(lines=5, label="Generated Text")
|
18 |
|
19 |
grad.Interface(fn=generate,
|
20 |
-
inputs=txt,
|
21 |
outputs=out,
|
22 |
allow_flagging='never',
|
23 |
cache_examples=False,
|
|
|
9 |
seed = random.randint(1, 100000)
|
10 |
set_seed(seed)
|
11 |
response = gpt2_pipe(starting_text, max_length=30, num_return_sequences=random.randint(5, 15))
|
12 |
+
response_list = []
|
13 |
+
for x in response:
|
14 |
+
if x['generated_text'].strip() != starting_text:
|
15 |
+
response_list.append(x['generated_text'])
|
16 |
+
|
17 |
+
response_end = "\n".join(response_list)
|
18 |
+
return response_end
|
19 |
|
20 |
|
21 |
txt = grad.Textbox(lines=1, label="English", placeholder="English Text here")
|
22 |
out = grad.Textbox(lines=5, label="Generated Text")
|
23 |
|
24 |
grad.Interface(fn=generate,
|
25 |
+
inputs=txt,
|
26 |
outputs=out,
|
27 |
allow_flagging='never',
|
28 |
cache_examples=False,
|