Extensions for the `fastai2` library in the form of data augmentations and inference utilities. Specific to computer vision models. Inference utilities are built with a focus on single-label (softmax) classifiers.
Discussion started in #2. plot_gcam does not work with a CNN using a pre-trained ResNet-50. There are two issues that arise. This occurs with the following versions:
The same error happens when you use ClassificationInterpretation from the base fastai class. The learner does have a loss_func attached, which is FlattenedLoss of CrossEntropyLoss().
2. Number of dims don't match in permute
When trying to replicate the code in interpret_gradcam.ipynb, the plot_gcam function gives the following error:
The same error happens when using any of the following:
learn.gradcam('File_008.jpeg', target_layer = learn.model[1][0]) (the adaptive pooling layer of the last Sequential)
learn.gradcam('File_008.jpeg', target_layer = learn.model[0][-1]) (the last Sequential of the first Sequential, which contains the final conv layer
learn.gradcam('File_008.jpeg', target_layer = learn.model[0][-1][-1]) (the last Bottleneck of the last Sequential)
learn.gradcam('File_008.jpeg', target_layer = learn.model[0][-1][-1].conv3) (the final conv layer)
And the following results in various Dimension out of range (expected to be in range of [-1, 0], but got 1) errors:
learn.gradcam('File_008.jpeg', target_layer = learn.model[1][1]) (the Flatten layer after the last conv layer
learn.gradcam('File_008.jpeg', target_layer = learn.model[1][8]) (the final Linear layer
Discussion started in #2.
plot_gcam
does not work with a CNN using a pre-trained ResNet-50. There are two issues that arise. This occurs with the following versions:1. Missing 1 required positional argument: 'losses'
This code:
Results in this error:
The same error happens when you use
ClassificationInterpretation
from the base fastai class. The learner does have aloss_func
attached, which isFlattenedLoss of CrossEntropyLoss()
.2. Number of dims don't match in permute
When trying to replicate the code in interpret_gradcam.ipynb, the
plot_gcam
function gives the following error:The same error happens when using any of the following:
learn.gradcam('File_008.jpeg', target_layer = learn.model[1][0])
(the adaptive pooling layer of the lastSequential
)learn.gradcam('File_008.jpeg', target_layer = learn.model[0][-1])
(the lastSequential
of the firstSequential
, which contains the final conv layerlearn.gradcam('File_008.jpeg', target_layer = learn.model[0][-1][-1])
(the lastBottleneck
of the lastSequential
)learn.gradcam('File_008.jpeg', target_layer = learn.model[0][-1][-1].conv3)
(the final conv layer)And the following results in various
Dimension out of range (expected to be in range of [-1, 0], but got 1)
errors:learn.gradcam('File_008.jpeg', target_layer = learn.model[1][1])
(theFlatten
layer after the last conv layerlearn.gradcam('File_008.jpeg', target_layer = learn.model[1][8])
(the finalLinear
layerNetwork structure