Last active
October 23, 2024 17:40
-
-
Save MartinWeiss12/cd185ac38fab0caefa31ddb5cb84e020 to your computer and use it in GitHub Desktop.
Generate Grad-CAM Plots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = torch.load('skin-cancer-recognition.pth', weights_only=False, map_location=device) | |
threshold = 0.6 | |
examples = [ | |
{'image_class': 'mel', 'image_id': 28087, 'lesion_type': 'Malignant Melanoma (mel)'}, | |
{'image_class': 'mel', 'image_id': 29571, 'lesion_type': 'Malignant Melanoma (mel)'}, | |
{'image_class': 'bcc', 'image_id': 32290, 'lesion_type': 'Basal Cell Carcinoma (bcc)'}, | |
{'image_class': 'vasc', 'image_id': 24867, 'lesion_type': 'Vascular Lesion (vasc)'}, | |
{'image_class': 'nv', 'image_id': 28507, 'lesion_type': 'Benign Melanocytic Nevi (nv)'}, | |
] | |
for img in examples: | |
img_path = f"{data_dir}/test/{img['image_class']}/ISIC_00{img['image_id']}.jpg" | |
grad_cam(model, threshold, img['image_id'], img_path, img['lesion_type'], image_width, image_height, device) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment