def detect()

in models/02_YoloV4/01_Pytorch/utils.py [0:0]


def detect(pred,conf_tresh=0.4, iou_tresh=0.5, merge=False):
    '''
    Get the two outputs of the network
    apply sigmoid, grids and concatenate
    exptected input shapes = [(batch_size,3,13,1,num_classes+5), (batch_size,3,26,26,num_classes+5)]
    '''
    pred = np.concatenate([get_pred(sigmoid(p), stride[i],anchors[i]) for i,p in enumerate(pred)], axis=1)
    preds = non_max_suppression(pred, conf_tresh, iou_tresh, merge)
    detections = []
    for det in preds:
        if det is None: continue
        for *xyxy, conf, cls in det:
            c1, c2 = (int(xyxy[0]), int(xyxy[1])), (int(xyxy[2]), int(xyxy[3]))
            detections.append([c1,c2,conf,cls])
    return detections