Update app.py
Browse files
app.py
CHANGED
@@ -50,7 +50,7 @@ def generate(prompt):
|
|
50 |
return break_until_dot(decoded)
|
51 |
|
52 |
def generate_image(prompt, inference_steps):
|
53 |
-
prompt = prompt + '
|
54 |
img = pipe(prompt, height=512, width=512, num_inference_steps=inference_steps)
|
55 |
return img.images[0]
|
56 |
|
@@ -62,16 +62,16 @@ def generate_story(prompt):
|
|
62 |
|
63 |
with gr.Blocks() as demo:
|
64 |
title = gr.Markdown('## Lord of the rings app')
|
65 |
-
description = gr.Markdown('
|
66 |
prompt = gr.Textbox(label="Your prompt", value="Frodo took the sword and")
|
67 |
story = gr.Textbox(label="Your story")
|
68 |
summary = gr.Textbox(label="Summary")
|
69 |
|
70 |
bt_make_text = gr.Button("Generate text")
|
71 |
-
bt_make_image = gr.Button("Generate an image (takes about 10-15 minutes on CPU)", visible=False)
|
72 |
|
73 |
-
image = gr.Image(label='Illustration for your story')
|
74 |
-
inference_steps = gr.Slider(5, 30, value=15, step=1, label="Num inference steps (more steps makes a better image but takes more time)")
|
75 |
|
76 |
bt_make_text.click(fn=generate_story, inputs=prompt, outputs=[story, summary, bt_make_image])
|
77 |
bt_make_image.click(fn=generate_image, inputs=[summary, inference_steps], outputs=image)
|
|
|
50 |
return break_until_dot(decoded)
|
51 |
|
52 |
def generate_image(prompt, inference_steps):
|
53 |
+
prompt = prompt + ' masterpiece charcoal pencil art lord of the rings illustration'
|
54 |
img = pipe(prompt, height=512, width=512, num_inference_steps=inference_steps)
|
55 |
return img.images[0]
|
56 |
|
|
|
62 |
|
63 |
with gr.Blocks() as demo:
|
64 |
title = gr.Markdown('## Lord of the rings app')
|
65 |
+
description = gr.Markdown(f'#### A Lord of the rings insired app that combines text and image generation. The language modeling is done by fine tuning distilgpt2 on the LOTR trilogy. The text2img model is {model_id}. The summarization is done using distilbart.')
|
66 |
prompt = gr.Textbox(label="Your prompt", value="Frodo took the sword and")
|
67 |
story = gr.Textbox(label="Your story")
|
68 |
summary = gr.Textbox(label="Summary")
|
69 |
|
70 |
bt_make_text = gr.Button("Generate text")
|
71 |
+
bt_make_image = gr.Button(f"Generate an image (takes about 10-15 minutes on CPU).", visible=False)
|
72 |
|
73 |
+
image = gr.Image(label='Illustration for your story', shape=(512, 512))
|
74 |
+
inference_steps = gr.Slider(5, 30, value=15, step=1, label=f"Num inference steps (more steps makes a better image but takes more time)")
|
75 |
|
76 |
bt_make_text.click(fn=generate_story, inputs=prompt, outputs=[story, summary, bt_make_image])
|
77 |
bt_make_image.click(fn=generate_image, inputs=[summary, inference_steps], outputs=image)
|