Example #1
0
def detect(only_snms=True):
    # load image
    load_begin = time.time()
    pkllistfile = open(os.path.join('video', 'pkllist.txt'))
    pkllist = pkllistfile.readlines()
    pkllistfile.close()
    pkllist = [pkl.strip() for pkl in pkllist]
    load_end = time.time()
    print('load: {:.4f}s'.format(load_end - load_begin))

    # detection
    detect_begin = time.time()
    res = yolo_detection.detect_imgs(pkllist, nms=0, thresh=0.25)
    detect_end = time.time()
    print('total detect: {:.4f}s'.format(detect_end - detect_begin))
    print('-----------------------------------')
    if only_snms:
        save_results(res, pkllist, True)
    else:  # Run both methods
        save_results(res, pkllist, False)
        save_results(res, pkllist, True)
Example #2
0
if __name__ == "__main__":
    # load image
    load_begin = time.time()
    pkllistfile = open(os.path.join('video', 'pkllist.txt'))
    pkllist = pkllistfile.readlines()
    pkllistfile.close()
    pkllist = [pkl.strip() for pkl in pkllist]
    load_end = time.time()
    print('load: {:.4f}s'.format(load_end - load_begin))

    # detection
    detect_begin = time.time()
    if len(sys.argv) > 1 and sys.argv[1] == 'tiny':
        res = yolo_detection.detect_imgs(pkllist,
                                         cfg="cfg/yolov2-tiny-voc.cfg",
                                         weights="yolov2-tiny-voc.weights",
                                         data="cfg/voc.data",
                                         nms=0,
                                         thresh=0.1)
    elif len(sys.argv) > 1 and sys.argv[1] == 'v2':
        res = yolo_detection.detect_imgs(pkllist,
                                         cfg="cfg/yolov2.cfg",
                                         weights="yolov2.weights",
                                         nms=0,
                                         thresh=0.1)
    elif len(sys.argv) > 1 and sys.argv[1] == 'face':
        res = yolo_detection.detect_imgs(pkllist,
                                         cfg="cfg/yolov3-wider.cfg",
                                         weights="yolov3-wider.weights",
                                         data="cfg/wider.data",
                                         nms=0,
                                         thresh=0.1)
Example #3
0
        category_index)
    return image_process

if __name__ == "__main__":
    # load image
    load_begin=time.time()
    pkllistfile=open(os.path.join('video', 'pkllist.txt'))
    pkllist=pkllistfile.readlines()
    pkllistfile.close()
    pkllist=[pkl.strip() for pkl in pkllist]
    load_end=time.time()
    print('load: {:.4f}s'.format(load_end - load_begin))

    # detection
    detect_begin=time.time()
    res = yolo_detection.detect_imgs(pkllist, nms=0, thresh=0.25)
    detect_end=time.time()
    print('total detect: {:.4f}s'.format(detect_end - detect_begin))

    # nms
    nms_begin=time.time()
    boxes, classes, scores = dsnms(res)
    nms_end=time.time()
    print('total nms: {:.4f}s'.format(nms_end - nms_begin))

    # save&visualization
    save_begin=time.time()
    PATH_TO_LABELS = os.path.join('data', 'mscoco_label_map.pbtxt')
    NUM_CLASSES = 80
    if not os.path.exists('video/output'):
        os.makedirs('video/output')
Example #4
0
if __name__ == "__main__":
    # load image
    load_begin = time.time()
    pkllistfile = open(os.path.join('video', 'pkllist.txt'))
    pkllist = pkllistfile.readlines()
    pkllistfile.close()
    pkllist = [pkl.strip() for pkl in pkllist]
    load_end = time.time()
    print('load: {:.4f}s'.format(load_end - load_begin))

    # detection
    detect_begin = time.time()
    if len(sys.argv) > 1 and sys.argv[1] == 'tiny':
        res = yolo_detection.detect_imgs(pkllist,
                                         cfg="cfg/tiny-yolo.cfg",
                                         weights="tiny-yolo.weights",
                                         nms=0,
                                         thresh=0.25)
    else:
        res = yolo_detection.detect_imgs(pkllist, nms=0, thresh=0.25)
    detect_end = time.time()
    print('total detect: {:.4f}s'.format(detect_end - detect_begin))
    print('average detect: {:.4f}s'.format(
        (detect_end - detect_begin) / len(pkllist)))

    # nms
    nms_begin = time.time()
    if len(sys.argv) > 1 and sys.argv[1] == 'only_person':
        boxes, classes, scores = dsnms(res, only_person=True)
    else:
        boxes, classes, scores = dsnms(res)