Spaces:
Runtime error
Runtime error
File size: 1,967 Bytes
e682b4a bce6870 e682b4a 6320655 e682b4a 6320655 |
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
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, use_auth_token=True).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") |