codic commited on
Commit
d1c4755
·
verified ·
1 Parent(s): b79af75

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -5
app.py CHANGED
@@ -16,8 +16,6 @@ from rembg import remove
16
  feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large")
17
  model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
18
 
19
-
20
-
21
  def process_image(image_path, depth_map_path=None):
22
  image_path = Path(image_path)
23
  image_raw = Image.open(image_path).convert("RGB")
@@ -175,10 +173,10 @@ def create_3d_obj(foreground, depth_image, image_path, depth=12, edge_strength=0
175
  foreground_pil = Image.fromarray(foreground)
176
  high_res_texture = foreground_pil.resize((4096, 4096), Image.LANCZOS) # Increased resolution for finer details
177
  high_res_texture.save(texture_path)
178
- mesh_crop.textures = [o3d.geometry.Image(np.array(high_res_texture))]
179
 
180
- # Export to glTF format
181
- gltf_path = f"./{image_path.stem}_high_quality.gltf"
 
182
  o3d.io.write_triangle_mesh(gltf_path, mesh_crop, write_triangle_uvs=True)
183
 
184
  return gltf_path
 
16
  feature_extractor = DPTFeatureExtractor.from_pretrained("Intel/dpt-large")
17
  model = DPTForDepthEstimation.from_pretrained("Intel/dpt-large")
18
 
 
 
19
  def process_image(image_path, depth_map_path=None):
20
  image_path = Path(image_path)
21
  image_raw = Image.open(image_path).convert("RGB")
 
173
  foreground_pil = Image.fromarray(foreground)
174
  high_res_texture = foreground_pil.resize((4096, 4096), Image.LANCZOS) # Increased resolution for finer details
175
  high_res_texture.save(texture_path)
 
176
 
177
+ # Apply the high-resolution texture and export the mesh as a GLTF file
178
+ mesh_crop.textures = [o3d.geometry.Image(np.array(high_res_texture))]
179
+ gltf_path = f"./{image_path.stem}_model.gltf"
180
  o3d.io.write_triangle_mesh(gltf_path, mesh_crop, write_triangle_uvs=True)
181
 
182
  return gltf_path