data_explorer
orchard.data_handler.data_explorer
¶
Data Visualization Module.
Utilities to inspect datasets visually by generating grids of sample images from raw tensors or NumPy arrays. Supports grayscale and RGB images and optional denormalization. Figures are saved inside the run's output directory managed by RunPaths.
show_sample_images(loader, save_path, *, mean=None, std=None, arch_name='Model', fig_dpi=_DEFAULT_DPI, num_samples=16, title_prefix=None)
¶
Extract a batch from the DataLoader and save a grid of sample images.
Saves images with their corresponding labels to verify data integrity and augmentations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loader
|
DataLoader[Any]
|
The PyTorch DataLoader to sample from. |
required |
save_path
|
Path
|
Full path (including filename) to save the resulting image. |
required |
mean
|
tuple[float, ...] | None
|
Per-channel mean for denormalization. |
None
|
std
|
tuple[float, ...] | None
|
Per-channel std for denormalization. |
None
|
arch_name
|
str
|
Architecture name for the figure title. |
'Model'
|
fig_dpi
|
int
|
DPI for the saved figure. |
_DEFAULT_DPI
|
num_samples
|
int
|
Number of images to display in the grid. |
16
|
title_prefix
|
str | None
|
Optional string to prepend to the figure title. |
None
|
Source code in orchard/data_handler/data_explorer.py
show_samples_for_dataset(loader, dataset_name, run_paths, *, mean=None, std=None, arch_name='Model', fig_dpi=_DEFAULT_DPI, num_samples=16, resolution=None)
¶
Generate a grid of sample images from a dataset and save to the figures directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
loader
|
DataLoader[Any]
|
PyTorch DataLoader to sample images from. |
required |
dataset_name
|
str
|
Name of the dataset, used in the filename and title. |
required |
run_paths
|
RunPaths
|
RunPaths instance to resolve figure saving path. |
required |
mean
|
tuple[float, ...] | None
|
Per-channel mean for denormalization. |
None
|
std
|
tuple[float, ...] | None
|
Per-channel std for denormalization. |
None
|
arch_name
|
str
|
Architecture name for the figure title. |
'Model'
|
fig_dpi
|
int
|
DPI for the saved figure. |
_DEFAULT_DPI
|
num_samples
|
int
|
Number of images to include in the grid. |
16
|
resolution
|
int | None
|
Resolution to include in filename to avoid overwriting. |
None
|