BladeSzaSza commited on
Commit
c95a6a2
·
1 Parent(s): e4aa154

fix: resolve boundary index calculation error in 3D mesh generation and AttributeError in image generator cleanup

Browse files
models/image_generator.py CHANGED
@@ -271,7 +271,7 @@ class OmniGenImageGenerator:
271
 
272
  def __del__(self):
273
  """Cleanup when object is destroyed"""
274
- if self.pipeline:
275
  del self.pipeline
276
  gc.collect()
277
  if torch.cuda.is_available():
 
271
 
272
  def __del__(self):
273
  """Cleanup when object is destroyed"""
274
+ if hasattr(self, 'pipeline') and self.pipeline is not None:
275
  del self.pipeline
276
  gc.collect()
277
  if torch.cuda.is_available():
models/model_3d_generator.py CHANGED
@@ -335,21 +335,40 @@ class Hunyuan3DGenerator:
335
  base_vertices = []
336
  base_faces = []
337
 
338
- # Get boundary vertices
339
  boundary_indices = []
340
- for i in range(h):
341
- boundary_indices.append(i * w) # Left edge
342
- boundary_indices.append(i * w + w - 1) # Right edge
343
  for j in range(1, w-1):
344
- boundary_indices.append(j) # Top edge
345
- boundary_indices.append((h-1) * w + j) # Bottom edge
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
 
347
  # Create base vertices
348
  start_idx = len(vertices)
349
  for idx in boundary_indices:
350
- v = vertices[idx].copy()
351
- v[2] = base_z
352
- base_vertices.append(v)
 
 
 
 
 
353
 
354
  # Create center vertex
355
  center = np.mean(base_vertices, axis=0)
 
335
  base_vertices = []
336
  base_faces = []
337
 
338
+ # Get boundary vertices - fix the indexing
339
  boundary_indices = []
340
+
341
+ # Top edge (excluding corners)
 
342
  for j in range(1, w-1):
343
+ boundary_indices.append(j)
344
+
345
+ # Right edge (including top-right corner)
346
+ for i in range(h):
347
+ boundary_indices.append(i * w + w - 1)
348
+
349
+ # Bottom edge (excluding bottom-right corner, going right to left)
350
+ for j in range(w-2, 0, -1):
351
+ boundary_indices.append((h-1) * w + j)
352
+
353
+ # Left edge (including bottom-left corner, going bottom to top)
354
+ for i in range(h-1, -1, -1):
355
+ boundary_indices.append(i * w)
356
+
357
+ # Remove duplicate indices (first and last should not be the same)
358
+ if boundary_indices and boundary_indices[0] == boundary_indices[-1]:
359
+ boundary_indices = boundary_indices[:-1]
360
 
361
  # Create base vertices
362
  start_idx = len(vertices)
363
  for idx in boundary_indices:
364
+ if idx < len(vertices): # Safety check
365
+ v = vertices[idx].copy()
366
+ v[2] = base_z
367
+ base_vertices.append(v)
368
+
369
+ if not base_vertices:
370
+ # If no base vertices were created, return empty arrays
371
+ return np.array([]), np.array([])
372
 
373
  # Create center vertex
374
  center = np.mean(base_vertices, axis=0)