File size: 848 Bytes
b311465
 
2b0cb07
 
b311465
 
2b0cb07
b311465
 
27ba818
70c3ab1
 
b311465
 
 
 
 
b3cbe74
b311465
 
 
 
 
 
 
 
 
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
26
27
28
import gradio as gr
import torch
from transformers import pipeline
modelo = pipeline("text-to-image", model="runwayml/stable-diffusion-v1-5")

def generarImagen(texto):
    imagen = modelo(prompt=texto).images[0]
    return imagen

with gr.Blocks() as demo:
    gr.Markdown("# Generador Visual de Historia")
    gr.Markdown("Introduce la historia a la que quieras generar el texto")

    with gr.Row():
        with gr.Column(scale=1):
            entrada = gr.Textbox(
                label="Fragmento de la Historia",
                placeholder="Introduce"
            )
            btn = gr.Button("Generar Imagen", variant="primary")

        with gr.Column(scale=1):
            salida = gr.Image(label="Imagen Generada", type="pil")

    btn.click(fn=generarImagen, inputs=entrada, outputs=salida)

demo.launch(theme=gr.themes.Monochrome())