Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.47k stars 1.49k forks source link

Clarification on post processing #540

Open lpkoh opened 2 years ago

lpkoh commented 2 years ago

Hi, I am currently running demo.py with the aim of converting my own trained yolov4-csp model from darknet to pytorch. I wanted to clarify if the parameters for the post processing after detections were the same.

This is from darknet. It has three params, thresh, hier_thresh and nms.

def detect_image(network, class_names, image, thresh=.5, hier_thresh=.5, nms=.45):
    """
        Returns a list with highest confidence class and their bbox
    """
    pnum = pointer(c_int(0))
    predict_image(network, image)
    detections = get_network_boxes(network, image.w, image.h,
                                   thresh, hier_thresh, None, 0, pnum, 0)
    num = pnum[0]
    if nms:
        do_nms_sort(detections, num, len(class_names), nms)
    predictions = remove_negatives(detections, class_names, num)
    predictions = decode_detection(predictions)
    free_detections(detections, num)
    return sorted(predictions, key=lambda x: x[1])

For this repo, I see conf_thresh and nms_thresh as parameters.

def do_detect(model, img, conf_thresh, nms_thresh, use_cuda=1):
    model.eval()
    with torch.no_grad():
        t0 = time.time()

The provided values are 0.4 for conf_thresh and 0.6 for nms_thresh.

Can I clarify if conf_thresh corresponds to thresh, and nms_thresh corresponds to nms? Is there an equivalent for hier_thresh?