Downloads · 30 days
0
c1tr0n75/VoxelPathFinder
VoxelPathFinder is a other model from c1tr0n75. Use it for the other task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
This repository hosts the weights and code for a neural network that plans paths in a 3D voxel grid (32×32×32). The model encodes the voxelized environment (obstacles + start + goal) with a 3D CNN, fuses learned posit…
Downloads · 30 days
0
Access
Public
Updated Aug 10, 2025
Repo size
110 MB
Likes
0
Public
Click a slice to open those files.
.pth110 MB · 100%
From the Hugging Face model README
This repository hosts the weights and code for a neural network that plans paths in a 3D voxel grid (32×32×32). The model encodes the voxelized environment (obstacles + start + goal) with a 3D CNN, fuses learned position embeddings, and autoregressively generates a sequence of movement actions with a Transformer decoder.
voxel_data: float tensor of shape [1, 3, 32, 32, 32]positions: long tensor of shape [1, 2, 3][[start_xyz, goal_xyz]] with each coordinate in [0, 31][1, T] of action IDs (0..5), padded internally with END if neededMake sure this repo includes both final_model.pth (or model_state_dict) and pathfinding_nn.py.
import torch, numpy as np
from huggingface_hub import hf_hub_download
import importlib.util, sys
REPO_ID = "c1tr0n75/VoxelPathFinder"
# Download files from the Hub
pth_path = hf_hub_download(repo_id=REPO_ID, filename="final_model.pth")
py_path = hf_hub_download(repo_id=REPO_ID, filename="pathfinding_nn.py")
# Dynamically import the model code
spec = importlib.util.spec_from_file_location("pathfinding_nn", py_path)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
PathfindingNetwork = mod.PathfindingNetwork
create_voxel_input = mod.create_voxel_input
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model = PathfindingNetwork().to(device).eval()
# Load weights (supports either a plain state_dict or {'model_state_dict': ...})
ckpt = torch.load(pth_path, map_location=device)
state = ckpt["model_state_dict"] if isinstance(ckpt, dict) and "model_state_dict" in ckpt else ckpt
model.load_state_dict(state)
# Build a random test environment
voxel_dim = model.voxel_dim # (32, 32, 32)
D, H, W = voxel_dim
obstacle_prob = 0.2
obstacles = (np.random.rand(D, H, W) < obstacle_prob).astype(np.float32)
free = np.argwhere(obstacles == 0)
assert len(free) >= 2, "Not enough free cells; lower obstacle_prob"
s_idx, g_idx = np.random.choice(len(free), size=2, replace=False)
start = tuple(free[s_idx])
goal = tuple(free[g_idx])
voxel_np = create_voxel_input(obstacles, start, goal, voxel_dim=voxel_dim) # (3,32,32,32)
voxel = torch.from_numpy(voxel_np).float().unsqueeze(0).to(device) # (1,3,32,32,32)
pos = torch.tensor([[start, goal]], dtype=torch.long, device=device) # (1,2,3)
with torch.no_grad():
actions = model(voxel, pos)[0].tolist()
ACTION_NAMES = ['FORWARD', 'BACK', 'LEFT', 'RIGHT', 'UP', 'DOWN']
decoded = [ACTION_NAMES[a] for a in actions if 0 <= a < 6]
print(f"Start: {start} | Goal: {goal}")
print(f"Generated {len(decoded)} steps (first 30): {decoded[:30]}")
If you use this model, please cite this repository: