Views
No views yet
1import torch
2from pi3.models.pi3x import Pi3X # new version (Recommended)
3from pi3.utils.basic import load_images_as_tensor
4
5# --- Setup ---
6device = 'cuda' if torch.cuda.is_available() else 'cpu'
7model = Pi3X.from_pretrained("yyfz233/Pi3X").to(device).eval()
8
9# --- Load Data ---
10# Load a sequence of N images into a tensor (N, 3, H, W)
11# pixel values in the range [0, 1]
12imgs = load_images_as_tensor('path/to/your/data', interval=10).to(device)
13
14# --- Inference ---
15print("Running model inference...")
16# Use mixed precision for better performance on compatible GPUs
17dtype = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[0] >= 8 else torch.float16
18
19with torch.no_grad():
20 with torch.amp.autocast('cuda', dtype=dtype):
21 # Add a batch dimension -> (1, N, 3, H, W)
22 results = model(imgs[None])
23
24print("Reconstruction complete!")
25# Access outputs: results['points'], results['camera_poses'] and results['local_points'].1@article{wang2025pi,
2 title={$\pi^3$: Permutation-Equivariant Visual Geometry Learning},
3 author={Wang, Yifan and Zhou, Jianjun and Zhu, Haoyi and Chang, Wenzheng and Zhou, Yang and Li, Zizun and Chen, Junyi and Pang, Jiangmiao and Shen, Chunhua and He, Tong},
4 journal={arXiv preprint arXiv:2507.13347},
5 year={2025}
6}