qian43 commited on
Commit
b54fae8
·
verified ·
1 Parent(s): 35fe63c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -16,7 +16,6 @@ from typing import List, Optional, Tuple
16
  import cv2
17
  import gradio as gr
18
  import numpy as np
19
- import open3d as o3d
20
  import torch
21
  import torchvision.transforms as T
22
  import trimesh
@@ -102,11 +101,12 @@ def load_model(checkpoint_path: str = "checkpoints"):
102
  def save_obj(vertices: np.ndarray, faces: np.ndarray, colors: np.ndarray, filepath: str):
103
  vertices = vertices @ np.array([[1, 0, 0], [0, 1, 0], [0, 0, -1]])
104
  faces = faces[:, [2, 1, 0]]
105
- mesh = o3d.geometry.TriangleMesh()
106
- mesh.vertices = o3d.utility.Vector3dVector(vertices)
107
- mesh.triangles = o3d.utility.Vector3iVector(faces)
108
- mesh.vertex_colors = o3d.utility.Vector3dVector(colors / 255.0)
109
- o3d.io.write_triangle_mesh(filepath, mesh, write_vertex_normals=False)
 
110
 
111
 
112
  def position_to_c2w(position: Tuple[float, float, float]) -> torch.Tensor:
@@ -495,7 +495,7 @@ def build_demo():
495
  Upload a satellite image to **generate a 3D mesh** or **render a walkthrough video**.
496
 
497
  📌 **Input requirements:** The satellite image should be at **zoom level 20**
498
- (same as the [VIGOR](https://github.com/Jeff-Zilence/VIGOR) dataset), resized to **512×512** pixels.
499
  You can download satellite tiles at this zoom level from any map tile API (e.g. Google Maps, Bing Maps, Mapbox).
500
  """
501
  )
 
16
  import cv2
17
  import gradio as gr
18
  import numpy as np
 
19
  import torch
20
  import torchvision.transforms as T
21
  import trimesh
 
101
  def save_obj(vertices: np.ndarray, faces: np.ndarray, colors: np.ndarray, filepath: str):
102
  vertices = vertices @ np.array([[1, 0, 0], [0, 1, 0], [0, 0, -1]])
103
  faces = faces[:, [2, 1, 0]]
104
+ mesh = trimesh.Trimesh(
105
+ vertices=vertices,
106
+ faces=faces,
107
+ vertex_colors=colors.astype(np.uint8),
108
+ )
109
+ mesh.export(filepath)
110
 
111
 
112
  def position_to_c2w(position: Tuple[float, float, float]) -> torch.Tensor:
 
495
  Upload a satellite image to **generate a 3D mesh** or **render a walkthrough video**.
496
 
497
  📌 **Input requirements:** The satellite image should be at **zoom level 20**
498
+ (same as the [VIGOR](https://github.com/Jeff-Zilence/VIGOR) dataset), then will be resized to the input size.
499
  You can download satellite tiles at this zoom level from any map tile API (e.g. Google Maps, Bing Maps, Mapbox).
500
  """
501
  )