17
17
get_zero123plus_input_cameras ,
18
18
get_circular_camera_poses ,
19
19
)
20
- from src .utils .mesh_util import save_obj
20
+ from src .utils .mesh_util import save_obj , save_glb
21
21
from src .utils .infer_util import remove_background , resize_foreground , images_to_video
22
22
23
23
import tempfile
@@ -139,11 +139,12 @@ def generate_mvs(input_image, sample_steps, sample_seed):
139
139
140
140
return z123_image , show_image
141
141
142
+
142
143
def make_mesh (mesh_fpath , planes ):
143
144
144
145
mesh_basename = os .path .basename (mesh_fpath ).split ('.' )[0 ]
145
146
mesh_dirname = os .path .dirname (mesh_fpath )
146
- mesh_vis_fpath = os .path .join (mesh_dirname , f"{ mesh_basename } .glb" )
147
+ mesh_glb_fpath = os .path .join (mesh_dirname , f"{ mesh_basename } .glb" )
147
148
148
149
with torch .no_grad ():
149
150
# get mesh
@@ -156,14 +157,14 @@ def make_mesh(mesh_fpath, planes):
156
157
157
158
vertices , faces , vertex_colors = mesh_out
158
159
vertices = vertices [:, [1 , 2 , 0 ]]
159
- vertices [:, - 1 ] *= - 1
160
- faces = faces [:, [2 , 1 , 0 ]]
161
-
160
+
161
+ save_glb (vertices , faces , vertex_colors , mesh_glb_fpath )
162
162
save_obj (vertices , faces , vertex_colors , mesh_fpath )
163
163
164
164
print (f"Mesh saved to { mesh_fpath } " )
165
165
166
- return mesh_fpath
166
+ return mesh_fpath , mesh_glb_fpath
167
+
167
168
168
169
def make3d (images ):
169
170
@@ -217,10 +218,9 @@ def make3d(images):
217
218
218
219
print (f"Video saved to { video_fpath } " )
219
220
220
- mesh_fpath = make_mesh (mesh_fpath , planes )
221
-
222
- return video_fpath , mesh_fpath
221
+ mesh_fpath , mesh_glb_fpath = make_mesh (mesh_fpath , planes )
223
222
223
+ return video_fpath , mesh_fpath , mesh_glb_fpath
224
224
225
225
226
226
import gradio as gr
@@ -316,11 +316,20 @@ def make3d(images):
316
316
)
317
317
318
318
with gr .Row ():
319
- output_model_obj = gr .Model3D (
320
- label = "Output Model (OBJ Format)" ,
321
- # width=768,
322
- interactive = False ,
323
- )
319
+ with gr .Tab ("OBJ" ):
320
+ output_model_obj = gr .Model3D (
321
+ label = "Output Model (OBJ Format)" ,
322
+ #width=768,
323
+ interactive = False ,
324
+ )
325
+ with gr .Tab ("GLB" ):
326
+ output_model_glb = gr .Model3D (
327
+ label = "Output Model (GLB Format)" ,
328
+ #width=768,
329
+ interactive = False ,
330
+ )
331
+ gr .Markdown ("Note: The model shown here has a darker appearance. Download to get correct results." )
332
+
324
333
with gr .Row ():
325
334
gr .Markdown ('''Try a different <b>seed value</b> if the result is unsatisfying (Default: 42).''' )
326
335
@@ -339,7 +348,7 @@ def make3d(images):
339
348
).success (
340
349
fn = make3d ,
341
350
inputs = [mv_images ],
342
- outputs = [output_video , output_model_obj ]
351
+ outputs = [output_video , output_model_obj , output_model_glb ]
343
352
)
344
353
345
354
demo .queue (max_size = 10 )
0 commit comments