Spaces:
Sleeping
Sleeping
Dheepak Karan
Align the demo with what actually ships, and pull model code from the main repo
c8f05dd Download data/scripts/sample_loader.py from dheepakkaran/multi-camera-bev: direct link, hf CLI and curl.
- Browser
- Download file 2.53 kB
-
https://huggingface.co/spaces/dheepakkaran/multi-camera-bev/resolve/main/data/scripts/sample_loader.py
- Command line
-
hf download hf://spaces/dheepakkaran/multi-camera-bev/data/scripts/sample_loader.py
-
curl -L -o sample_loader.py https://huggingface.co/spaces/dheepakkaran/multi-camera-bev/resolve/main/data/scripts/sample_loader.py
2.53 kB
| # ============================================================ | |
| # sample_loader.py | |
| # ============================================================ | |
| # | |
| # ETHUKU CREATE PANNINOM? | |
| # ββββββββββββββββββββββ | |
| # Oru "sample" = oru nodi-la (timestamp) 6 camera-vum eduthu photo. | |
| # camera_loader oru camera-va mattum handle pannum. | |
| # Ithu antha 6-ai stack panni ORE tensor-a thara. | |
| # | |
| # MUNADI FILE ODA CONNECTION: | |
| # ββββββββββββββββββββββββββ | |
| # camera_loader.load_camera() -> 6 thadava call | |
| # dataset.py ithai __getitem__-la koopidum. | |
| # | |
| # INNER OPERATIONS: | |
| # ββββββββββββββββ | |
| # CAMERAS list order-la loop -> 6 dict -> torch.stack -> batch dim add. | |
| # | |
| # INPUT / OUTPUT: | |
| # ββββββββββββββ | |
| # Input : nusc, sample_token | |
| # Output: {"images":[6,3,224,400], "intrinsics":[6,3,3], | |
| # "extrinsics":[6,4,4], "sample_token": str} | |
| # | |
| # EPADI USE AAGUM: | |
| # βββββββββββββββ | |
| # Model 6 camera-vum ore neram paakkanum (surround view). | |
| # Antha 6-ai ore tensor-a kudukka ithu thevai. | |
| # | |
| # ============================================================ | |
| import torch | |
| from .camera_loader import load_camera | |
| from .constants import CAMERAS | |
| def load_sample(nusc, sample_token: str, data_root: str) -> dict: | |
| """ | |
| Oru sample-oda 6 camera data-vum load panni stack pannurathu. | |
| Args: | |
| nusc: NuScenes object | |
| sample_token: sample-oda unique id | |
| data_root: dataset folder | |
| Returns: | |
| dict of stacked tensors (mela sonna shapes) | |
| """ | |
| sample = nusc.get("sample", sample_token) | |
| images, intrinsics, extrinsics = [], [], [] | |
| # CAMERAS order MUKIYAM - ellaa sample-layum ore order irukkanum, | |
| # illaina model "front camera" nu nenachi back photo paakkum. | |
| for cam_name in CAMERAS: | |
| sd_token = sample["data"][cam_name] # antha camera-oda photo id | |
| cam = load_camera(nusc, sd_token, data_root) | |
| images.append(cam["image"]) # [3,224,400] | |
| intrinsics.append(cam["intrinsic"]) # [3,3] | |
| extrinsics.append(cam["extrinsic"]) # [4,4] | |
| # stack = pudhu dimension add pannurathu (list of 6 -> tensor with 6) | |
| return { | |
| "images": torch.stack(images, dim=0), # [6,3,224,400] | |
| "intrinsics": torch.stack(intrinsics, dim=0), # [6,3,3] | |
| "extrinsics": torch.stack(extrinsics, dim=0), # [6,4,4] | |
| "sample_token": sample_token, | |
| } | |