tokenid commited on
Commit
35f429b
1 Parent(s): 00059bc
Files changed (2) hide show
  1. app.py +14 -25
  2. src/models/renderer/utils/renderer.py +2 -0
app.py CHANGED
@@ -167,30 +167,6 @@ def generate_mvs(input_image, sample_steps, sample_seed):
167
 
168
  return z123_image, show_image
169
 
170
- def make_mesh(mesh_fpath, planes):
171
-
172
- mesh_basename = os.path.basename(mesh_fpath).split('.')[0]
173
- mesh_dirname = os.path.dirname(mesh_fpath)
174
- mesh_vis_fpath = os.path.join(mesh_dirname, f"{mesh_basename}.glb")
175
-
176
- with torch.no_grad():
177
-
178
- # get mesh
179
- mesh_out = model.extract_mesh(
180
- planes,
181
- use_texture_map=False,
182
- **infer_config,
183
- )
184
-
185
- vertices, faces, vertex_colors = mesh_out
186
- vertices = vertices[:, [0, 2, 1]]
187
- vertices[:, -1] *= -1
188
-
189
- save_obj(vertices, faces, vertex_colors, mesh_fpath)
190
-
191
- print(f"Mesh saved to {mesh_fpath}")
192
-
193
- return mesh_fpath
194
 
195
  @spaces.GPU
196
  def make3d(input_image, sample_steps, sample_seed):
@@ -253,7 +229,20 @@ def make3d(input_image, sample_steps, sample_seed):
253
 
254
  # print(f"Video saved to {video_fpath}")
255
 
256
- mesh_fpath = make_mesh(mesh_fpath, planes)
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
  return mesh_fpath, show_images
259
 
 
167
 
168
  return z123_image, show_image
169
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
  @spaces.GPU
172
  def make3d(input_image, sample_steps, sample_seed):
 
229
 
230
  # print(f"Video saved to {video_fpath}")
231
 
232
+ # get mesh
233
+ mesh_out = model.extract_mesh(
234
+ planes,
235
+ use_texture_map=False,
236
+ **infer_config,
237
+ )
238
+
239
+ vertices, faces, vertex_colors = mesh_out
240
+ vertices = vertices[:, [0, 2, 1]]
241
+ vertices[:, -1] *= -1
242
+
243
+ save_obj(vertices, faces, vertex_colors, mesh_fpath)
244
+
245
+ print(f"Mesh saved to {mesh_fpath}")
246
 
247
  return mesh_fpath, show_images
248
 
src/models/renderer/utils/renderer.py CHANGED
@@ -68,6 +68,8 @@ def sample_from_planes(plane_axes, plane_features, coordinates, mode='bilinear',
68
 
69
  coordinates = (2/box_warp) * coordinates # add specific box bounds
70
 
 
 
71
  projected_coordinates = project_onto_planes(plane_axes, coordinates).unsqueeze(1)
72
  output_features = torch.nn.functional.grid_sample(
73
  plane_features,
 
68
 
69
  coordinates = (2/box_warp) * coordinates # add specific box bounds
70
 
71
+ print('plane_axes', plane_axes.dtype, 'plane_features', plane_features.dtype, 'coordinates', coordinates.dtype)
72
+
73
  projected_coordinates = project_onto_planes(plane_axes, coordinates).unsqueeze(1)
74
  output_features = torch.nn.functional.grid_sample(
75
  plane_features,