Skip to content

Fix HuggingFaceDataLoader mask casting for point cloud datasets - #88

Merged
js2552 merged 1 commit into
mainfrom
feature/point_cloud_loader
Sep 12, 2026
Merged

js2552 merged 1 commit into
mainfrom
feature/point_cloud_loader

Conversation

@bharathsri272

Copy link
Copy Markdown
Contributor

Fix HuggingFaceDataLoader to support point cloud mask columns

What

_cast_single in agml/data/hf_loader.py unconditionally cast any mask column to Image(), assuming masks are always pixel maps. Point cloud datasets (e.g. Project-AgML/pheno4d_point_cloud_segmentation) store mask as Array2D (per-point label arrays), since there's no image to draw a pixel mask onto for 3D data. The unconditional cast broke loading for these datasets.

Fix

Only cast mask to Image() when it isn't already Image or Array2D. No changes needed for object detection, objects isn't handled specially in this file, so point cloud detection datasets already pass through unaffected.

Tested against the real, live dataset

from agml.data.hf_loader import HuggingFaceDataLoader
loader = HuggingFaceDataLoader("Project-AgML/pheno4d_point_cloud_segmentation", "raw")
row = loader.dataset["train"][0]
print(type(row["mask"]))  # <class 'list'>, not PIL.Image

Confirmed mask comes back as its correct raw nested-list form (convertible via np.array()), not miscast into an image, no data loss or corruption.

_cast_single previously cast any "mask" column to Image() unconditionally,
assuming masks are always pixel maps. Point cloud datasets store mask as
Array2D (per-point labels) instead, since there's no image to draw a mask
onto. Only cast to Image() when the column isn't already Image or Array2D.

Tested against Project-AgML/pheno4d_point_cloud_segmentation: mask now
loads correctly as a list instead of being miscast into an image.
@bharathsri272
bharathsri272 requested a review from js2552 September 9, 2026 23:27
@js2552
js2552 merged commit 77aa062 into main Sep 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants