ResNetCAM-keras
ResNetCAM-keras copied to clipboard
fast tensor mult
Scipy zoom function and the numpy dot product are really slow and also, can't take advantage of computation on GPU. A much faster way is to use tensorflow for both operations and convert the final result back to a numpy array. On my system, running code on CPU, this saves approximately 10 seconds for a single image.
I faced the performance issue as well. I modified original code to
# ResNet_CAM.py
mat_for_mult = tf.image.resize(last_conv_output, (224, 224))
amp_layer_weights = all_amp_layer_weights[:, pred:pred+1]
final_output = tf.matmul(mat_for_mult, amp_layer_weights)[:,:,0]
It got 10 times faster.