Yuliang commited on
Commit
de9b060
1 Parent(s): 96d77c3

only show refined clothed human

Browse files
Files changed (3) hide show
  1. .gitignore +2 -0
  2. app.py +3 -6
  3. apps/infer.py +9 -16
.gitignore CHANGED
@@ -14,3 +14,5 @@ neural_voxelization_layer/
14
  pytorch3d/
15
  force_push.sh
16
  results/
 
 
14
  pytorch3d/
15
  force_push.sh
16
  results/
17
+ gradio_cached_examples/
18
+ gradio_queue.db
app.py CHANGED
@@ -47,7 +47,7 @@ description = '''
47
  </th>
48
  </table>
49
 
50
- <h4> The reconstruction + refinement + video take about 80~200 seconds for single image. <span style="color:red"> If ERROR, try "Submit Image" again.</span></h4>
51
 
52
  <details>
53
 
@@ -94,7 +94,7 @@ def generate_image(seed, psi):
94
 
95
 
96
  random.seed(2022)
97
- model_types = ['icon-filter', 'pifu', 'pamir']
98
  examples = [[item, random.choice(model_types)]
99
  for item in glob.glob('examples/*.png')]
100
 
@@ -134,15 +134,12 @@ with gr.Blocks() as demo:
134
  clear_color=[0.0, 0.0, 0.0, 0.0], label="SMPL")
135
  out_smpl_download = gr.File(label="Download SMPL mesh")
136
  out_smpl_npy_download = gr.File(label="Download SMPL params")
137
- out_recon = gr.Model3D(
138
- clear_color=[0.0, 0.0, 0.0, 0.0], label="Recon")
139
- out_recon_download = gr.File(label="Download clothed human mesh")
140
  out_final = gr.Model3D(
141
  clear_color=[0.0, 0.0, 0.0, 0.0], label="Refined Recon")
142
  out_final_download = gr.File(
143
  label="Download refined clothed human mesh")
144
 
145
- out_lst = [out_smpl, out_smpl_download, out_smpl_npy_download, out_recon, out_recon_download,
146
  out_final, out_final_download, out_vid, out_vid_download, overlap_inp]
147
 
148
  btn_submit.click(fn=generate_model, inputs=[
47
  </th>
48
  </table>
49
 
50
+ <h4> The reconstruction + refinement + video take about 200 seconds for single image. <span style="color:red"> If ERROR, try "Submit Image" again.</span></h4>
51
 
52
  <details>
53
 
94
 
95
 
96
  random.seed(2022)
97
+ model_types = ['ICON', 'PIFu', 'PaMIR']
98
  examples = [[item, random.choice(model_types)]
99
  for item in glob.glob('examples/*.png')]
100
 
134
  clear_color=[0.0, 0.0, 0.0, 0.0], label="SMPL")
135
  out_smpl_download = gr.File(label="Download SMPL mesh")
136
  out_smpl_npy_download = gr.File(label="Download SMPL params")
 
 
 
137
  out_final = gr.Model3D(
138
  clear_color=[0.0, 0.0, 0.0, 0.0], label="Refined Recon")
139
  out_final_download = gr.File(
140
  label="Download refined clothed human mesh")
141
 
142
+ out_lst = [out_smpl, out_smpl_download, out_smpl_npy_download,
143
  out_final, out_final_download, out_vid, out_vid_download, overlap_inp]
144
 
145
  btn_submit.click(fn=generate_model, inputs=[
apps/infer.py CHANGED
@@ -49,9 +49,14 @@ logging.getLogger("trimesh").setLevel(logging.ERROR)
49
  def generate_model(in_path, model_type):
50
 
51
  torch.cuda.empty_cache()
 
 
 
 
 
52
 
53
  config_dict = {'loop_smpl': 100,
54
- 'loop_cloth': 100,
55
  'patience': 5,
56
  'out_dir': './results',
57
  'hps_type': 'pymaf',
@@ -340,10 +345,6 @@ def generate_model(in_path, model_type):
340
  os.path.join(config_dict['out_dir'], cfg.name,
341
  f"obj/{data['name']}_recon.obj")
342
  )
343
- recon_obj.export(
344
- os.path.join(config_dict['out_dir'], cfg.name,
345
- f"obj/{data['name']}_recon.glb")
346
- )
347
 
348
  # Isotropic Explicit Remeshing for better geometry topology
349
  verts_refine, faces_refine = remesh(os.path.join(config_dict['out_dir'], cfg.name,
@@ -428,12 +429,8 @@ def generate_model(in_path, model_type):
428
  f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_refine.glb")
429
 
430
  # always export visualized video regardless of the cloth refinment
431
- if final is not None:
432
- verts_lst = [verts_pr, final.vertices]
433
- faces_lst = [faces_pr, final.faces]
434
- else:
435
- verts_lst = [verts_pr]
436
- faces_lst = [faces_pr]
437
 
438
  # self-rotated video
439
  dataset.render.load_meshes(
@@ -447,8 +444,6 @@ def generate_model(in_path, model_type):
447
  smpl_obj_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_smpl.obj"
448
  smpl_glb_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_smpl.glb"
449
  smpl_npy_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_smpl.npy"
450
- recon_obj_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_recon.obj"
451
- recon_glb_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_recon.glb"
452
  refine_obj_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_refine.obj"
453
  refine_glb_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_refine.glb"
454
 
@@ -464,8 +459,6 @@ def generate_model(in_path, model_type):
464
  gc.collect()
465
  torch.cuda.empty_cache()
466
 
467
- return [smpl_glb_path, smpl_obj_path,
468
- smpl_npy_path,
469
- recon_glb_path, recon_obj_path,
470
  refine_glb_path, refine_obj_path,
471
  video_path, video_path, overlap_path]
49
  def generate_model(in_path, model_type):
50
 
51
  torch.cuda.empty_cache()
52
+
53
+ if model_type == 'ICON':
54
+ model_type = 'icon-filter'
55
+ else:
56
+ model_type = model_type.lower()
57
 
58
  config_dict = {'loop_smpl': 100,
59
+ 'loop_cloth': 200,
60
  'patience': 5,
61
  'out_dir': './results',
62
  'hps_type': 'pymaf',
345
  os.path.join(config_dict['out_dir'], cfg.name,
346
  f"obj/{data['name']}_recon.obj")
347
  )
 
 
 
 
348
 
349
  # Isotropic Explicit Remeshing for better geometry topology
350
  verts_refine, faces_refine = remesh(os.path.join(config_dict['out_dir'], cfg.name,
429
  f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_refine.glb")
430
 
431
  # always export visualized video regardless of the cloth refinment
432
+ verts_lst = [smpl_obj.vertices, final.vertices]
433
+ faces_lst = [smpl_obj.faces, final.faces]
 
 
 
 
434
 
435
  # self-rotated video
436
  dataset.render.load_meshes(
444
  smpl_obj_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_smpl.obj"
445
  smpl_glb_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_smpl.glb"
446
  smpl_npy_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_smpl.npy"
 
 
447
  refine_obj_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_refine.obj"
448
  refine_glb_path = f"{config_dict['out_dir']}/{cfg.name}/obj/{data['name']}_refine.glb"
449
 
459
  gc.collect()
460
  torch.cuda.empty_cache()
461
 
462
+ return [smpl_glb_path, smpl_obj_path,smpl_npy_path,
 
 
463
  refine_glb_path, refine_obj_path,
464
  video_path, video_path, overlap_path]