codic commited on
Commit
4488dd6
·
verified ·
1 Parent(s): 7924226

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -64,7 +64,7 @@ def process_image(image_path, depth_map_path=None):
64
 
65
  # Step 2: Edge-preserving filter (Enhance small structures)
66
  depth_image = cv2.edgePreservingFilter(
67
- (depth_image_cleaned * 255).astype(np.uint8), flags=1, sigma_s=20, sigma_r=0.3
68
  )
69
  depth_image = depth_image.astype(np.float32) / 255 # Normalize back to [0, 1]
70
 
@@ -103,7 +103,7 @@ def process_image(image_path, depth_map_path=None):
103
  img = Image.fromarray(depth_display)
104
  return [img, gltf_path, gltf_path]
105
 
106
- def create_3d_obj(foreground, depth_image, image_path, depth=12, edge_strength=0.15):
107
  """
108
  Generates a 3D model by combining an image and a masked depth map focused only on the main subject.
109
 
@@ -175,7 +175,7 @@ def create_3d_obj(foreground, depth_image, image_path, depth=12, edge_strength=0
175
 
176
 
177
  # Simplify with smaller voxel size for more detail
178
- voxel_size = max(mesh_raw.get_max_bound() - mesh_raw.get_min_bound()) / 5200
179
  mesh = mesh_raw.simplify_vertex_clustering(
180
  voxel_size=voxel_size,
181
  contraction=o3d.geometry.SimplificationContraction.Average,
@@ -195,7 +195,7 @@ def create_3d_obj(foreground, depth_image, image_path, depth=12, edge_strength=0
195
  # Save high-resolution texture image
196
  texture_path = f"./{image_path.stem}_texture_highres.png"
197
  foreground_pil = Image.fromarray(foreground)
198
- high_res_texture = foreground_pil.resize((3096, 3096), Image.LANCZOS) # Increased resolution for finer details
199
  high_res_texture.save(texture_path)
200
 
201
  # Apply the high-resolution texture and export the mesh as a GLTF file
 
64
 
65
  # Step 2: Edge-preserving filter (Enhance small structures)
66
  depth_image = cv2.edgePreservingFilter(
67
+ (depth_image_cleaned * 255).astype(np.uint8), flags=1, sigma_s=14, sigma_r=0.3
68
  )
69
  depth_image = depth_image.astype(np.float32) / 255 # Normalize back to [0, 1]
70
 
 
103
  img = Image.fromarray(depth_display)
104
  return [img, gltf_path, gltf_path]
105
 
106
+ def create_3d_obj(foreground, depth_image, image_path, depth=10, edge_strength=0.15):
107
  """
108
  Generates a 3D model by combining an image and a masked depth map focused only on the main subject.
109
 
 
175
 
176
 
177
  # Simplify with smaller voxel size for more detail
178
+ voxel_size = max(mesh_raw.get_max_bound() - mesh_raw.get_min_bound()) / 4200
179
  mesh = mesh_raw.simplify_vertex_clustering(
180
  voxel_size=voxel_size,
181
  contraction=o3d.geometry.SimplificationContraction.Average,
 
195
  # Save high-resolution texture image
196
  texture_path = f"./{image_path.stem}_texture_highres.png"
197
  foreground_pil = Image.fromarray(foreground)
198
+ high_res_texture = foreground_pil.resize((2096, 2096), Image.LANCZOS) # Increased resolution for finer details
199
  high_res_texture.save(texture_path)
200
 
201
  # Apply the high-resolution texture and export the mesh as a GLTF file