We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
why this wrong %%time
from tf_keras_vis.gradcam_plus_plus import GradcamPlusPlus
gradcam = GradcamPlusPlus(model, model_modifier=model_modifier, clone=False) score = CategoricalScore([1, 1,1])
cam = gradcam(score, images, penultimate_layer=-1)
normalize()
f, ax = plt.subplots(nrows=1, ncols=3, figsize=(12, 4)) for i, title in enumerate(image_titles): heatmap = np.uint8(cm.jet(cam[i])[..., :3] * 255) ax[i].set_title(title, fontsize=16) ax[i].imshow(images[i]) ax[i].imshow(heatmap, cmap='jet', alpha=0.5) ax[i].axis('off') plt.tight_layout() plt.savefig('/content/gradcam_plus_plus.png') plt.show()
The text was updated successfully, but these errors were encountered:
outputs = model(seed_inputs, training=training) 93 outputs, penultimate_output = outputs[:-1], outputs[-1] ---> 94 score_values = self._calculate_scores(outputs, scores) 95 grads = tape.gradient(score_values, 96 penultimate_output,
4 frames /usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/ops.py in getattr(self, name) 441 np_config.enable_numpy_behavior() 442 """) --> 443 self.getattribute(name) 444 445 @staticmethod
AttributeError: 'Tensor' object has no attribute 'ndim'
Sorry, something went wrong.
No branches or pull requests
why this wrong
%%time
from tf_keras_vis.gradcam_plus_plus import GradcamPlusPlus
Create GradCAM++ object
gradcam = GradcamPlusPlus(model,
model_modifier=model_modifier,
clone=False)
score = CategoricalScore([1, 1,1])
Generate heatmap with GradCAM++
cam = gradcam(score, images, penultimate_layer=-1)
Since v0.6.0, calling
normalize()
is NOT necessary.cam = normalize(cam)
Render
f, ax = plt.subplots(nrows=1, ncols=3, figsize=(12, 4))
for i, title in enumerate(image_titles):
heatmap = np.uint8(cm.jet(cam[i])[..., :3] * 255)
ax[i].set_title(title, fontsize=16)
ax[i].imshow(images[i])
ax[i].imshow(heatmap, cmap='jet', alpha=0.5)
ax[i].axis('off')
plt.tight_layout()
plt.savefig('/content/gradcam_plus_plus.png')
plt.show()
The text was updated successfully, but these errors were encountered: