Spaces:
Runtime error
Runtime error
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline, set_seed
|
2 |
+
import gradio as grad
|
3 |
+
import random
|
4 |
+
|
5 |
+
|
6 |
+
gpt2_pipe = pipeline('text-generation', model='succinctly/text2image-prompt-generator')
|
7 |
+
set_seed(42)
|
8 |
+
|
9 |
+
def generate(starting_text):
|
10 |
+
seed = random.randint(1, 10000000)
|
11 |
+
response= gpt2_pipe(starting_text, max_length=20, num_return_sequences=5)
|
12 |
+
return response
|
13 |
+
|
14 |
+
txt=grad.Textbox(lines=1, label="English", placeholder="English Text here")
|
15 |
+
out=grad.Textbox(lines=1, label="Generated Text")
|
16 |
+
|
17 |
+
grad.Interface(fn=generate, inputs=txt, outputs=out,
|
18 |
+
allow_flagging='never',
|
19 |
+
cache_examples=False,
|
20 |
+
theme="default").launch(enable_queue=True, debug=True)
|