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
when i choose AblationCAM in YOLOv5 notebook,it will promt this issue, this is my part code about YOLOBoxScoreTarget
def __init__(self, labels, bounding_boxes, iou_threshold=0.5): self.labels = labels self.bounding_boxes = bounding_boxes self.iou_threshold = iou_threshold def __call__(self, model_output): model_output = model([rgb_img]) boxes,_,_,confidences,categories = parse_detections(model_output) boxes = torch.Tensor(boxes) output = torch.Tensor([0]) if torch.cuda.is_available(): output = output.cuda() boxes = boxes.cuda() if len(boxes) == 0: return output for box, label in zip(self.bounding_boxes, self.labels): # print(type(box)) # <class 'tuple'> # print(box) # box[:] = (477, 271, 639, 471) box = torch.Tensor(np.array(box)[None,:]) if torch.cuda.is_available(): box = box.cuda() ious = torchvision.ops.box_iou(box, boxes) index = ious.argmax() if ious[0, index] > self.iou_threshold and categories[index] == label: score = ious[0, index] + confidences[index] output = output + score return output
And this is my test :
targets = [YOLOBoxScoreTarget(labels=names, bounding_boxes=boxes)] cam = AblationCAM(model, target_layers, ablation_layer=AblationLayer(), use_cuda=torch.cuda.is_available() ) grayscale_cam = cam(tensor, targets=targets)[0,:,:] cam_image = show_cam_on_image(img, grayscale_cam, use_rgb=True) Image.fromarray(cam_image)
The text was updated successfully, but these errors were encountered:
@jacobgil
Sorry, something went wrong.
No branches or pull requests
when i choose AblationCAM in YOLOv5 notebook,it will promt this issue,
this is my part code about YOLOBoxScoreTarget
def __init__(self, labels, bounding_boxes, iou_threshold=0.5): self.labels = labels self.bounding_boxes = bounding_boxes self.iou_threshold = iou_threshold def __call__(self, model_output): model_output = model([rgb_img]) boxes,_,_,confidences,categories = parse_detections(model_output) boxes = torch.Tensor(boxes) output = torch.Tensor([0]) if torch.cuda.is_available(): output = output.cuda() boxes = boxes.cuda() if len(boxes) == 0: return output for box, label in zip(self.bounding_boxes, self.labels): # print(type(box)) # <class 'tuple'> # print(box) # box[:] = (477, 271, 639, 471) box = torch.Tensor(np.array(box)[None,:]) if torch.cuda.is_available(): box = box.cuda() ious = torchvision.ops.box_iou(box, boxes) index = ious.argmax() if ious[0, index] > self.iou_threshold and categories[index] == label: score = ious[0, index] + confidences[index] output = output + score return output
And this is my test :
targets = [YOLOBoxScoreTarget(labels=names, bounding_boxes=boxes)] cam = AblationCAM(model, target_layers, ablation_layer=AblationLayer(), use_cuda=torch.cuda.is_available() ) grayscale_cam = cam(tensor, targets=targets)[0,:,:] cam_image = show_cam_on_image(img, grayscale_cam, use_rgb=True) Image.fromarray(cam_image)
The text was updated successfully, but these errors were encountered: