reiirene commited on
Commit
3a31535
·
verified ·
1 Parent(s): a313f39

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import DiffusionPipeline
3
+ import gradio as gr
4
+
5
+ multi_view_diffusion_pipeline = DiffusionPipeline.from_pretrained(
6
+ "reiirene/multi-view-diffusion",
7
+ custom_pipeline="reiirene/multi-view-diffusion",
8
+ torch_dtype=torch.float16,
9
+ trust_remote_code=True,
10
+ ).to("cuda")
11
+
12
+ def run(image):
13
+ image = np.array(image, dtype=np.float32) / 255.0
14
+ images = multi_view_diffusion_pipeline("", image, guidance_scale=5, num_inference_steps=30, elevation=0)
15
+
16
+ images = [Image.fromarray((img * 255).astype("uint8")) for img in images]
17
+
18
+ width, height = images[0].size
19
+ grid_img = Image.new("RGB", (2 * width, 2 * height))
20
+
21
+ grid_img.paste(images[0], (0, 0))
22
+ grid_img.paste(images[1], (width, 0))
23
+ grid_img.paste(images[2], (0, height))
24
+ grid_img.paste(images[3], (width, height))
25
+
26
+ return grid_img
27
+
28
+ demo = gr.Interface(fn=run, inputs="image", outputs="image")
29
+ demo.launch(debug=True)