leonel1122 chaoxu commited on
Commit
948f12c
·
0 Parent(s):

Duplicate from One-2-3-45/One-2-3-45

Browse files

Co-authored-by: Chao Xu <[email protected]>

Files changed (40) hide show
  1. .gitattributes +36 -0
  2. .gitignore +4 -0
  3. README.md +30 -0
  4. app.py +671 -0
  5. demo_examples/00_zero123_lysol.png +3 -0
  6. demo_examples/01_wild_hydrant.png +3 -0
  7. demo_examples/02_zero123_spyro.png +3 -0
  8. demo_examples/03_wild2_pineapple_bottle.png +3 -0
  9. demo_examples/04_unsplash_broccoli.png +3 -0
  10. demo_examples/05_objaverse_backpack.png +3 -0
  11. demo_examples/06_unsplash_chocolatecake.png +3 -0
  12. demo_examples/07_unsplash_stool2.png +3 -0
  13. demo_examples/08_dalle_icecream.png +3 -0
  14. demo_examples/09_unsplash_bigmac.png +3 -0
  15. demo_examples/10_dalle3_blueberryicecream2.png +3 -0
  16. demo_examples/11_GSO_Crosley_Alarm_Clock_Vintage_Metal.png +3 -0
  17. demo_examples/12_realfusion_cactus_1.png +3 -0
  18. demo_examples/13_realfusion_cherry_1.png +3 -0
  19. demo_examples/14_dalle_cowbear.png +3 -0
  20. demo_examples/15_dalle3_gramophone1.png +3 -0
  21. demo_examples/16_dalle3_mushroom2.png +3 -0
  22. demo_examples/17_dalle3_rockingchair1.png +3 -0
  23. demo_examples/18_unsplash_mario.png +3 -0
  24. demo_examples/19_dalle3_stump1.png +3 -0
  25. demo_examples/20_objaverse_stool.png +3 -0
  26. demo_examples/21_objaverse_barrel.png +3 -0
  27. demo_examples/22_unsplash_boxtoy.png +3 -0
  28. demo_examples/23_objaverse_tank.png +3 -0
  29. demo_examples/24_wild2_yellow_duck.png +3 -0
  30. demo_examples/25_unsplash_teapot.png +3 -0
  31. demo_examples/26_unsplash_strawberrycake.png +3 -0
  32. demo_examples/27_objaverse_robocat.png +3 -0
  33. demo_examples/28_wild_goose_chef.png +3 -0
  34. demo_examples/29_wild_peroxide.png +3 -0
  35. demo_tmp/.gitignore +1 -0
  36. demo_tmp/.gitkeep +0 -0
  37. instructions_12345.md +10 -0
  38. packages.txt +1 -0
  39. pre-requirements.txt +74 -0
  40. requirements.txt +12 -0
.gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.png filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ weights/
2
+ data/
3
+ *.ipynb
4
+ demo_examples_*
README.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: One-2-3-45
3
+ emoji: 📸🚀🌟
4
+ colorFrom: red
5
+ colorTo: yellow
6
+ sdk: gradio
7
+ sdk_version: 3.36.1
8
+ app_file: app.py
9
+ pinned: true
10
+ license: mit
11
+ duplicated_from: One-2-3-45/One-2-3-45
12
+ ---
13
+
14
+ # One-2-3-45: Any Single Image to 3D Mesh in 45 Seconds without Per-Shape Optimization
15
+
16
+ Paper: https://arxiv.org/abs/2306.16928
17
+ Code: https://github.com/One-2-3-45/One-2-3-45
18
+
19
+ ## BibTeX
20
+
21
+ ```bibtex
22
+ @misc{liu2023one2345,
23
+ title={One-2-3-45: Any Single Image to 3D Mesh in 45 Seconds without Per-Shape Optimization},
24
+ author={Minghua Liu and Chao Xu and Haian Jin and Linghao Chen and Mukund Varma T and Zexiang Xu and Hao Su},
25
+ year={2023},
26
+ eprint={2306.16928},
27
+ archivePrefix={arXiv},
28
+ primaryClass={cs.CV}
29
+ }
30
+ ```
app.py ADDED
@@ -0,0 +1,671 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, sys
2
+ from huggingface_hub import snapshot_download
3
+
4
+ is_local_run = False
5
+
6
+ code_dir = snapshot_download("One-2-3-45/code", token=os.environ['TOKEN']) if not is_local_run else "../code"
7
+
8
+ sys.path.append(code_dir)
9
+
10
+ elev_est_dir = os.path.join(code_dir, "one2345_elev_est/")
11
+ sys.path.append(elev_est_dir)
12
+
13
+ if not is_local_run:
14
+ import subprocess
15
+ subprocess.run(["sh", os.path.join(elev_est_dir, "install.sh")], cwd=elev_est_dir)
16
+ # export TORCH_CUDA_ARCH_LIST="7.0;7.2;8.0;8.6"
17
+ # export IABN_FORCE_CUDA=1
18
+ os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
19
+ os.environ["IABN_FORCE_CUDA"] = "1"
20
+ os.environ["FORCE_CUDA"] = "1"
21
+ subprocess.run(["pip", "install", "inplace_abn"])
22
+ # FORCE_CUDA=1 pip install --no-cache-dir git+https://github.com/mit-han-lab/[email protected]
23
+ subprocess.run(["pip", "install", "--no-cache-dir", "git+https://github.com/mit-han-lab/[email protected]"])
24
+
25
+ import inspect
26
+ import shutil
27
+ import torch
28
+ import fire
29
+ import gradio as gr
30
+ import numpy as np
31
+ import plotly.graph_objects as go
32
+ from functools import partial
33
+
34
+ from lovely_numpy import lo
35
+ import cv2
36
+ from PIL import Image
37
+ import trimesh
38
+ import tempfile
39
+ from zero123_utils import init_model, predict_stage1_gradio, zero123_infer
40
+ from sam_utils import sam_init, sam_out_nosave
41
+ from utils import image_preprocess_nosave, gen_poses
42
+ from one2345_elev_est.tools.estimate_wild_imgs import estimate_elev
43
+ from rembg import remove
44
+
45
+ _GPU_INDEX = 0
46
+
47
+ _TITLE = '''One-2-3-45: Any Single Image to 3D Mesh in 45 Seconds without Per-Shape Optimization'''
48
+
49
+ _DESCRIPTION = '''
50
+ We reconstruct a 3D textured mesh from a single image by initially predicting multi-view images and then lifting them to 3D.
51
+ [<a href="http://One-2-3-45.com">Project</a>]
52
+ [<a href="https://github.com/One-2-3-45/One-2-3-45">GitHub</a>]
53
+ '''
54
+ # _HTML = '''<p>[<a href="https://github.com/One-2-3-45/One-2-3-45">GitHub</a>]
55
+ # <object alt="GitHub Repo stars" src="https://img.shields.io/github/stars/One-2-3-45/One-2-3-45?style=social&link=https%3A%2F%2Fgithub.com%2FOne-2-3-45%2FOne-2-3-45">
56
+ # </p>'''
57
+ # _HTML = '<script async defer src="https://buttons.github.io/buttons.js"></script> <a class="github-button" href="https://github.com/One-2-3-45/One-2-3-45" data-icon="octicon-star" data-show-count="true" aria-label="Star One-2-3-45/One-2-3-45 on GitHub">Star</a><p>'
58
+
59
+ _USER_GUIDE = "Please upload an image in the block above (or choose an example above) and click **Run Generation**."
60
+ _BBOX_1 = "Predicting bounding box for the input image..."
61
+ _BBOX_2 = "Bounding box adjusted. Continue adjusting or **Run Generation**."
62
+ _BBOX_3 = "Bounding box predicted. Adjust it using sliders or **Run Generation**."
63
+ _SAM = "Preprocessing the input image... (safety check, SAM segmentation, *etc*.)"
64
+ _GEN_1 = "Predicting multi-view images... (may take \~13 seconds) <br> Images will be shown in the bottom right blocks."
65
+ _GEN_2 = "Predicting nearby views and generating mesh... (may take \~35 seconds) <br> Mesh will be shown on the right."
66
+ _DONE = "Done! Mesh is shown on the right. <br> If it is not satisfactory, please select **Retry view** checkboxes for inaccurate views and click **Regenerate selected view(s)** at the bottom."
67
+ _REGEN_1 = "Selected view(s) are regenerated. You can click **Regenerate nearby views and mesh**. <br> Alternatively, if the regenerated view(s) are still not satisfactory, you can repeat the previous step (select the view and regenerate)."
68
+ _REGEN_2 = "Regeneration done. Mesh is shown on the right."
69
+
70
+
71
+ def calc_cam_cone_pts_3d(polar_deg, azimuth_deg, radius_m, fov_deg):
72
+ '''
73
+ :param polar_deg (float).
74
+ :param azimuth_deg (float).
75
+ :param radius_m (float).
76
+ :param fov_deg (float).
77
+ :return (5, 3) array of float with (x, y, z).
78
+ '''
79
+ polar_rad = np.deg2rad(polar_deg)
80
+ azimuth_rad = np.deg2rad(azimuth_deg)
81
+ fov_rad = np.deg2rad(fov_deg)
82
+ polar_rad = -polar_rad # NOTE: Inverse of how used_x relates to x.
83
+
84
+ # Camera pose center:
85
+ cam_x = radius_m * np.cos(azimuth_rad) * np.cos(polar_rad)
86
+ cam_y = radius_m * np.sin(azimuth_rad) * np.cos(polar_rad)
87
+ cam_z = radius_m * np.sin(polar_rad)
88
+
89
+ # Obtain four corners of camera frustum, assuming it is looking at origin.
90
+ # First, obtain camera extrinsics (rotation matrix only):
91
+ camera_R = np.array([[np.cos(azimuth_rad) * np.cos(polar_rad),
92
+ -np.sin(azimuth_rad),
93
+ -np.cos(azimuth_rad) * np.sin(polar_rad)],
94
+ [np.sin(azimuth_rad) * np.cos(polar_rad),
95
+ np.cos(azimuth_rad),
96
+ -np.sin(azimuth_rad) * np.sin(polar_rad)],
97
+ [np.sin(polar_rad),
98
+ 0.0,
99
+ np.cos(polar_rad)]])
100
+
101
+ # Multiply by corners in camera space to obtain go to space:
102
+ corn1 = [-1.0, np.tan(fov_rad / 2.0), np.tan(fov_rad / 2.0)]
103
+ corn2 = [-1.0, -np.tan(fov_rad / 2.0), np.tan(fov_rad / 2.0)]
104
+ corn3 = [-1.0, -np.tan(fov_rad / 2.0), -np.tan(fov_rad / 2.0)]
105
+ corn4 = [-1.0, np.tan(fov_rad / 2.0), -np.tan(fov_rad / 2.0)]
106
+ corn1 = np.dot(camera_R, corn1)
107
+ corn2 = np.dot(camera_R, corn2)
108
+ corn3 = np.dot(camera_R, corn3)
109
+ corn4 = np.dot(camera_R, corn4)
110
+
111
+ # Now attach as offset to actual 3D camera position:
112
+ corn1 = np.array(corn1) / np.linalg.norm(corn1, ord=2)
113
+ corn_x1 = cam_x + corn1[0]
114
+ corn_y1 = cam_y + corn1[1]
115
+ corn_z1 = cam_z + corn1[2]
116
+ corn2 = np.array(corn2) / np.linalg.norm(corn2, ord=2)
117
+ corn_x2 = cam_x + corn2[0]
118
+ corn_y2 = cam_y + corn2[1]
119
+ corn_z2 = cam_z + corn2[2]
120
+ corn3 = np.array(corn3) / np.linalg.norm(corn3, ord=2)
121
+ corn_x3 = cam_x + corn3[0]
122
+ corn_y3 = cam_y + corn3[1]
123
+ corn_z3 = cam_z + corn3[2]
124
+ corn4 = np.array(corn4) / np.linalg.norm(corn4, ord=2)
125
+ corn_x4 = cam_x + corn4[0]
126
+ corn_y4 = cam_y + corn4[1]
127
+ corn_z4 = cam_z + corn4[2]
128
+
129
+ xs = [cam_x, corn_x1, corn_x2, corn_x3, corn_x4]
130
+ ys = [cam_y, corn_y1, corn_y2, corn_y3, corn_y4]
131
+ zs = [cam_z, corn_z1, corn_z2, corn_z3, corn_z4]
132
+
133
+ return np.array([xs, ys, zs]).T
134
+
135
+ class CameraVisualizer:
136
+ def __init__(self, gradio_plot):
137
+ self._gradio_plot = gradio_plot
138
+ self._fig = None
139
+ self._polar = 0.0
140
+ self._azimuth = 0.0
141
+ self._radius = 0.0
142
+ self._raw_image = None
143
+ self._8bit_image = None
144
+ self._image_colorscale = None
145
+
146
+ def encode_image(self, raw_image, elev=90):
147
+ '''
148
+ :param raw_image (H, W, 3) array of uint8 in [0, 255].
149
+ '''
150
+ # https://stackoverflow.com/questions/60685749/python-plotly-how-to-add-an-image-to-a-3d-scatter-plot
151
+
152
+ dum_img = Image.fromarray(np.ones((3, 3, 3), dtype='uint8')).convert('P', palette='WEB')
153
+ idx_to_color = np.array(dum_img.getpalette()).reshape((-1, 3))
154
+
155
+ self._raw_image = raw_image
156
+ self._8bit_image = Image.fromarray(raw_image).convert('P', palette='WEB', dither=None)
157
+ # self._8bit_image = Image.fromarray(raw_image.clip(0, 254)).convert(
158
+ # 'P', palette='WEB', dither=None)
159
+ self._image_colorscale = [
160
+ [i / 255.0, 'rgb({}, {}, {})'.format(*rgb)] for i, rgb in enumerate(idx_to_color)]
161
+ self._elev = elev
162
+ # return self.update_figure()
163
+
164
+ def update_figure(self):
165
+ fig = go.Figure()
166
+
167
+ if self._raw_image is not None:
168
+ (H, W, C) = self._raw_image.shape
169
+
170
+ x = np.zeros((H, W))
171
+ (y, z) = np.meshgrid(np.linspace(-1.0, 1.0, W), np.linspace(1.0, -1.0, H) * H / W)
172
+
173
+ angle_deg = self._elev-90
174
+ angle = np.radians(90-self._elev)
175
+ rotation_matrix = np.array([
176
+ [np.cos(angle), 0, np.sin(angle)],
177
+ [0, 1, 0],
178
+ [-np.sin(angle), 0, np.cos(angle)]
179
+ ])
180
+ # Assuming x, y, z are the original 3D coordinates of the image
181
+ coordinates = np.stack((x, y, z), axis=-1) # Combine x, y, z into a single array
182
+ # Apply the rotation matrix
183
+ rotated_coordinates = np.matmul(coordinates, rotation_matrix)
184
+ # Extract the new x, y, z coordinates from the rotated coordinates
185
+ x, y, z = rotated_coordinates[..., 0], rotated_coordinates[..., 1], rotated_coordinates[..., 2]
186
+
187
+
188
+ print('x:', lo(x))
189
+ print('y:', lo(y))
190
+ print('z:', lo(z))
191
+
192
+ fig.add_trace(go.Surface(
193
+ x=x, y=y, z=z,
194
+ surfacecolor=self._8bit_image,
195
+ cmin=0,
196
+ cmax=255,
197
+ colorscale=self._image_colorscale,
198
+ showscale=False,
199
+ lighting_diffuse=1.0,
200
+ lighting_ambient=1.0,
201
+ lighting_fresnel=1.0,
202
+ lighting_roughness=1.0,
203
+ lighting_specular=0.3))
204
+
205
+ scene_bounds = 3.5
206
+ base_radius = 2.5
207
+ zoom_scale = 1.5 # Note that input radius offset is in [-0.5, 0.5].
208
+ fov_deg = 50.0
209
+ edges = [(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (2, 3), (3, 4), (4, 1)]
210
+
211
+ input_cone = calc_cam_cone_pts_3d(
212
+ angle_deg, 0.0, base_radius, fov_deg) # (5, 3).
213
+ output_cone = calc_cam_cone_pts_3d(
214
+ self._polar, self._azimuth, base_radius + self._radius * zoom_scale, fov_deg) # (5, 3).
215
+ output_cones = []
216
+ for i in range(1,4):
217
+ output_cones.append(calc_cam_cone_pts_3d(
218
+ angle_deg, i*90, base_radius + self._radius * zoom_scale, fov_deg))
219
+ delta_deg = 30 if angle_deg <= -15 else -30
220
+ for i in range(4):
221
+ output_cones.append(calc_cam_cone_pts_3d(
222
+ angle_deg+delta_deg, 30+i*90, base_radius + self._radius * zoom_scale, fov_deg))
223
+
224
+ cones = [(input_cone, 'rgb(174, 54, 75)', 'Input view (Predicted view 1)')]
225
+ for i in range(len(output_cones)):
226
+ cones.append((output_cones[i], 'rgb(32, 77, 125)', f'Predicted view {i+2}'))
227
+
228
+ for idx, (cone, clr, legend) in enumerate(cones):
229
+
230
+ for (i, edge) in enumerate(edges):
231
+ (x1, x2) = (cone[edge[0], 0], cone[edge[1], 0])
232
+ (y1, y2) = (cone[edge[0], 1], cone[edge[1], 1])
233
+ (z1, z2) = (cone[edge[0], 2], cone[edge[1], 2])
234
+ fig.add_trace(go.Scatter3d(
235
+ x=[x1, x2], y=[y1, y2], z=[z1, z2], mode='lines',
236
+ line=dict(color=clr, width=3),
237
+ name=legend, showlegend=(i == 1) and (idx <= 1)))
238
+
239
+ # Add label.
240
+ if cone[0, 2] <= base_radius / 2.0:
241
+ fig.add_trace(go.Scatter3d(
242
+ x=[cone[0, 0]], y=[cone[0, 1]], z=[cone[0, 2] - 0.05], showlegend=False,
243
+ mode='text', text=legend, textposition='bottom center'))
244
+ else:
245
+ fig.add_trace(go.Scatter3d(
246
+ x=[cone[0, 0]], y=[cone[0, 1]], z=[cone[0, 2] + 0.05], showlegend=False,
247
+ mode='text', text=legend, textposition='top center'))
248
+
249
+ # look at center of scene
250
+ fig.update_layout(
251
+ # width=640,
252
+ # height=480,
253
+ # height=400,
254
+ height=450,
255
+ autosize=True,
256
+ hovermode=False,
257
+ margin=go.layout.Margin(l=0, r=0, b=0, t=0),
258
+ showlegend=False,
259
+ legend=dict(
260
+ yanchor='bottom',
261
+ y=0.01,
262
+ xanchor='right',
263
+ x=0.99,
264
+ ),
265
+ scene=dict(
266
+ aspectmode='manual',
267
+ aspectratio=dict(x=1, y=1, z=1.0),
268
+ camera=dict(
269
+ eye=dict(x=base_radius - 1.6, y=0.0, z=0.6),
270
+ center=dict(x=0.0, y=0.0, z=0.0),
271
+ up=dict(x=0.0, y=0.0, z=1.0)),
272
+ xaxis_title='',
273
+ yaxis_title='',
274
+ zaxis_title='',
275
+ xaxis=dict(
276
+ range=[-scene_bounds, scene_bounds],
277
+ showticklabels=False,
278
+ showgrid=True,
279
+ zeroline=False,
280
+ showbackground=True,
281
+ showspikes=False,
282
+ showline=False,
283
+ ticks=''),
284
+ yaxis=dict(
285
+ range=[-scene_bounds, scene_bounds],
286
+ showticklabels=False,
287
+ showgrid=True,
288
+ zeroline=False,
289
+ showbackground=True,
290
+ showspikes=False,
291
+ showline=False,
292
+ ticks=''),
293
+ zaxis=dict(
294
+ range=[-scene_bounds, scene_bounds],
295
+ showticklabels=False,
296
+ showgrid=True,
297
+ zeroline=False,
298
+ showbackground=True,
299
+ showspikes=False,
300
+ showline=False,
301
+ ticks='')))
302
+
303
+ self._fig = fig
304
+ return fig
305
+
306
+
307
+ def stage1_run(models, device, cam_vis, tmp_dir,
308
+ input_im, scale, ddim_steps, elev=None, rerun_all=[],
309
+ *btn_retrys):
310
+ is_rerun = True if cam_vis is None else False
311
+ model = models['turncam'].half()
312
+
313
+ stage1_dir = os.path.join(tmp_dir, "stage1_8")
314
+ if not is_rerun:
315
+ os.makedirs(stage1_dir, exist_ok=True)
316
+ output_ims = predict_stage1_gradio(model, input_im, save_path=stage1_dir, adjust_set=list(range(4)), device=device, ddim_steps=ddim_steps, scale=scale)
317
+ stage2_steps = 50 # ddim_steps
318
+ zero123_infer(model, tmp_dir, indices=[0], device=device, ddim_steps=stage2_steps, scale=scale)
319
+ elev_output = estimate_elev(tmp_dir)
320
+ gen_poses(tmp_dir, elev_output)
321
+ show_in_im1 = np.asarray(input_im, dtype=np.uint8)
322
+ cam_vis.encode_image(show_in_im1, elev=elev_output)
323
+ new_fig = cam_vis.update_figure()
324
+
325
+ flag_lower_cam = elev_output <= 75
326
+ if flag_lower_cam:
327
+ output_ims_2 = predict_stage1_gradio(model, input_im, save_path=stage1_dir, adjust_set=list(range(4,8)), device=device, ddim_steps=ddim_steps, scale=scale)
328
+ else:
329
+ output_ims_2 = predict_stage1_gradio(model, input_im, save_path=stage1_dir, adjust_set=list(range(8,12)), device=device, ddim_steps=ddim_steps, scale=scale)
330
+ torch.cuda.empty_cache()
331
+ return (90-elev_output, new_fig, *output_ims, *output_ims_2)
332
+ else:
333
+ rerun_idx = [i for i in range(len(btn_retrys)) if btn_retrys[i]]
334
+ if 90-int(elev["label"]) > 75:
335
+ rerun_idx_in = [i if i < 4 else i+4 for i in rerun_idx]
336
+ else:
337
+ rerun_idx_in = rerun_idx
338
+ for idx in rerun_idx_in:
339
+ if idx not in rerun_all:
340
+ rerun_all.append(idx)
341
+ print("rerun_idx", rerun_all)
342
+ output_ims = predict_stage1_gradio(model, input_im, save_path=stage1_dir, adjust_set=rerun_idx_in, device=device, ddim_steps=ddim_steps, scale=scale)
343
+ outputs = [gr.update(visible=True)] * 8
344
+ for idx, view_idx in enumerate(rerun_idx):
345
+ outputs[view_idx] = output_ims[idx]
346
+ reset = [gr.update(value=False)] * 8
347
+ torch.cuda.empty_cache()
348
+ return (rerun_all, *reset, *outputs)
349
+
350
+ def stage2_run(models, device, tmp_dir,
351
+ elev, scale, is_glb=False, rerun_all=[], stage2_steps=50):
352
+ flag_lower_cam = 90-int(elev["label"]) <= 75
353
+ is_rerun = True if rerun_all else False
354
+ model = models['turncam'].half()
355
+ if not is_rerun:
356
+ if flag_lower_cam:
357
+ zero123_infer(model, tmp_dir, indices=list(range(1,8)), device=device, ddim_steps=stage2_steps, scale=scale)
358
+ else:
359
+ zero123_infer(model, tmp_dir, indices=list(range(1,4))+list(range(8,12)), device=device, ddim_steps=stage2_steps, scale=scale)
360
+ else:
361
+ print("rerun_idx", rerun_all)
362
+ zero123_infer(model, tmp_dir, indices=rerun_all, device=device, ddim_steps=stage2_steps, scale=scale)
363
+
364
+ dataset = tmp_dir
365
+ main_dir_path = os.path.dirname(os.path.abspath(
366
+ inspect.getfile(inspect.currentframe())))
367
+ torch.cuda.empty_cache()
368
+ os.chdir(os.path.join(code_dir, 'SparseNeuS_demo_v1/'))
369
+
370
+ bash_script = f'CUDA_VISIBLE_DEVICES={_GPU_INDEX} python exp_runner_generic_blender_val.py --specific_dataset_name {dataset} --mode export_mesh --conf confs/one2345_lod0_val_demo.conf --is_continue'
371
+ print(bash_script)
372
+ os.system(bash_script)
373
+ os.chdir(main_dir_path)
374
+
375
+ ply_path = os.path.join(tmp_dir, f"meshes_val_bg/lod0/mesh_00215000_gradio_lod0.ply")
376
+ mesh_ext = ".glb" if is_glb else ".obj"
377
+ mesh_path = os.path.join(tmp_dir, f"mesh{mesh_ext}")
378
+ # Read the textured mesh from .ply file
379
+ mesh = trimesh.load_mesh(ply_path)
380
+ axis = [1, 0, 0]
381
+ angle = np.radians(90)
382
+ rotation_matrix = trimesh.transformations.rotation_matrix(angle, axis)
383
+ mesh.apply_transform(rotation_matrix)
384
+ axis = [0, 0, 1]
385
+ angle = np.radians(180)
386
+ rotation_matrix = trimesh.transformations.rotation_matrix(angle, axis)
387
+ mesh.apply_transform(rotation_matrix)
388
+ # flip x
389
+ mesh.vertices[:, 0] = -mesh.vertices[:, 0]
390
+ mesh.faces = np.fliplr(mesh.faces)
391
+ # Export the mesh as .obj file with colors
392
+ if not is_glb:
393
+ mesh.export(mesh_path, file_type='obj', include_color=True)
394
+ else:
395
+ mesh.export(mesh_path, file_type='glb')
396
+ torch.cuda.empty_cache()
397
+
398
+ if not is_rerun:
399
+ return (mesh_path)
400
+ else:
401
+ return (mesh_path, [], gr.update(visible=False), gr.update(visible=False))
402
+
403
+ def nsfw_check(models, raw_im, device='cuda'):
404
+ safety_checker_input = models['clip_fe'](raw_im, return_tensors='pt').to(device)
405
+ (_, has_nsfw_concept) = models['nsfw'](
406
+ images=np.ones((1, 3)), clip_input=safety_checker_input.pixel_values)
407
+ print('has_nsfw_concept:', has_nsfw_concept)
408
+ del safety_checker_input
409
+ if np.any(has_nsfw_concept):
410
+ print('NSFW content detected.')
411
+ # Define the image size and background color
412
+ image_width = image_height = 256
413
+ background_color = (255, 255, 255) # White
414
+ # Create a blank image
415
+ image = Image.new("RGB", (image_width, image_height), background_color)
416
+ from PIL import ImageDraw
417
+ draw = ImageDraw.Draw(image)
418
+ text = "Potential NSFW content was detected."
419
+ text_color = (255, 0, 0)
420
+ text_position = (10, 123)
421
+ draw.text(text_position, text, fill=text_color)
422
+ text = "Please try again with a different image."
423
+ text_position = (10, 133)
424
+ draw.text(text_position, text, fill=text_color)
425
+ return image
426
+ else:
427
+ print('Safety check passed.')
428
+ return False
429
+
430
+ def preprocess_run(predictor, models, raw_im, preprocess, *bbox_sliders):
431
+ raw_im.thumbnail([512, 512], Image.Resampling.LANCZOS)
432
+ check_results = nsfw_check(models, raw_im, device=predictor.device)
433
+ if check_results:
434
+ return check_results
435
+ image_sam = sam_out_nosave(predictor, raw_im.convert("RGB"), *bbox_sliders)
436
+ input_256 = image_preprocess_nosave(image_sam, lower_contrast=preprocess, rescale=True)
437
+ torch.cuda.empty_cache()
438
+ return input_256
439
+
440
+ def on_coords_slider(image, x_min, y_min, x_max, y_max, color=(88, 191, 131, 255)):
441
+ """Draw a bounding box annotation for an image."""
442
+ print("on_coords_slider, drawing bbox...")
443
+ image.thumbnail([512, 512], Image.Resampling.LANCZOS)
444
+ image_size = image.size
445
+ if max(image_size) > 224:
446
+ image.thumbnail([224, 224], Image.Resampling.LANCZOS)
447
+ shrink_ratio = max(image.size) / max(image_size)
448
+ x_min = int(x_min * shrink_ratio)
449
+ y_min = int(y_min * shrink_ratio)
450
+ x_max = int(x_max * shrink_ratio)
451
+ y_max = int(y_max * shrink_ratio)
452
+ image = cv2.cvtColor(np.array(image), cv2.COLOR_RGBA2BGRA)
453
+ image = cv2.rectangle(image, (x_min, y_min), (x_max, y_max), color, int(max(max(image.shape) / 400*2, 2)))
454
+ return cv2.cvtColor(image, cv2.COLOR_BGRA2RGBA) # image[:, :, ::-1]
455
+
456
+ def init_bbox(image):
457
+ image.thumbnail([512, 512], Image.Resampling.LANCZOS)
458
+ width, height = image.size
459
+ image_rem = image.convert('RGBA')
460
+ image_nobg = remove(image_rem, alpha_matting=True)
461
+ arr = np.asarray(image_nobg)[:,:,-1]
462
+ x_nonzero = np.nonzero(arr.sum(axis=0))
463
+ y_nonzero = np.nonzero(arr.sum(axis=1))
464
+ x_min = int(x_nonzero[0].min())
465
+ y_min = int(y_nonzero[0].min())
466
+ x_max = int(x_nonzero[0].max())
467
+ y_max = int(y_nonzero[0].max())
468
+ image_mini = image.copy()
469
+ image_mini.thumbnail([224, 224], Image.Resampling.LANCZOS)
470
+ shrink_ratio = max(image_mini.size) / max(width, height)
471
+ x_min_shrink = int(x_min * shrink_ratio)
472
+ y_min_shrink = int(y_min * shrink_ratio)
473
+ x_max_shrink = int(x_max * shrink_ratio)
474
+ y_max_shrink = int(y_max * shrink_ratio)
475
+
476
+ return [on_coords_slider(image_mini, x_min_shrink, y_min_shrink, x_max_shrink, y_max_shrink),
477
+ gr.update(value=x_min, maximum=width),
478
+ gr.update(value=y_min, maximum=height),
479
+ gr.update(value=x_max, maximum=width),
480
+ gr.update(value=y_max, maximum=height)]
481
+
482
+
483
+ def run_demo(
484
+ device_idx=_GPU_INDEX,
485
+ ckpt='zero123-xl.ckpt'):
486
+
487
+ device = f"cuda:{device_idx}" if torch.cuda.is_available() else "cpu"
488
+ models = init_model(device, os.path.join(code_dir, ckpt))
489
+ # model = models['turncam']
490
+ # sampler = DDIMSampler(model)
491
+
492
+ # init sam model
493
+ predictor = sam_init(device_idx)
494
+
495
+ with open('instructions_12345.md', 'r') as f:
496
+ article = f.read()
497
+
498
+ # NOTE: Examples must match inputs
499
+ example_folder = os.path.join(os.path.dirname(__file__), 'demo_examples')
500
+ example_fns = os.listdir(example_folder)
501
+ example_fns.sort()
502
+ examples_full = [os.path.join(example_folder, x) for x in example_fns if x.endswith('.png')]
503
+
504
+ # Compose demo layout & data flow.
505
+ css = "#model-3d-out {height: 400px;} #plot-out {height: 450px;}"
506
+ with gr.Blocks(title=_TITLE, css=css) as demo:
507
+ gr.Markdown('# ' + _TITLE)
508
+ gr.Markdown(_DESCRIPTION)
509
+ # gr.HTML(_HTML)
510
+
511
+ with gr.Row(variant='panel'):
512
+ with gr.Column(scale=1.2):
513
+ image_block = gr.Image(type='pil', image_mode='RGBA', label='Input image', tool=None).style(height=290)
514
+
515
+ gr.Examples(
516
+ examples=examples_full, # NOTE: elements must match inputs list!
517
+ inputs=[image_block],
518
+ outputs=[image_block],
519
+ cache_examples=False,
520
+ label='Examples (click one of the images below to start)',
521
+ examples_per_page=40
522
+ )
523
+ preprocess_chk = gr.Checkbox(
524
+ False, label='Reduce image contrast (mitigate shadows on the backside)')
525
+ with gr.Accordion('Advanced options', open=False):
526
+ scale_slider = gr.Slider(0, 30, value=3, step=1,
527
+ label='Diffusion guidance scale')
528
+ steps_slider = gr.Slider(5, 200, value=75, step=5,
529
+ label='Number of diffusion inference steps')
530
+ glb_chk = gr.Checkbox(
531
+ False, label='Export the mesh in .glb format')
532
+
533
+ run_btn = gr.Button('Run Generation', variant='primary', interactive=False)
534
+ guide_text = gr.Markdown(_USER_GUIDE, visible=True)
535
+
536
+ with gr.Column(scale=.8):
537
+ with gr.Row():
538
+ bbox_block = gr.Image(type='pil', label="Bounding box", interactive=False).style(height=290)
539
+ sam_block = gr.Image(type='pil', label="SAM output", interactive=False)
540
+ max_width = max_height = 256
541
+ with gr.Row():
542
+ x_min_slider = gr.Slider(label="X min", interactive=True, value=0, minimum=0, maximum=max_width, step=1)
543
+ y_min_slider = gr.Slider(label="Y min", interactive=True, value=0, minimum=0, maximum=max_height, step=1)
544
+ with gr.Row():
545
+ x_max_slider = gr.Slider(label="X max", interactive=True, value=max_width, minimum=0, maximum=max_width, step=1)
546
+ y_max_slider = gr.Slider(label="Y max", interactive=True, value=max_height, minimum=0, maximum=max_height, step=1)
547
+ bbox_sliders = [x_min_slider, y_min_slider, x_max_slider, y_max_slider]
548
+
549
+ mesh_output = gr.Model3D(clear_color=[0.0, 0.0, 0.0, 0.0], label="One-2-3-45's Textured Mesh", elem_id="model-3d-out")
550
+
551
+ with gr.Row(variant='panel'):
552
+ with gr.Column(scale=0.85):
553
+ elev_output = gr.Label(label='Estimated elevation (degree, w.r.t. the horizontal plane)')
554
+ vis_output = gr.Plot(label='Camera poses of the input view (red) and predicted views (blue)', elem_id="plot-out")
555
+
556
+ with gr.Column(scale=1.15):
557
+ gr.Markdown('Predicted multi-view images')
558
+ with gr.Row():
559
+ view_1 = gr.Image(interactive=False, show_label=False).style(height=200)
560
+ view_2 = gr.Image(interactive=False, show_label=False).style(height=200)
561
+ view_3 = gr.Image(interactive=False, show_label=False).style(height=200)
562
+ view_4 = gr.Image(interactive=False, show_label=False).style(height=200)
563
+ with gr.Row():
564
+ btn_retry_1 = gr.Checkbox(label='Retry view 1')
565
+ btn_retry_2 = gr.Checkbox(label='Retry view 2')
566
+ btn_retry_3 = gr.Checkbox(label='Retry view 3')
567
+ btn_retry_4 = gr.Checkbox(label='Retry view 4')
568
+ with gr.Row():
569
+ view_5 = gr.Image(interactive=False, show_label=False).style(height=200)
570
+ view_6 = gr.Image(interactive=False, show_label=False).style(height=200)
571
+ view_7 = gr.Image(interactive=False, show_label=False).style(height=200)
572
+ view_8 = gr.Image(interactive=False, show_label=False).style(height=200)
573
+ with gr.Row():
574
+ btn_retry_5 = gr.Checkbox(label='Retry view 5')
575
+ btn_retry_6 = gr.Checkbox(label='Retry view 6')
576
+ btn_retry_7 = gr.Checkbox(label='Retry view 7')
577
+ btn_retry_8 = gr.Checkbox(label='Retry view 8')
578
+ with gr.Row():
579
+ regen_view_btn = gr.Button('1. Regenerate selected view(s)', variant='secondary', visible=False)
580
+ regen_mesh_btn = gr.Button('2. Regenerate nearby views and mesh', variant='secondary', visible=False)
581
+
582
+ update_guide = lambda GUIDE_TEXT: gr.update(value=GUIDE_TEXT)
583
+
584
+ views = [view_1, view_2, view_3, view_4, view_5, view_6, view_7, view_8]
585
+ btn_retrys = [btn_retry_1, btn_retry_2, btn_retry_3, btn_retry_4, btn_retry_5, btn_retry_6, btn_retry_7, btn_retry_8]
586
+
587
+ rerun_idx = gr.State([])
588
+ tmp_dir = gr.State('./demo_tmp/tmp_dir')
589
+
590
+ def refresh(tmp_dir):
591
+ if os.path.exists(tmp_dir):
592
+ shutil.rmtree(tmp_dir)
593
+ tmp_dir = tempfile.TemporaryDirectory(dir=os.path.join(os.path.dirname(__file__), 'demo_tmp'))
594
+ print("create tmp_dir", tmp_dir.name)
595
+ clear = [gr.update(value=[])] + [None] * 5 + [gr.update(visible=False)] * 2 + [None] * 8 + [gr.update(value=False)] * 8
596
+ return (tmp_dir.name, *clear)
597
+
598
+ placeholder = gr.Image(visible=False)
599
+ tmp_func = lambda x: False if not x else gr.update(visible=False)
600
+ disable_func = lambda x: gr.update(interactive=False)
601
+ enable_func = lambda x: gr.update(interactive=True)
602
+ image_block.change(disable_func, inputs=run_btn, outputs=run_btn, queue=False
603
+ ).success(fn=refresh,
604
+ inputs=[tmp_dir],
605
+ outputs=[tmp_dir, rerun_idx, bbox_block, sam_block, elev_output, vis_output, mesh_output, regen_view_btn, regen_mesh_btn, *views, *btn_retrys],
606
+ queue=False
607
+ ).success(fn=tmp_func, inputs=[image_block], outputs=[placeholder], queue=False
608
+ ).success(fn=partial(update_guide, _BBOX_1), outputs=[guide_text], queue=False
609
+ ).success(fn=init_bbox,
610
+ inputs=[image_block],
611
+ outputs=[bbox_block, *bbox_sliders], queue=False
612
+ ).success(fn=partial(update_guide, _BBOX_3), outputs=[guide_text], queue=False
613
+ ).success(enable_func, inputs=run_btn, outputs=run_btn, queue=False)
614
+
615
+
616
+ for bbox_slider in bbox_sliders:
617
+ bbox_slider.release(fn=on_coords_slider,
618
+ inputs=[image_block, *bbox_sliders],
619
+ outputs=[bbox_block],
620
+ queue=False
621
+ ).success(fn=partial(update_guide, _BBOX_2), outputs=[guide_text], queue=False)
622
+
623
+ cam_vis = CameraVisualizer(vis_output)
624
+
625
+ gr.Markdown(article)
626
+
627
+ # Define the function to be called when any of the btn_retry buttons are clicked
628
+ def on_retry_button_click(*btn_retrys):
629
+ any_checked = any([btn_retry for btn_retry in btn_retrys])
630
+ print('any_checked:', any_checked, [btn_retry for btn_retry in btn_retrys])
631
+ if any_checked:
632
+ return (gr.update(visible=True), gr.update(visible=True))
633
+ else:
634
+ return (gr.update(), gr.update())
635
+ # make regen_btn visible when any of the btn_retry is checked
636
+ for btn_retry in btn_retrys:
637
+ # Add the event handlers to the btn_retry buttons
638
+ btn_retry.change(fn=on_retry_button_click, inputs=[*btn_retrys], outputs=[regen_view_btn, regen_mesh_btn], queue=False)
639
+
640
+
641
+ run_btn.click(fn=partial(update_guide, _SAM), outputs=[guide_text], queue=False
642
+ ).success(fn=partial(preprocess_run, predictor, models),
643
+ inputs=[image_block, preprocess_chk, *bbox_sliders],
644
+ outputs=[sam_block]
645
+ ).success(fn=partial(update_guide, _GEN_1), outputs=[guide_text], queue=False
646
+ ).success(fn=partial(stage1_run, models, device, cam_vis),
647
+ inputs=[tmp_dir, sam_block, scale_slider, steps_slider],
648
+ outputs=[elev_output, vis_output, *views]
649
+ ).success(fn=partial(update_guide, _GEN_2), outputs=[guide_text], queue=False
650
+ ).success(fn=partial(stage2_run, models, device),
651
+ inputs=[tmp_dir, elev_output, scale_slider, glb_chk],
652
+ outputs=[mesh_output]
653
+ ).success(fn=partial(update_guide, _DONE), outputs=[guide_text], queue=False)
654
+
655
+
656
+ regen_view_btn.click(fn=partial(stage1_run, models, device, None),
657
+ inputs=[tmp_dir, sam_block, scale_slider, steps_slider, elev_output, rerun_idx, *btn_retrys],
658
+ outputs=[rerun_idx, *btn_retrys, *views]
659
+ ).success(fn=partial(update_guide, _REGEN_1), outputs=[guide_text], queue=False)
660
+ regen_mesh_btn.click(fn=partial(stage2_run, models, device),
661
+ inputs=[tmp_dir, elev_output, scale_slider, glb_chk, rerun_idx],
662
+ outputs=[mesh_output, rerun_idx, regen_view_btn, regen_mesh_btn]
663
+ ).success(fn=partial(update_guide, _REGEN_2), outputs=[guide_text], queue=False)
664
+
665
+
666
+ demo.launch(enable_queue=True, share=False, max_threads=80) # auth=("admin", os.environ['PASSWD'])
667
+
668
+
669
+ if __name__ == '__main__':
670
+
671
+ fire.Fire(run_demo)
demo_examples/00_zero123_lysol.png ADDED

Git LFS Details

  • SHA256: e6a8dc67d256dbd16f399407bf12f554bb86a1ba5428c0666556f012bcc00e27
  • Pointer size: 130 Bytes
  • Size of remote file: 27 kB
demo_examples/01_wild_hydrant.png ADDED

Git LFS Details

  • SHA256: 3c523613f3a178acd2cbdc82635674de91060523094ce304b1707202f850e2bc
  • Pointer size: 131 Bytes
  • Size of remote file: 530 kB
demo_examples/02_zero123_spyro.png ADDED

Git LFS Details

  • SHA256: 12cf2a035a4d2d5d11952c30cb1ca9d80ca0ea5b7467cd3a19209df50e68428f
  • Pointer size: 130 Bytes
  • Size of remote file: 31.1 kB
demo_examples/03_wild2_pineapple_bottle.png ADDED

Git LFS Details

  • SHA256: e37757de125a25d76d72bb3b4ad535931fc1691a740a330cf1e02c2c772cf639
  • Pointer size: 131 Bytes
  • Size of remote file: 402 kB
demo_examples/04_unsplash_broccoli.png ADDED

Git LFS Details

  • SHA256: 0342affecfd2626bae0238cf07c7aa173ec8a99e9eba02381334dc44d62b558f
  • Pointer size: 131 Bytes
  • Size of remote file: 275 kB
demo_examples/05_objaverse_backpack.png ADDED

Git LFS Details

  • SHA256: a7ee505609229e4e5563ae5ff679a3dbcef33e20a6c3adcc69f82038acc12e5a
  • Pointer size: 130 Bytes
  • Size of remote file: 39.6 kB
demo_examples/06_unsplash_chocolatecake.png ADDED

Git LFS Details

  • SHA256: f2d9d9c515d2ca28720e361762cf45630ef82efbcf0de4face13bb77784392e2
  • Pointer size: 131 Bytes
  • Size of remote file: 207 kB
demo_examples/07_unsplash_stool2.png ADDED

Git LFS Details

  • SHA256: 2d00968b346d5e63aa68645c5e13edc13b3665fd7e89ad7ae6f374414320f28f
  • Pointer size: 131 Bytes
  • Size of remote file: 198 kB
demo_examples/08_dalle_icecream.png ADDED

Git LFS Details

  • SHA256: 8c814423ff2dbac089485b35d9b350a855ab18f8d422dee25e3f5e5f6bd7eb1e
  • Pointer size: 131 Bytes
  • Size of remote file: 221 kB
demo_examples/09_unsplash_bigmac.png ADDED

Git LFS Details

  • SHA256: c85bedd18f77f3574fbaa8ff296607f4fe17f36d0fd8a8c5ca262fdee9486f84
  • Pointer size: 131 Bytes
  • Size of remote file: 395 kB
demo_examples/10_dalle3_blueberryicecream2.png ADDED

Git LFS Details

  • SHA256: b6c5aa7b48d2550e08865ef0e1b097955ad2c292b4f4c8a92e6638ae88d3f4a0
  • Pointer size: 131 Bytes
  • Size of remote file: 221 kB
demo_examples/11_GSO_Crosley_Alarm_Clock_Vintage_Metal.png ADDED

Git LFS Details

  • SHA256: cef5279deddead4cb31258a73613accccc21d1e6b63bbdacb0b934d66ff31a08
  • Pointer size: 130 Bytes
  • Size of remote file: 32 kB
demo_examples/12_realfusion_cactus_1.png ADDED

Git LFS Details

  • SHA256: bc8b559acdaabd5fec369e9543a3fb4516d25b74e2bab35e075335e7e557cef3
  • Pointer size: 131 Bytes
  • Size of remote file: 122 kB
demo_examples/13_realfusion_cherry_1.png ADDED

Git LFS Details

  • SHA256: 99f8defc7d88f0a953578004443ec117b90920e68e86ad0488b8529ad5f61c2b
  • Pointer size: 131 Bytes
  • Size of remote file: 273 kB
demo_examples/14_dalle_cowbear.png ADDED

Git LFS Details

  • SHA256: 1c6a510ebdea03448dadf4dff71a2cc3ce54e0a0328ee87ce0c1bbf6fbbca91d
  • Pointer size: 131 Bytes
  • Size of remote file: 284 kB
demo_examples/15_dalle3_gramophone1.png ADDED

Git LFS Details

  • SHA256: 54a802f0995b6ff64071b9b986650037be5fcd0d5b68626a4b468a5709cc0d29
  • Pointer size: 131 Bytes
  • Size of remote file: 277 kB
demo_examples/16_dalle3_mushroom2.png ADDED

Git LFS Details

  • SHA256: dd4f0cb7cd9b65489e8ccb2d23d76ec1caa29ebf7c1e0c1fc25fdd803e8ce9a4
  • Pointer size: 131 Bytes
  • Size of remote file: 352 kB
demo_examples/17_dalle3_rockingchair1.png ADDED

Git LFS Details

  • SHA256: 6ad3eea0f2a98af1d5382787dda80c24b2061456ca8bde094cd9fc9308b178c3
  • Pointer size: 131 Bytes
  • Size of remote file: 230 kB
demo_examples/18_unsplash_mario.png ADDED

Git LFS Details

  • SHA256: 55fd9facf435eda15d5636f001c78bbe9cee14b549672bc2eb86ae4dbe183e97
  • Pointer size: 131 Bytes
  • Size of remote file: 294 kB
demo_examples/19_dalle3_stump1.png ADDED

Git LFS Details

  • SHA256: 1e64cbbc88f310487f5b2f3ed2eb7d1cd859adf4653e10173033ddee6562151e
  • Pointer size: 131 Bytes
  • Size of remote file: 297 kB
demo_examples/20_objaverse_stool.png ADDED

Git LFS Details

  • SHA256: fca2047879efaffd5ce6e19271d633cb1a4e67080ccfdcf7d251da4d2753172a
  • Pointer size: 130 Bytes
  • Size of remote file: 25.5 kB
demo_examples/21_objaverse_barrel.png ADDED

Git LFS Details

  • SHA256: d33a8814313eb11bdca60aec3cad0f7d49c76e397b265d9797a4efe2bce5dbce
  • Pointer size: 130 Bytes
  • Size of remote file: 49.6 kB
demo_examples/22_unsplash_boxtoy.png ADDED

Git LFS Details

  • SHA256: 0d40a932892e3bd7076eb44cfe327e1e87ea00469cf1a120da746e6f3caef882
  • Pointer size: 131 Bytes
  • Size of remote file: 275 kB
demo_examples/23_objaverse_tank.png ADDED

Git LFS Details

  • SHA256: 2f970c70041f951d1a0683a0b2ff57354850498c4add47758bc2d1fa59b6590c
  • Pointer size: 130 Bytes
  • Size of remote file: 51.3 kB
demo_examples/24_wild2_yellow_duck.png ADDED

Git LFS Details

  • SHA256: 5791f44bdf0487916eb3129539ae0bcaec1d3ebc825363b27aebfeeb2981643d
  • Pointer size: 131 Bytes
  • Size of remote file: 560 kB
demo_examples/25_unsplash_teapot.png ADDED

Git LFS Details

  • SHA256: 70e67ae75c14fc60beddceafbce0ad81a5142b17378531b880ae9858fae51483
  • Pointer size: 131 Bytes
  • Size of remote file: 255 kB
demo_examples/26_unsplash_strawberrycake.png ADDED

Git LFS Details

  • SHA256: 3db1f8ebc29f3ea89fb16a9202d9659ddac447a85ef015e7a5b731178a076ddd
  • Pointer size: 131 Bytes
  • Size of remote file: 198 kB
demo_examples/27_objaverse_robocat.png ADDED

Git LFS Details

  • SHA256: 83499ab6e65e6cfa9e158d71a141c296d8585a0ba8923251b86de68af2b4f1a8
  • Pointer size: 130 Bytes
  • Size of remote file: 32 kB
demo_examples/28_wild_goose_chef.png ADDED

Git LFS Details

  • SHA256: 7a3fc54c19e7ddf9d3c4796f597e96a373904cb6341c02a3676df92352837496
  • Pointer size: 131 Bytes
  • Size of remote file: 274 kB
demo_examples/29_wild_peroxide.png ADDED

Git LFS Details

  • SHA256: 6d30acf4216ca9cc9531d630881047c6864c5359f53685101547311d99b6a38f
  • Pointer size: 131 Bytes
  • Size of remote file: 238 kB
demo_tmp/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ tmp*
demo_tmp/.gitkeep ADDED
File without changes
instructions_12345.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Tuning Tips:
2
+
3
+ 1. The multi-view prediction module (Zero123) operates probabilistically. If some of the predicted views are not satisfactory, you may select and regenerate them.
4
+
5
+ 2. In “advanced options”, you can tune two parameters as in other common diffusion models:
6
+ - Diffusion Guidance Scale determines how much you want the model to respect the input information (input image + viewpoints). Increasing the scale typically results in better adherence, less diversity, and also higher image distortion.
7
+
8
+ - Number of diffusion inference steps controls the number of diffusion steps applied to generate each image. Generally, a higher value yields better results but with diminishing returns.
9
+
10
+ Enjoy creating your 3D asset!
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ libsparsehash-dev
pre-requirements.txt ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # --extra-index-url https://download.pytorch.org/whl/cu113
2
+ torch>=1.12.1
3
+ torchvision>=0.13.1
4
+ albumentations>=0.4.3
5
+ opencv-python>=4.5.5.64
6
+ pudb>=2019.2
7
+ imageio>=2.9.0
8
+ imageio-ffmpeg>=0.4.2
9
+ pytorch-lightning>=1.4.2
10
+ omegaconf>=2.1.1
11
+ test-tube>=0.7.5
12
+ streamlit>=0.73.1
13
+ einops>=0.3.0
14
+ torch-fidelity>=0.3.0
15
+ transformers>=4.22.2
16
+ kornia>=0.6
17
+ webdataset>=0.2.5
18
+ torchmetrics>=0.6.0
19
+ fire>=0.4.0
20
+ gradio>=3.21.0
21
+ diffusers>=0.12.1
22
+ datasets[vision]>=2.4.0
23
+ carvekit-colab>=4.1.0
24
+ rich>=13.3.2
25
+ lovely-numpy>=0.2.8
26
+ lovely-tensors>=0.1.14
27
+ plotly>=5.13.1
28
+ -e git+https://github.com/CompVis/taming-transformers.git#egg=taming-transformers
29
+ # elev est
30
+ dl_ext
31
+ easydict
32
+ glumpy
33
+ gym
34
+ h5py
35
+ imageio
36
+ loguru
37
+ matplotlib
38
+ # mplib
39
+ multipledispatch
40
+ open3d
41
+ packaging
42
+ Pillow
43
+ pycocotools
44
+ motion-planning
45
+ pyrender
46
+ PyYAML
47
+ scikit_image
48
+ scikit_learn
49
+ scipy
50
+ screeninfo
51
+ setuptools
52
+ tensorboardX
53
+ termcolor
54
+ tqdm
55
+ transforms3d
56
+ trimesh
57
+ yacs
58
+ zarr
59
+ sapien
60
+ pyglet==1.5.27
61
+ wis3d
62
+ gdown
63
+ git+https://github.com/NVlabs/nvdiffrast.git
64
+ # shap-e
65
+ git+https://github.com/openai/shap-e@8625e7c
66
+ # segment anything
67
+ opencv-python
68
+ pycocotools
69
+ matplotlib
70
+ onnxruntime
71
+ onnx
72
+ git+https://github.com/facebookresearch/segment-anything.git
73
+ # rembg
74
+ rembg
requirements.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # sparseneus
2
+ # -e git+https://github.com/mit-han-lab/[email protected]#egg=torchsparse
3
+ opencv_python
4
+ trimesh
5
+ numpy
6
+ pyhocon
7
+ icecream
8
+ tqdm
9
+ scipy
10
+ PyMCubes
11
+ ninja
12
+ # sudo apt-get install libsparsehash-dev