mednet.engine.classify.saliency.generator¶
Engine and functions for saliency map generation.
Functions
|
Apply saliency mapping techniques on input CXR, outputs pickled saliency maps directly to disk. |
- mednet.engine.classify.saliency.generator.run(model, datamodule, device_manager, saliency_map_algorithm, target_class, positive_only, output_folder, only_dataset)[source]¶
Apply saliency mapping techniques on input CXR, outputs pickled saliency maps directly to disk.
- Parameters:
model (
LightningModule
) – Neural network model (e.g. pasa).datamodule (
LightningDataModule
) – The lightning DataModule to iterate on.device_manager (
DeviceManager
) – An internal device representation, to be used for training and validation. This representation can be converted into a pytorch device or a lightning accelerator setup.saliency_map_algorithm (
Literal
['ablationcam'
,'eigencam'
,'eigengradcam'
,'fullgrad'
,'gradcam'
,'gradcamelementwise'
,'gradcam++'
,'gradcamplusplus'
,'hirescam'
,'layercam'
,'randomcam'
,'scorecam'
,'xgradcam'
]) – The algorithm to use for saliency map estimation.target_class (
Literal
['highest'
,'all'
]) – (Use only with multi-label models) Which class to target for CAM calculation. Can be either set to “all” or “highest”. “highest” is default, which means only saliency maps for the class with the highest activation will be generated.positive_only (
bool
) – If set, saliency maps will only be generated for positive samples (ie. label == 1 in a binary classification task). This option is ignored on a multi-class output model.output_folder (
Path
) – Where to save all the saliency maps (this path should exist before this function is called).only_dataset (
str
|None
) – If set, will only run this code for the named dataset on the provided datamodule, skipping any other datasets.
- Return type: