hysts HF staff commited on
Commit
7292a02
1 Parent(s): 7d275a2
Files changed (3) hide show
  1. app.py +6 -5
  2. model.py +10 -3
  3. requirements.txt +1 -0
app.py CHANGED
@@ -39,9 +39,10 @@ with gr.Blocks(css='style.css') as demo:
39
  progress_text = gr.Text(label='Progress')
40
  with gr.Tabs():
41
  with gr.TabItem(label='Images from each viewpoint'):
42
- viewpoint_images = gr.Gallery(show_label=False)
43
- with gr.TabItem(label='Result video'):
44
- result_video = gr.Video(show_label=False)
 
45
  with gr.TabItem(label='Output mesh file'):
46
  output_file = gr.File(show_label=False)
47
  with gr.Row():
@@ -60,7 +61,7 @@ with gr.Blocks(css='style.css') as demo:
60
  guidance_scale,
61
  ],
62
  outputs=[
63
- result_video,
64
  output_file,
65
  ],
66
  cache_examples=False)
@@ -74,7 +75,7 @@ with gr.Blocks(css='style.css') as demo:
74
  ],
75
  outputs=[
76
  viewpoint_images,
77
- result_video,
78
  output_file,
79
  progress_text,
80
  ])
 
39
  progress_text = gr.Text(label='Progress')
40
  with gr.Tabs():
41
  with gr.TabItem(label='Images from each viewpoint'):
42
+ viewpoint_images = gr.Gallery(show_label=False).style(
43
+ columns=4, height='auto')
44
+ with gr.TabItem(label='Result 3D model'):
45
+ result_3d_model = gr.Model3D(show_label=False)
46
  with gr.TabItem(label='Output mesh file'):
47
  output_file = gr.File(show_label=False)
48
  with gr.Row():
 
61
  guidance_scale,
62
  ],
63
  outputs=[
64
+ result_3d_model,
65
  output_file,
66
  ],
67
  cache_examples=False)
 
75
  ],
76
  outputs=[
77
  viewpoint_images,
78
+ result_3d_model,
79
  output_file,
80
  progress_text,
81
  ])
model.py CHANGED
@@ -8,6 +8,7 @@ import sys
8
  from typing import Generator, Optional
9
 
10
  import gradio as gr
 
11
 
12
  sys.path.append('TEXTurePaper')
13
 
@@ -80,8 +81,14 @@ class Model:
80
  yield sample_image_paths, None, None, f'{step}/{total_steps}'
81
 
82
  trainer.mesh_model.change_default_to_median()
83
- trainer.full_eval()
84
 
85
- video_path = config.log.exp_dir / 'results' / 'step_00010_rgb.mp4'
 
 
 
 
 
 
 
86
  zip_path = self.zip_results(config.log.exp_dir)
87
- yield sample_image_paths, video_path.as_posix(), zip_path, 'Done!'
 
8
  from typing import Generator, Optional
9
 
10
  import gradio as gr
11
+ import trimesh
12
 
13
  sys.path.append('TEXTurePaper')
14
 
 
81
  yield sample_image_paths, None, None, f'{step}/{total_steps}'
82
 
83
  trainer.mesh_model.change_default_to_median()
 
84
 
85
+ save_dir = trainer.exp_path / 'mesh'
86
+ save_dir.mkdir(exist_ok=True, parents=True)
87
+ trainer.mesh_model.export_mesh(save_dir)
88
+ model_path = save_dir / 'mesh.obj'
89
+ mesh = trimesh.load(model_path)
90
+ mesh_path = save_dir / 'mesh.glb'
91
+ mesh.export(mesh_path, file_type='glb')
92
+
93
  zip_path = self.zip_results(config.log.exp_dir)
94
+ yield sample_image_paths, mesh_path.as_posix(), zip_path, 'Done!'
requirements.txt CHANGED
@@ -12,4 +12,5 @@ torch==1.12.1
12
  torchvision==0.13.1
13
  tqdm==4.65.0
14
  transformers==4.29.1
 
15
  xatlas==0.0.7
 
12
  torchvision==0.13.1
13
  tqdm==4.65.0
14
  transformers==4.29.1
15
+ trimesh==3.21.6
16
  xatlas==0.0.7