File size: 783 Bytes
4188a3b
 
 
 
 
34cfb12
4188a3b
 
8d74675
34cfb12
9133fa2
 
 
8d74675
 
 
9133fa2
4188a3b
9133fa2
 
 
8d74675
 
9133fa2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from transformers import pipeline, set_seed
import gradio as grad
import random

gpt2_pipe = pipeline('text-generation', model='succinctly/text2image-prompt-generator')


def generate(starting_text):
    seed = random.randint(1, 100000)
    set_seed(seed)
    response = gpt2_pipe(starting_text, max_length=30, num_return_sequences=random.randint(5, 15))
    response_list = "\n".join(response)
    return response_list


txt = grad.Textbox(lines=1, label="English", placeholder="English Text here")
out = grad.Textbox(lines=5, label="Generated Text")

grad.Interface(fn=generate,
               inputs=txt, 
               outputs=out,
               allow_flagging='never',
               cache_examples=False,
               theme="default").launch(enable_queue=True, debug=True)