SumantBobade commited on
Commit
b562890
·
verified ·
1 Parent(s): 222fcc3

Update app.py

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