Views
No views yet
1git clone https://github.com/yyfz/Pi3.git
2cd Pi3
3pip install -r requirements.txt--ckpt argument.1# Run with default example video
2python example.py
3
4# Run on your own data (image folder or .mp4 file)
5python example.py --data_path <path/to/your/images_dir_or_video.mp4>--data_path: Path to the input image directory or a video file. (Default: examples/skating.mp4)--save_path: Path to save the output .ply point cloud. (Default: examples/result.ply)--interval: Frame sampling interval. (Default: 1 for images, 10 for video)--ckpt: Path to a custom model checkpoint file.--device: Device to run inference on. (Default: cuda)1# Install demo-specific requirements
2pip install -r requirements_demo.txt
3
4# Launch the demo
5python demo_gradio.pytorch.Tensor of shape $B \times N \times 3 \times H \times W$ with pixel values in the range [0, 1].dict with the following keys:
points: Global point cloud unprojected by local points and camera_poses (torch.Tensor, $B \times N \times H \times W \times 3$).local_points: Per-view local point maps (torch.Tensor, $B \times N \times H \times W \times 3$).conf: Confidence scores for local points (values in [0, 1], higher is better) (torch.Tensor, $B \times N \times H \times W \times 1$).camera_poses: Camera-to-world transformation matrices (4x4 in OpenCV format) (torch.Tensor, $B \times N \times 4 \times 4$).1import torch
2from pi3.models.pi3 import Pi3
3from pi3.utils.basic import load_images_as_tensor # Assuming you have a helper function
4
5# --- Setup ---
6device = 'cuda' if torch.cuda.is_available() else 'cpu'
7model = Pi3.from_pretrained("yyfz233/Pi3").to(device).eval()
8# or download checkpoints from `https://huggingface.co/yyfz233/Pi3/resolve/main/model.safetensors`
9
10# --- Load Data ---
11# Load a sequence of N images into a tensor
12# imgs shape: (N, 3, H, W).
13# imgs value: [0, 1]
14imgs = load_images_as_tensor('examples/skating.mp4', interval=10).to(device)
15
16# --- Inference ---
17print("Running model inference...")
18# Use mixed precision for better performance on compatible GPUs
19dtype = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[0] >= 8 else torch.float16
20
21with torch.no_grad():
22 with torch.amp.autocast('cuda', dtype=dtype):
23 # Add a batch dimension -> (1, N, 3, H, W)
24 results = model(imgs[None])
25
26print("Reconstruction complete!")
27# Access outputs: results['points'], results['camera_poses'] and results['local_points'].1@misc{wang2025pi3,
2 title={$\\pi^3$: Scalable Permutation-Equivariant Visual Geometry Learning},
3 author={Yifan Wang and Jianjun Zhou and Haoyi Zhu and Wenzheng Chang and Yang Zhou and Zizun Li and Junyi Chen and Jiangmiao Pang and Chunhua Shen and Tong He},
4 year={2025},
5 eprint={2507.13347},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2507.13347},
9}