Akash887 commited on
Commit
624f7f6
·
verified ·
1 Parent(s): e12e3ae

Update app.py

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