Skip to content

Feature/hdf5 integration#20

Merged
NetZissou merged 7 commits into
mainfrom
feature/hdf5_integration
Jul 6, 2026
Merged

Feature/hdf5 integration#20
NetZissou merged 7 commits into
mainfrom
feature/hdf5_integration

Conversation

@NetZissou

Copy link
Copy Markdown
Collaborator

HDF5 dataset support for batch inference

  • Added HDF5ImageDataset class in hdf5_dataset.py, which enables distributed processing of images stored in HDF5 files; supports rank-based and worker-based file partitioning similar to ImageFolderDataset and ParquetImageDataset
  • Registered HDF5ImageDataset in the datasets package's __init__.py and included it in the module exports.

Dataset conversion workflow

Added script wds_to_hdf5 to automate conversion of WebDataset shards to HDF5 format

Dependency updates

  • Added h5py as a required dependency for HDF5 file support and introduced an optional conversion dependency group with webdataset for dataset conversion.
  • Updated the all feature set to include both inference and conversion dependencies.

- added HDF5ImageDataset class to schedule, I/O, and process during
  batch inference
- updated package dependency to include `h5py` pkg
- added scripts to convert webdataset into HDF5 file storage
- added `webdataset` as the optional dependency
@NetZissou NetZissou requested a review from egrace479 November 19, 2025 15:20
@NetZissou NetZissou self-assigned this Nov 19, 2025
@NetZissou NetZissou added the Datasets class Dataset class label Nov 19, 2025
@NetZissou NetZissou linked an issue Nov 19, 2025 that may be closed by this pull request
5 tasks
@egrace479 egrace479 requested a review from thompsonmj November 19, 2025 18:22
@egrace479

Copy link
Copy Markdown
Member

@thompsonmj, a variation on what you have for parquet to HDF5, but instead pulling from webdataset format. Should be merged before #16, which has pulled updates from here.

@NetZissou

Copy link
Copy Markdown
Collaborator Author

@thompsonmj converting this to draft for a while as I'll be working on making HDF5 file available in the batch embed modules.

@NetZissou NetZissou marked this pull request as draft January 14, 2026 15:46
- integrated HDF5 as image data source input option for batch embedding
  scripts
- added SLURM job scripts + configs template for batch embed HDF5 tasks
- modified documentation index page to reflect the HDF5 integration
  update
@NetZissou NetZissou marked this pull request as ready for review January 15, 2026 19:05
NetZissou and others added 2 commits March 30, 2026 17:52
… refs

- Add HDF5ImageDataset to top-level package exports for consistent API
- Add conversion feature check to print_installation_guide()
- Remove references to nonexistent HDF5Writer class in config and SLURM templates
- Replace emoji symbols with plain text in installation guide output

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The conversion tool is a one-time data prep task, not an inference
concern. Removing it keeps the package focused on its core mission
of GPU saturation during inference. HDF5ImageDataset (the inference
input format) is unaffected.

Removed:
- src/hpc_inference/utils/wds_to_hdf5.py
- scripts/conversion/wds_to_hdf5.slurm
- [conversion] optional dependency group (webdataset)
- Conversion feature check from print_installation_guide()
- Conversion references from config/SLURM templates

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@thompsonmj thompsonmj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of quick-inline comments; probably ready for approval afterwards.

Comment on lines +168 to +176
try:
# Decode from bytes
img = Image.open(io.BytesIO(image_bytes))

# Convert to desired color mode
if img.mode != self.color_mode:
img = img.convert(self.color_mode)

# Validate if requested

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good to put this before conversion so when validation is requested it happens before working on the file.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I'll move img.verify() before conversion


class HDF5ImageDataset(IterableDataset):
"""
Loads images from HDF5 files created by HDF5Writer in a streaming fashion.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's HDF5Writer?

@NetZissou NetZissou Mar 31, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been addressed in the recent modifications. No HDF5Writer

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thompsonmj was this comment from previous unsubmitted review? It says it is from today, so I was not sure. But it should be addressed in
a6b4079

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so I think the docstrings just need updated to reflect that it is no longer with us 🪦

"${OUTPUT_DIR}" \
--input_type hdf5 \
--config "${CONFIG_FILE}" \
--file_list "${FILE_LIST}" # [OPTIONAL] Use this if you have a specific list of files to process

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if this is optional, it could be commented out by default (along with FILE_LIST definition above). As-is, I think it will require a user to comment out manually or else "/path/to/your/file_list.txt" will be passed to open_clip_embed.py causing an error.

Relatedly, looks like this is in open_clip_embed_parquet_template.slurm as well here.

help="Type of input data: 'images' for image directory, 'parquet' for Parquet files, 'hdf5' for HDF5 files")
parser.add_argument("--config", type=str, default=None, help="Path to YAML config file (optional)")
parser.add_argument("--file_list", type=str, default=None,
help="File containing list of Parquet files to process (only for --input_type parquet)")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update file types similarly to the above help strings.

@egrace479 egrace479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One suggestion for documentation

Comment thread docs/index.md Outdated
NetZissou and others added 2 commits March 31, 2026 14:49
- Move image validation before color conversion in HDF5ImageDataset
  so corrupted data is caught early (thompsonmj)
- Comment out optional --file_list in HDF5 and Parquet SLURM templates
  to prevent placeholder path errors (thompsonmj)
- Update --file_list help string to include HDF5 file types (thompsonmj)
- Make templates a linkable header in docs/index.md (egrace479)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@NetZissou NetZissou requested a review from thompsonmj April 1, 2026 13:37
@NetZissou NetZissou merged commit 84f14d0 into main Jul 6, 2026
@NetZissou NetZissou deleted the feature/hdf5_integration branch July 6, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Datasets class Dataset class

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add WebP Image Dataset Support for HDF5 Storage Format

3 participants