image2mesh / app.py
dylanebert's picture
dylanebert HF staff
initial commit
d9905a4
raw
history blame
1.02 kB
import shlex
import subprocess
import gradio as gr
import numpy as np
import torch
from diffusers import DiffusionPipeline
subprocess.run(
shlex.split(
"pip install https://huggingface.co/spaces/dylanebert/LGM-mini/resolve/main/wheel/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl"
)
)
pipeline = DiffusionPipeline.from_pretrained(
"dylanebert/LGM-full",
custom_pipeline="dylanebert/LGM-full",
torch_dtype=torch.float16,
trust_remote_code=True,
).to("cuda")
def run(image):
input_image = np.array(image, dtype=np.float32) / 255.0
splat = pipeline(
"", input_image, guidance_scale=5, num_inference_steps=30, elevation=0
)
splat_file = "/tmp/output.ply"
pipeline.save_ply(splat, splat_file)
return splat_file
demo = gr.Interface(
fn=run,
inputs="image",
outputs=gr.Model3D(),
examples=[
"https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_cat_statue.jpg"
],
)
demo.queue().launch()