Spaces:
Runtime error
Runtime error
Separate card rendering from card image generation.
Browse files
app.py
CHANGED
@@ -356,28 +356,25 @@ with gr.Blocks(title='MagicGen') as demo:
|
|
356 |
with gr.Row():
|
357 |
with gr.Column():
|
358 |
in_text = gr.TextArea(label="Card Text (Shift+Enter to submit)", value=starting_text)
|
|
|
359 |
in_image = gr.Image(label="Card Image (400px x 550px)", type='filepath', value='placeholder.png')
|
360 |
-
|
361 |
gr.ClearButton([audio_in, prompt_in, in_text, in_image])
|
362 |
with gr.Column():
|
363 |
out_image = gr.Image(label="Rendered Card", value=get_initial_card())
|
364 |
|
|
|
|
|
|
|
|
|
|
|
365 |
# Shift + Enter to submit text in TextAreas
|
366 |
-
audio_in.stop_recording(
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
None).then(
|
373 |
-
generate_card, [in_image, in_text], [out_image], None)
|
374 |
-
prompt_in.submit(generate_text, [in_text, prompt_in], [bot_text, in_text, audio_in]).then(generate_image, [in_text],
|
375 |
-
[in_image], None).then(
|
376 |
-
generate_card, [in_image, in_text], [out_image], None)
|
377 |
-
in_text.submit(generate_image, [in_text], [in_image], None).then(generate_card, [in_image, in_text], [out_image],
|
378 |
-
None)
|
379 |
-
run_button.click(generate_image, [in_text], [in_image], None).then(generate_card, [in_image, in_text], [out_image],
|
380 |
-
None)
|
381 |
demo.load(None, None, None, js=add_hotkeys())
|
382 |
|
383 |
if __name__ == "__main__":
|
|
|
356 |
with gr.Row():
|
357 |
with gr.Column():
|
358 |
in_text = gr.TextArea(label="Card Text (Shift+Enter to submit)", value=starting_text)
|
359 |
+
gen_image_button = gr.Button('🖼️ Generate Card Image')
|
360 |
in_image = gr.Image(label="Card Image (400px x 550px)", type='filepath', value='placeholder.png')
|
361 |
+
render_button = gr.Button('🎴 Render Card', variant="primary")
|
362 |
gr.ClearButton([audio_in, prompt_in, in_text, in_image])
|
363 |
with gr.Column():
|
364 |
out_image = gr.Image(label="Rendered Card", value=get_initial_card())
|
365 |
|
366 |
+
transcribe_params = {'fn': transcribe, 'inputs': [audio_in], 'outputs': [prompt_in, audio_in]}
|
367 |
+
generate_text_params = {'fn': generate_text, 'inputs': [in_text, prompt_in],
|
368 |
+
'outputs': [bot_text, in_text, audio_in]}
|
369 |
+
generate_image_params = {'fn': generate_image, 'inputs': [in_text], 'outputs': [in_image]}
|
370 |
+
generate_card_params = {'fn': generate_card, 'inputs': [in_image, in_text], 'outputs': [out_image]}
|
371 |
# Shift + Enter to submit text in TextAreas
|
372 |
+
audio_in.stop_recording(**transcribe_params).then(**generate_text_params).then(**generate_image_params).then(
|
373 |
+
**generate_card_params)
|
374 |
+
prompt_in.submit(**generate_text_params).then(**generate_image_params).then(**generate_card_params)
|
375 |
+
in_text.submit(**generate_card_params)
|
376 |
+
render_button.click(**generate_card_params)
|
377 |
+
gen_image_button.click(**generate_image_params).then(**generate_card_params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
demo.load(None, None, None, js=add_hotkeys())
|
379 |
|
380 |
if __name__ == "__main__":
|