img = np.concatenate((img, img, img), axis=2)
        img = Image.fromarray(img)

    #12-net
    #box: xmin, ymin, xmax, ymax, score, cropped_img, scale
    neg_box = util.sliding_window(img, param.thr_12, net_12, input_12_node)

    #12-calib
    neg_db_tmp = np.zeros((len(neg_box), param.img_size_12, param.img_size_12,
                           param.input_channel), np.float32)
    for id_, box in enumerate(neg_box):
        neg_db_tmp[id_, :] = util.img2array(box[5], param.img_size_12)

    calib_result = net_12_calib.prediction.eval(
        feed_dict={input_12_node: neg_db_tmp})
    neg_box = util.calib_box(neg_box, calib_result, img)

    #NMS for each scale
    scale_cur = 0
    scale_box = []
    suppressed = []
    for id_, box in enumerate(neg_box):
        if box[6] == scale_cur:
            scale_box.append(box)
        if box[6] != scale_cur or id_ == len(neg_box) - 1:
            suppressed += util.NMS(scale_box)
            scale_cur = box[6]
            scale_box = [box]

    neg_box = suppressed
    suppressed = []
Exemple #2
0
        #12-net
        #xmin, ymin, xmax, ymax, score, cropped_img, scale
        result_box = util.sliding_window(img, param.thr_12, net_12,
                                         input_12_node)

        #12-calib
        result_db_tmp = np.zeros((len(result_box), param.img_size_12,
                                  param.img_size_12, param.input_channel),
                                 np.float32)
        for id_, box in enumerate(result_box):
            result_db_tmp[id_, :] = util.img2array(box[5], param.img_size_12)

        calib_result = net_12_calib.prediction.eval(
            feed_dict={input_12_node: result_db_tmp})
        result_box = util.calib_box(result_box, calib_result, img)

        #NMS for each scale
        scale_cur = 0
        scale_box = []
        suppressed = []
        for id_, box in enumerate(result_box):
            if box[6] == scale_cur:
                scale_box.append(box)
            if box[6] != scale_cur or id_ == len(result_box) - 1:
                suppressed += util.NMS(scale_box)
                scale_cur = box[6]
                scale_box = [box]

        result_box = suppressed
        suppressed = []