File size: 3,158 Bytes
2ba4050
 
e7c6d97
 
 
 
 
 
 
 
 
 
 
 
 
2ba4050
e7c6d97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cb01dac
 
e7c6d97
3ac01a8
 
 
e91244b
 
 
 
 
3ac01a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
license: mit
language:
- en
tags:
- robotics
- motion-planning
- segmentation
- unet
- topological-traps
- viability-prediction
- non-holonomic
pipeline_tag: image-segmentation
datasets:
- DanielDDDs/topological-traps-dataset
---

# Neural Prediction of Heading-Dependent Topological Traps

**TAU Algorithmic Robotics - Fall 2025/2026 - Daniel Simanovsky**

A U-Net model that predicts directional viability maps for non-holonomic robot navigation:
given a 2D occupancy grid and robot dimensions, the model outputs four binary masks (N/S/E/W)
indicating which pixels are topological traps - cells the robot can enter but cannot escape
by translating in that heading without first rotating.

## Models in this repo

| File | Description | Val IoU |
|---|---|---|
| `models/viability_cardinal_best_iou.pth` | Cardinal model - 3-ch input, 4-ch binary output (N/S/E/W) | 0.9793 |
| `models/viability_continuous_angle_best_iou.pth` | Angle model - 5-ch input (sin/cos theta), 1-ch arbitrary heading | 0.984 |
| `configs/training_config.yaml` | Training configuration | - |

## Architecture

- Backbone: U-Net with ResNet34 encoder (ImageNet pre-trained), ~24.5M parameters
- Input: 3-channel tensor - binary occupancy grid + normalised robot L/512, W/512
- Output: 4-channel sigmoid map, one per cardinal direction
- Training: AdamW (lr=1e-4, wd=1e-4), CosineAnnealingLR, BCE+Dice loss, FP16, batch 16, 50 epochs

## Results

| Metric | Value |
|---|---|
| IoU (seen sizes) | 0.978 |
| IoU (unseen size 25x18) | 0.953 |
| Generalisation gap | 0.025 |
| Inference time | 8.8 ms/map (GPU) |
| Oracle speedup | 21.5x |
| PRM trap reduction | 81% |

## Quick start

```python
import torch, numpy as np
from huggingface_hub import hf_hub_download
import segmentation_models_pytorch as smp

ckpt_path = hf_hub_download(
    repo_id="DanielDDDs/topological-traps",
    filename="models/viability_cardinal_best_iou.pth"
)
model = smp.Unet(encoder_name="resnet34", encoder_weights=None, in_channels=3, classes=4)
state = torch.load(ckpt_path, map_location="cpu")
model.load_state_dict(state["model_state_dict"])
model.eval()

def predict(occupancy, robot_L=30, robot_W=20):
    x = np.zeros((1, 3, 512, 512), dtype=np.float32)
    x[0, 0] = occupancy
    x[0, 1] = robot_L / 512.0
    x[0, 2] = robot_W / 512.0
    with torch.no_grad():
        out = torch.sigmoid(model(torch.from_numpy(x)))
    return out[0].numpy()  # (4, 512, 512) N/S/E/W viability

viability = predict(occupancy_grid)
north_viable = viability[0] > 0.5
```

## Dataset

Full processed maps and Oracle labels: [DanielDDDs/topological-traps-dataset](https://huggingface.co/datasets/DanielDDDs/topological-traps-dataset)

## Code

[github.com/danielsddd/topological-traps-project](https://github.com/danielsddd/topological-traps-project)

## Compute

TAU CS SLURM cluster:
- NVIDIA TITAN Xp (12 GB)  
- NVIDIA GeForce RTX 2080 (8 GB) 

If you use this model in your research, please cite it as follows:

```bibtex
@misc{simanovsky2026neural,
  author = {Daniel Simanovsky},
  title  = {Neural Prediction of Heading-Dependent Topological Traps},
  year   = {2026},
  school = {Tel Aviv University},
}