import gradio as gr import torch from diffusers import UnCLIPPipeline pipe = UnCLIPPipeline.from_pretrained("kakaobrain/karlo-v1-alpha", torch_dtype=torch.float16) pipe = pipe.to("cuda") def run(prompt): images = pipe([prompt]*6).images return images css = ''' .container{max-width: 800px} #title_area{text-align: center} .footer {margin-bottom: 45px;text-align: center;border-bottom: 1px solid #e5e5e5} .footer>p {font-size: .8rem;display: inline-block;padding: 0 10px;transform: translateY(10px);background: white} .dark .footer {border-color: #303030} .dark .footer>p {background: #0b0f19} .acknowledgments h4{margin: 1.25em 0 .25em 0;font-weight: bold;font-size: 115%} ''' with gr.Blocks(css=css) as demo: with gr.Column(variant="panel"): gr.Markdown('''## Karlo - unCLIP model by KakaoBrain ##### First [open source implementation](https://github.com/kakaobrain/karlo) of unCLIP, the DALL-E 2 technique. For more try our [B^Discover app](https://huggingface.co/kakaobrain/karlo-v1-alpha) ''', elem_id="title_area") with gr.Row(variant="compact"): text = gr.Textbox( label="Enter your prompt", show_label=False, max_lines=1, placeholder="Enter your prompt", ).style( container=False, ) btn = gr.Button("Generate image").style(full_width=False) gallery = gr.Gallery( label="Generated images", show_label=False, elem_id="gallery" ).style(grid=[3], height="auto") text.submit(run, text, gallery) btn.click(run, text, gallery) examples = ["A man with a face of avocado, in the drawing style of Rene Magritte", "a black porcelain in the shape of pikachu", "a portrait of an old monk, highly detailed", "A teddy bear on a skateboard, children drawing style.", ] ex = gr.Examples(examples=examples, fn=run, inputs=text, outputs=gallery, cache_examples=True) ex.dataset.headers = [""] gr.HTML('''
For Faster Results you can skip the queue by duplicating this space:
''') gr.HTML( """