Views
No views yet
1from pathlib import Path
2import torch
3import os
4import sys
5sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
6
7from src.misc.image_io import save_interpolated_video
8from src.model.model.anysplat import AnySplat
9from src.utils.image import process_image
10
11# Load the model from Hugging Face
12model = AnySplat.from_pretrained("anysplat_ckpt_v1")
13device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14model = model.to(device)
15model.eval()
16for param in model.parameters():
17 param.requires_grad = False
18
19# Load and preprocess example images (replace with your own image paths)
20image_names = ["path/to/imageA.png", "path/to/imageB.png", "path/to/imageC.png"]
21images = [process_image(image_name) for image_name in image_names]
22images = torch.stack(images, dim=0).unsqueeze(0).to(device) # [1, K, 3, 448, 448]
23b, v, _, h, w = images.shape
24
25# Run Inference
26gaussians, pred_context_pose = model.inference((images+1)*0.5)
27
28pred_all_extrinsic = pred_context_pose['extrinsic']
29pred_all_intrinsic = pred_context_pose['intrinsic']
30save_interpolated_video(pred_all_extrinsic, pred_all_intrinsic, b, h, w, gaussians, image_folder, model.decoder)
31@article{jiang2025anysplat,
title={AnySplat: Feed-forward 3D Gaussian Splatting from Unconstrained Views},
author={Jiang, Lihan and Mao, Yucheng and Xu, Linning and Lu, Tao and Ren, Kerui and Jin, Yichen and Xu, Xudong and Yu, Mulin and Pang, Jiangmiao and Zhao, Feng and others},
journal={arXiv preprint arXiv:2505.23716},
year={2025}
}