vulture990 commited on
Commit
48db36e
Β·
verified Β·
1 Parent(s): d0bc4fb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import shlex
2
+ import subprocess
3
+
4
+ import gradio as gr
5
+ import numpy as np
6
+ import spaces
7
+ import torch
8
+ from diffusers import DiffusionPipeline
9
+
10
+ subprocess.run(
11
+ shlex.split(
12
+ "pip install https://huggingface.co/spaces/dylanebert/LGM-mini/resolve/main/wheel/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl"
13
+ )
14
+ )
15
+
16
+ pipeline = DiffusionPipeline.from_pretrained(
17
+ "vulture990/2D-3D",
18
+ custom_pipeline="vulture990/2D-3D",
19
+ torch_dtype=torch.float16,
20
+ trust_remote_code=True,
21
+ ).to("cuda")
22
+
23
+
24
+ @spaces.GPU
25
+ def run(image):
26
+ input_image = np.array(image, dtype=np.float32) / 255.0
27
+ splat = pipeline(
28
+ "", input_image, guidance_scale=5, num_inference_steps=30, elevation=0
29
+ )
30
+ splat_file = "/tmp/output.ply"
31
+ pipeline.save_ply(splat, splat_file)
32
+ return splat_file
33
+
34
+
35
+ demo = gr.Interface(
36
+ fn=run,
37
+ title="LGM Tiny",
38
+ description="An extremely simplified version of [LGM](https://huggingface.co/ashawkey/LGM). Intended as resource for the [ML for 3D Course](https://huggingface.co/learn/ml-for-3d-course/unit0/introduction).",
39
+ inputs="image",
40
+ outputs=gr.Model3D(),
41
+ examples=[
42
+ # "https://huggingface.co/datasets/dylanebert/iso3d/resolve/main/jpg@512/a_cat_statue.jpg"
43
+ "https://ibb.co/GTGc7X1",
44
+ "https://ibb.co/k5vRx9J",
45
+ "https://ibb.co/8YsHPZp",
46
+ "https://ibb.co/n0g9V89"
47
+ ],
48
+ cache_examples=True,
49
+ allow_duplication=True,
50
+ )
51
+ demo.queue().launch()