prediction_saver
SavePredictions
Bases: BasePredictionWriter
A class that saves model predictions.
Attributes:
Name | Type | Description |
---|---|---|
path |
str
|
The path to save the output CSV file. |
save_preview_samples |
bool
|
If True, save preview images. |
keys |
List[str]
|
A list of keys. |
Source code in fmcib/callbacks/prediction_saver.py
__init__(path, save_preview_samples=False, keys=None)
Initialize an instance of the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The path to save the output CSV file. |
required |
save_preview_samples
|
bool
|
A flag indicating whether to save preview samples. Defaults to False. |
False
|
keys
|
List[str]
|
A list of keys. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
None |
Source code in fmcib/callbacks/prediction_saver.py
save_preview_image(data, tag)
Save a preview image to a specified directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self
|
object
|
The object calling the function. (self in Python) |
required |
data
|
tuple
|
A tuple containing the image data and its corresponding tag. |
required |
tag
|
str
|
The tag for the image. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in fmcib/callbacks/prediction_saver.py
write_on_epoch_end(trainer, pl_module, predictions, batch_indices)
Write predictions on epoch end.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
self
|
The instance of the class. |
required | |
trainer
|
The trainer object. |
required | |
pl_module
|
LightningModule
|
The Lightning module. |
required |
predictions
|
List[Any]
|
A list of prediction values. |
required |
batch_indices
|
List[Any]
|
A list of batch indices. |
required |
Raises:
Type | Description |
---|---|
AssertionError
|
If 'predict' is not present in pl_module.datasets. |
AssertionError
|
If 'data' is not defined in pl_module.datasets. |
Returns:
Type | Description |
---|---|
None |