Spaces:
Runtime error
Runtime error
import gradio as gr | |
from diffusers import LMSDiscreteScheduler | |
from mixdiff import StableDiffusionCanvasPipeline, Text2ImageRegion | |
# Creater scheduler and model (similar to StableDiffusionPipeline) | |
scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000) | |
pipeline = StableDiffusionCanvasPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", scheduler=scheduler).to("cuda:0") | |
def generate(prompt1, prompt2, prompt3, seed): | |
"""Mixture of Diffusers generation""" | |
return pipeline( | |
canvas_height=640, | |
canvas_width=1408, | |
regions=[ | |
Text2ImageRegion(0, 640, 0, 640, guidance_scale=8, | |
prompt=prompt1), | |
Text2ImageRegion(0, 640, 384, 1024, guidance_scale=8, | |
prompt=prompt2), | |
Text2ImageRegion(0, 640, 768, 1408, guidance_scale=8, | |
prompt=prompt3), | |
], | |
num_inference_steps=50, | |
seed=seed, | |
)["sample"][0] | |
demo = gr.Interface( | |
fn=generate, | |
inputs=[ | |
gr.Textbox(lines=2, label="Left region prompt"), | |
gr.Textbox(lines=2, label="Center region prompt"), | |
gr.Textbox(lines=2, label="Right region prompt"), | |
gr.Number(value=12345, precision=0), | |
], | |
outputs="image", | |
examples=[ | |
[ | |
"A charming house in the countryside, by jakub rozalski, sunset lighting, elegant, highly detailed, smooth, sharp focus, artstation, stunning masterpiece", | |
"A dirt road in the countryside crossing pastures, by jakub rozalski, sunset lighting, elegant, highly detailed, smooth, sharp focus, artstation, stunning masterpiece", | |
"An old and rusty giant robot lying on a dirt road, by jakub rozalski, dark sunset lighting, elegant, highly detailed, smooth, sharp focus, artstation, stunning masterpiece", | |
7178915308 | |
], | |
], | |
) | |
demo.launch(server_name="0.0.0.0") |