Spaces:
Sleeping
Sleeping
File size: 946 Bytes
347fd66 4ddb8f6 820b693 4ddb8f6 820b693 347fd66 |
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 |
import gradio as gr
import torch
from PIL import Image
from diffusers import DiffusionPipeline
import numpy as np
multi_view_diffusion_pipeline = DiffusionPipeline.from_pretrained(
"2gnak/multi-view-diffusion-demo",
custom_pipeline="dylanebert/multi-view-diffusion",
torch_dtype=torch.float16,
trust_remote_code=True,
).to("cpu")
def run(image):
image = np.array(image, dtype=np.float32) / 255.0
images = multi_view_diffusion_pipeline("", image, guidance_scale=5, num_inference_steps=30, elevation=0)
images = [Image.fromarray((img * 255).astype("uint8")) for img in images]
width, height = images[0].size
grid_img = Image.new("RGB", (2 * width, 2 * height))
grid_img.paste(images[0], (0, 0))
grid_img.paste(images[1], (width, 0))
grid_img.paste(images[2], (0, height))
grid_img.paste(images[3], (width, height))
return grid_img
demo = gr.Interface(fn=run, inputs="image", outputs="image")
demo.launch() |