Skip to content

True Positive detections #8440

Closed
Closed
@ilpapds

Description

Search before asking

Question

Hello, i am trying to store/save the true positive (correct) detected bounding boxes of the yolov5 model. In order to do that, i am trying to modify the val.py code in the following lines:

        # Evaluate
        if nl:
            tbox = xywh2xyxy(labels[:, 1:5])  # target boxes
            scale_coords(im[si].shape[1:], tbox, shape, shapes[si][1])  # native-space labels
            labelsn = torch.cat((labels[:, 0:1], tbox), 1)  # native-space labels
            correct = process_batch(predn, labelsn, iouv)
            if plots:
                confusion_matrix.process_batch(predn, labelsn)
        stats.append((correct, pred[:, 4], pred[:, 5], labels[:, 0]))  # (correct, conf, pcls, tcls)

Modyfying them in this way:

        # Evaluate
        if nl:
            tbox = xywh2xyxy(labels[:, 1:5])  # target boxes
            scale_coords(im[si].shape[1:], tbox, shape, shapes[si][1])  # native-space labels
            labelsn = torch.cat((labels[:, 0:1], tbox), 1)  # native-space labels
            correct = process_batch(predn, labelsn, iouv)
            for batch_j in correct[batch_j, 0]:  
                init_img = cv2.imread(paths[batch_j])                               
                crop_img = init_img[int(predn[batch_j,0]):int(predn[batch_j,2]),int(predn[batch_j,1]):int(predn[batch_j,3]),:]     
            if plots:
                confusion_matrix.process_batch(predn, labelsn)
        stats.append((correct, pred[:, 4], pred[:, 5], labels[:, 0]))  # (correct, conf, pcls, tcls)

And now i want to store this crop_img which corresponds to the true positive detections. Is that possible? Has anybody done it with another way? Thank you mery much

Additional

No response

Metadata

Assignees

No one assigned

    Labels

    StaleStale and schedule for closing soonquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions