ByteDance-Seed / ByteDance-Seed/Depth-Anything-3
Point Cloud Stitching Works Well but 3DGS Results Are Poor with Same Samples
- Dominant language
- Python
- Stars
- 6.3k
- Forks
- 702
- PR merge metrics
- No merged PRs in 30d
Description
Hi team,
I'm experiencing inconsistent results when using depth predictions from DepthAnything3 for different 3D reconstruction tasks. Using the same set of samples, I'm getting good results with point cloud stitching but poor results with 3D Gaussian Splatting (3DGS).
**Environment:**
- Hardware: A100
- Dataset: Custom indoor scene dataset (38 images)
**Issue Details:**
When I use the depth maps generated by DepthAnything3:
- **Point cloud stitching**: Results are visually good with proper alignment and structure
- **3D Gaussian Splatting**: Results are significantly worse:
**Questions:**
1. Are there any recommended preprocessing steps or parameter adjustments specifically for 3DGS applications?
2. Could this be related to depth scale/metric accuracy issues that affect 3DGS more than point cloud methods?
3. Are there any known best practices for using DepthAnything3 depth maps with 3DGS?
**Code:**
```python
# point cloud stitching code
model = DepthAnything3.from_pretrained("./DA3-LARG")
model = model.to(device=device)
example_path = "/data/zhw/Depth-Anything-3/assets/examples/zed_img1_left_images/"
images = sorted(glob.glob(os.path.join(example_path, "*.png")))
prediction = model.inference(
images,
)
# ...
for i in range(N):
print(f"处理第 {i+1}/{N} 帧...")
depth = prediction.depth[i]
conf = prediction.conf[i]
K = prediction.intrinsics[i]
W2C = prediction.extrinsics[i]
rgb = prediction.processed_images[i] # [H, W, 3]
H, W = depth.shape
# 过滤低置信度和无效深度的点
# 如果要保存所有置信度的点,将 use_conf_filter 设为 False
use_conf_filter = False # 设为 False 保存所有置信度的点,设为 True 使用置信度过滤
if use_conf_filter:
conf_threshold = np.percentile(conf, 10) # 保留置信度前90%的点
valid_mask = (conf > conf_threshold) & (depth > 0)
else:
# 只过滤无效深度,保留所有置信度的点
valid_mask = (depth > 0)
# 为了减少点数,进行下采样
downsample_step = 2 # 每2个像素采样一个(增加采样密度)
v_grid, u_grid = np.meshgrid(
np.arange(0, H, downsample_step),
np.arange(0, W, downsample_step),
indexing='ij'
)
sample_mask = valid_mask[v_grid, u_grid]
u_valid = u_grid[sample_mask]
v_valid = v_grid[sample_mask]
# 反投影到相机坐标系
K_inv = np.linalg.inv(K)
pixels = np.stack([u_valid, v_valid, np.ones_like(u_valid)], axis=0) # [3, N]
depths_valid = depth[v_valid, u_valid] # [N]
X_cam = (K_inv @ pixels) * depths_valid # [3, N]
X_cam_homo = np.vstack([X_cam, np.ones((1, len(u_valid)))]) # [4, N]
# 变换到世界坐标系
W2C_homo = np.vstack([W2C, [0, 0, 0, 1]])
C2W = np.linalg.inv(W2C_homo)
X_world_homo = C2W @ X_cam_homo # [4, N]
X_world = X_world_homo[:3, :].T # [N, 3]
# 获取颜色
colors = rgb[v_valid, u_valid] # [N, 3]
all_points.append(X_world)
all_colors.append(colors)
print(f" 提取了 {len(X_world)} 个点")
# 合并所有点云
all_points = np.vstack(all_points) # [Total, 3]
all_colors = np.vstack(all_colors) # [Total, 3]
print(f"\n总共生成 {len(all_points)} 个3D点")
# 保存为PLY格式
ply_path = "merged_pointcloud.ply"
print(f"保存点云到: {ply_path}")
```
```python
#3DGS code
print("\n[1/4] 加载模型...")
model = DepthAnything3.from_pretrained(model_path)
model = model.to(device=device)
print(f"✅ 模型加载成功: {model_path}")
# 2. 加载图像
print("\n[2/4] 加载图像...")
all_images = sorted(glob.glob(image_path + "*.png"))
# 建议:至少 5-10 张图像,可以调整这个数字
num_images = min(100, len(all_images)) # 使用前10张(或全部如果不足10张)
images = all_images[:num_images]
print(f"✅ 加载了 {len(images)} 张图像(共 {len(all_images)} 张可用)")
for i, img in enumerate(images):
print(f" - 图像 {i}: {img.split('/')[-1]}")
# 3. 推理(生成 GS)
print("\n[3/4] 运行前馈 GS 推理...")
print("⏳ 正在预测深度 + 姿态 + 高斯参数...")
try:
prediction = model.inference(
images,
infer_gs=True, # 🔥 关键参数:启用 GS 预测
# infer_depth=True, # 默认开启
# infer_camera=True, # 默认开启
)
# ...
save_gaussian_ply(
gaussians=gs_world,
save_path=os.path.join(improved_output_dir, "gs_ply/0000_no_filter.ply"),
ctx_depth=pred_depth,
shift_and_scale=True, # 启用坐标归一化
save_sh_dc_only=True,
gs_views_interval=1,
inv_opacity=True,
prune_by_depth_percent=1.0, # 🔥 完全禁用深度过滤
prune_border_gs=False, # 🔥 禁用边界过滤
match_3dgs_mcmc_dev=False,
)
# ...
```
Any guidance or suggestions would be greatly appreciated!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.