Datasets:
ArXiv:
License:
| license: cc-by-4.0 | |
| task_categories: | |
| - image-classification | |
| tags: | |
| - medical | |
| - pathology | |
| - whole-slide-imaging | |
| - cancer-detection | |
| # CPath Preprocessed Patch for E2E Training | |
| <!-- Provide a quick summary of the dataset. --> | |
| This dataset is used for training E2E CPath model, presented in [Revisiting End-to-End Learning with Slide-level Supervision in Computational Pathology](https://huggingface.co/papers/2506.02408), NeurIPS 2025. | |
| **Code:** [https://github.com/DearCaat/E2E-WSI-ABMILX](https://github.com/DearCaat/E2E-WSI-ABMILX) | |
| ## Sample Usage | |
| This dataset provides preprocessed whole-slide image (WSI) patches in LMDB format. Below is an example of how to load data from an LMDB dataset. | |
| ```python | |
| import lmdb | |
| import torch | |
| import pickle | |
| from datasets.utils import imfrombytes # Ensure this utility function is correctly referenced | |
| slide_name = "xxxx" # Example slide name | |
| path_to_lmdb = "YOUR_PATH_TO_LMDB_FILE" # e.g., "/path/to/my_dataset_256_level0.lmdb" | |
| # Open LMDB dataset | |
| env = lmdb.open(path_to_lmdb, subdir=False, readonly=True, lock=False, | |
| readahead=False, meminit=False, map_size=100 * (1024**3)) | |
| with env.begin(write=False) as txn: | |
| # Get patch count for the slide | |
| pn_dict = pickle.loads(txn.get(b'__pn__')) | |
| if slide_name not in pn_dict: | |
| raise ValueError(f"Slide ID {slide_name} not found in LMDB metadata.") | |
| num_patches = pn_dict[slide_name] | |
| # Generate patch IDs | |
| patch_ids = [f"{slide_name}-{i}" for i in range(num_patches)] | |
| # Allocate memory for patches (adjust dimensions and dtype as needed) | |
| # Assuming patches are 224x224, 3 channels, and will be normalized later | |
| patches_tensor = torch.empty((len(patch_ids), 3, 224, 224), dtype=torch.float32) | |
| # Load and decode data into torch.tensor | |
| for i, key_str in enumerate(patch_ids): | |
| patch_bytes = txn.get(key_str.encode('ascii')) | |
| if patch_bytes is None: | |
| print(f"Warning: Key {key_str} not found in LMDB.") | |
| continue | |
| # Assuming the stored value is pickled image bytes | |
| img_array = imfrombytes(pickle.loads(patch_bytes).tobytes()) # Or .tobytes() if it's already bytes | |
| patches_tensor[i] = torch.from_numpy(img_array.transpose(2, 0, 1)) # HWC to CHW | |
| # Normalize the data (example using ImageNet stats) | |
| # Ensure values are in [0, 255] before this normalization if they aren't already | |
| mean = torch.tensor([0.485, 0.456, 0.406]).view((1, 3, 1, 1)) * 255.0 | |
| std = torch.tensor([0.229, 0.224, 0.225]).view((1, 3, 1, 1)) * 255.0 | |
| # If your patches_tensor is already in [0,1] range, remove * 255.0 from mean/std | |
| # If your patches_tensor is uint8 [0,255], convert to float first: patches_tensor.float() | |
| patches_tensor = (patches_tensor.float() - mean) / std | |
| env.close() | |
| ``` | |
| ## Citation | |
| <!-- If there is a paper or blog post introducing the dataset, the APA and Bibtex information for that should go in this section. --> | |
| **BibTeX:** | |
| ``` | |
| @misc{tang2025revisitingendtoendlearningslidelevel, | |
| title={Revisiting End-to-End Learning with Slide-level Supervision in Computational Pathology}, | |
| author={Wenhao Tang and Rong Qin and Heng Fang and Fengtao Zhou and Hao Chen and Xiang Li and Ming-Ming Cheng}, | |
| year={2025}, | |
| eprint={2506.02408}, | |
| archivePrefix={arXiv}, | |
| primaryClass={cs.CV}, | |
| url={https://arxiv.org/abs/2506.02408}, | |
| } | |
| ``` |