albarji commited on
Commit
e682b4a
1 Parent(s): c2cf956

First version of app

Browse files
Files changed (1) hide show
  1. app.py +38 -0
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from diffusers import LMSDiscreteScheduler
4
+ from mixdiff import StableDiffusionCanvasPipeline, Text2ImageRegion
5
+
6
+ # Creater scheduler and model (similar to StableDiffusionPipeline)
7
+ scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000)
8
+ pipeline = StableDiffusionCanvasPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", scheduler=scheduler, use_auth_token=True).to("cuda:0")
9
+
10
+ def generate(prompt1, prompt2, prompt3, seed)
11
+ """Mixture of Diffusers generation"""
12
+ return pipeline(
13
+ canvas_height=640,
14
+ canvas_width=1408,
15
+ regions=[
16
+ Text2ImageRegion(0, 640, 0, 640, guidance_scale=8,
17
+ prompt=prompt1),
18
+ Text2ImageRegion(0, 640, 384, 1024, guidance_scale=8,
19
+ prompt=prompt2),
20
+ Text2ImageRegion(0, 640, 768, 1408, guidance_scale=8,
21
+ prompt=prompt3),
22
+ ],
23
+ num_inference_steps=50,
24
+ seed=seed,
25
+ )["sample"][0]
26
+
27
+
28
+ demo = gr.Interface(
29
+ fn=generate,
30
+ inputs=[
31
+ gr.Textbox(lines=2, placeholder="Left prompt"),
32
+ gr.Textbox(lines=2, placeholder="Center prompt"),
33
+ gr.Textbox(lines=2, placeholder="Right prompt"),
34
+ gr.Textbox(lines=1, placeholder="Random Seed"),
35
+ ]
36
+ outputs="image"
37
+ )
38
+ demo.launch()