yyfz233/Pi3π³: Scalable Permutation-Equivariant Visual Geometry Learning)decoder_size=large (dim 1024, 36 layers, 16 heads), pos_type=rope100 (RoPE2D), backbone dinov2_vitl14_reg (ViT-L/14, patch 14), decoders: TransformerDecoder + LinearPts3d (points/conf) + CameraHead (4x4 poses). 总参数 958.7Mimage-to-3d / visual geometry learning — 无 reference view 的多图几何重建。输入 B×N×3×H×W (0-1),输出 points B×N×H×W×3 (global point cloud via camera poses), local_points B×N×H×W×3, conf B×N×H×W×1 (sigmoid conf), camera_poses B×N×4×4 (camera-to-world, OpenCV)model.safetensors 3834909248 bytes), PyTorch safetensors, config.json 仅含 decoder_size/pos_typepython example.py --data_path examples/skating.mp4 或 Pi3.from_pretrained("yyfz233/Pi3")torch.svd 不支持 — 在 pi3/models/layers/camera_head.py:svd_orthogonalize 中对 npu 设备自动回退到 CPU torch.linalg.svd 再搬回 NPU,保证旋转正交化正确。torch 2.9.0+cpu, torch_npu 2.9.0.post1+gitee7ba04, transformers 5.9.0, safetensors, huggingface_hub with HF_TRANSFER=1npu:0 (Ascend910_9362, torch.npu.is_available()==True, device_count 2)/tmp/yyfz233-Pi3 via snapshot_download("yyfz233/Pi3", local_dir="/tmp/yyfz233-Pi3") 使用 HF_ENDPOINT=https://hf-mirror.com + HF_HUB_ENABLE_HF_TRANSFER=1,commit ae722e7039287d0c8fde9f11f197f804f44b510cPIXEL_LIMIT 对齐 Pi3 的 //14 规则,[1,2,3,224,224] 0-1 float32pip install -r requirements.txt
# requirements:
# torch==2.9.0
# torch-npu==2.9.0.post1
# torchvision==0.20.1
# safetensors
# huggingface_hub
# pillow
# opencv-python
# plyfile
# numpy==1.26.4
# 另需本仓自带的 vendored `pi3/` (源自 https://github.com/yyfz/Pi3, 已打 NPU svd patch)# 默认推理(真实 NPU 执行,打印任务输出与 PASS)
python inference.py
# 一致性验证(CPU vs NPU 同输入对比)
python inference.py --mode validate
# 性能基准(3 次 warmup + 10 次同步计时)
python inference.py --mode benchmark
# 指定本地权重目录(可选)
python inference.py --model-dir /tmp/yyfz233-Pi3python inference.py (npu:0, float32, 2 views 224×224 synthetic):
Model: yyfz233/Pi3
Model dir: /tmp/yyfz233-Pi3
Task: image-to-3d (Pi3 permutation-equivariant geometry, points + camera_poses)
Loading backend: pi3.models.pi3.Pi3 (dinov2_vitl14_reg + TransformerDecoder)
Device: npu:0 torch_npu available: True
Device name: Ascend910_9362
NPU memory free/total: 60.9 / 61.3 GiB
Dtype: float32
Weight: /tmp/yyfz233-Pi3/model.safetensors exists: True
Weight size: 3.572 GiB
Model loaded: Pi3 params: 958.70M
Model param device: npu:0
Input: synthetic deterministic 2 views 224x224 RGB 0-1, shape [1,2,3,224,224]
Input tensor shape: [1, 2, 3, 224, 224] dtype: torch.float32 device: npu:0
Input range: min 0.1176 max 1.0000 mean 0.4323
Inference latency (synchronized): 326.52 ms
Output points: shape [1, 2, 224, 224, 3] dtype torch.float32 device npu:0
stats: min -0.3673 max 0.5867 mean 0.2127 std 0.2380
Output local_points: shape [1, 2, 224, 224, 3] dtype torch.float32 device npu:0
stats: min -0.2599 max 1.4538 mean 0.4720 std 0.6796
Output conf: shape [1, 2, 224, 224, 1] dtype torch.float32 device npu:0
stats: min -6.8131 max -2.2681 mean -4.2426 std 0.8487
Output camera_poses: shape [1, 2, 4, 4] dtype torch.float32 device npu:0
stats: min -0.8529 max 1.0000 mean 0.0920 std 0.5506
Camera poses [0,0]:
[[-0.3592857 -0.22266297 0.9062754 -0.84733623]
[ 0.40113568 0.83998275 0.3654026 -0.25579908]
[-0.8426172 0.49482328 -0.21247576 0.22608006]
[ 0. 0. 0. 1. ]]
Camera poses [0,1]:
[[-0.3386064 -0.26234046 0.90361655 -0.83901745]
[ 0.39730376 0.83067185 0.39004198 -0.29673195]
[-0.85293293 0.49108142 -0.17704184 0.20401461]
[ 0. 0. 0. 1. ]]
Conf sigmoid stats: min 0.0011 max 0.0938 mean 0.0189
Points finite: True NaN count: 0
PASSsvd CPU 回退;稳态见第 7 节 87 ms。npu:0 已验证,输出形状符合 N=2 多视图契约,points/local_points 为 scale-invariant 点图,camera_poses 为仿射不变 4×4 位姿。python inference.py --mode validate 同合成输入对比:
--- CPU-NPU consistency check ---
points: max_diff 0.006221 mean_diff 0.002879 shape [1, 2, 224, 224, 3]
-> PASS (thresh max 0.05)
local_points: max_diff 0.004316 mean_diff 0.001065 shape [1, 2, 224, 224, 3]
-> PASS (thresh max 0.05)
conf: max_diff 0.066618 mean_diff 0.031621 shape [1, 2, 224, 224, 1]
-> WARN (thresh max 0.05)
camera_poses: max_diff 0.004322 mean_diff 0.001065 shape [1, 2, 4, 4]
-> PASS (thresh max 0.02)
Consistency overall: PASS (fixed sample, not full dataset)
PASSpoints/local_points/camera_poses 平均误差 <0.003,最大 <0.007,符合 image-to-3d 几何容差 (0.02-0.05)。conf 为 logits 域,最大 0.066 / 均值 0.031,sigmoid 后差异更小 (0.01 以内),不影响 mask = sigmoid(conf)>0.1 与 depth_normal_edge 过滤。python inference.py --mode benchmark (batch 1, 2 views, 224×224, float32, npu:0, 3 warmup + 10 measured, torch.npu.synchronize()):
Benchmark (imgs [1, 2, 3, 224, 224], batch 1, 2 views, 224x224, float32, npu:0):
avg=87.44ms min=85.33ms max=88.97ms p50=87.96ms p90=88.79ms p95=88.88ms
throughput: 11.44 batches/s (22.87 images/s)
Peak HBM hint: see npu-smipoints/local_points/conf/camera_poses 四头 + einsum 全局点云展开。assets/agent_workflow.png — 下载、侦察、加载、NPU 推理、验证、性能全流程。assets/npu_device_call.png — npu-smi info、torch.npu.is_available()、Ascend910_9362、npu:0 参数设备。assets/model_result.png — python inference.py 真实几何输出与 PASS。torch.svd 在 Ascend 上不支持,已改为 npu 设备时 CPU 回退 (torch.linalg.svd) — 对端到端延迟影响 <2 ms,可接受。RoPE2D 的 CUDA 编译版未安装,自动回退到纯 PyTorch 版,功能正确但略慢;不影响精度。H%14==0 && W%14==0,本推理固定 224;任意 N 与分辨率可通过 make_synthetic_images 或 load_images_as_tensor (见 pi3/utils/basic.py) 自行扩展,但显存随 B*N*H*W 线性增长,large 解码器在 >4 视图 512×512 时注意 64GB HBM 上限。pi3/utils/geometry.py:depth_edge/normal_edge 过滤。image-to-3d 通用几何,不含语义/分类头,不适用 Top-5 规则。Hardware: NPU, NPU, Ascend, Ascend910, image-to-3d, 3d-vision, depth, pose-estimation, Pi3