Skip to content

Conversation

@perctrix
Copy link
Contributor

This pull request introduces enhancements to the region-of-interest (ROI) sampling logic for inspection datasets, focusing on foreground-aware patch selection and more flexible sampling strategies. The changes add foreground sample tracking to annotations, allow random and foreground-guided ROI cropping, and provide configurable oversampling of foreground regions in the ROIDataset.

ROI sampling and annotation improvements:

  • Added a foreground_samples attribute to the InspectionAnnotation class to store sampled foreground pixel locations for each annotation, enabling foreground-guided ROI selection.
  • Implemented new methods random_roi and foreground_guided_random_roi in InspectionAnnotations to support random and foreground-aware ROI cropping, and updated crop_roi to optionally use these strategies based on new parameters.

Inspection and dataset construction enhancements:

  • Updated the inspect function to sample and store foreground pixel indices for each annotation, with configurable minimum/maximum samples and percent coverage, improving downstream patch selection.
  • Modified the ROIDataset class to accept parameters for random patch sampling and foreground oversampling, and updated the load method to use these options for more flexible ROI extraction. [1] [2]

fixed #82

@ATATC ATATC changed the title Feature/random patch sampling Add random and foreground oversampling in ROIDataset Oct 23, 2025
@ATATC ATATC self-requested a review October 23, 2025 17:38
@ATATC ATATC added enhancement New feature or request todo New task or assignment labels Oct 23, 2025
@ATATC ATATC added this to the 1.1.0 milestone Oct 23, 2025
@ATATC
Copy link
Contributor

ATATC commented Nov 5, 2025

Maybe make it modular, don't integrate into the existing code.

@perctrix
Copy link
Contributor Author

perctrix commented Nov 5, 2025

You mean leave this part in the mipcandy-bundles?

@ATATC
Copy link
Contributor

ATATC commented Nov 11, 2025

#82 (comment) Make it a child class inheriting from ROIDataset.

- Merged latest changes from main (19 commits)
- Fixed save() to use to_dict() for proper JSON serialization
- Added Tensor to list conversion in serialization/deserialization
- Preserved random patch sampling features
- Merged latest changes from main
- Fixed Tensor serialization in save/load methods
- Created RandomROIDataset as child class of ROIDataset
- Moved all random sampling logic into the subclass
- Kept ROIDataset and InspectionAnnotations minimal and clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request todo New task or assignment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add random and foreground oversampling in ROIDataset

2 participants