Пример #1
0
def main(args):
    listModels = []
    models_list = args.models.split(",")
    print("Models to be run: ", models_list)
    if 'mask_rcnn' in models_list:
        maskRcnn = testTimeAugmentation.MaskRCNNPred(
            '/mnt/src/mask_rcnn_coco.h5', '/mnt/src/coco.names')
        listModels.append(maskRcnn)
    if 'retinanet' in models_list:
        retinaResnet50 = testTimeAugmentation.RetinaNetResnet50Pred(
            '/mnt/src/resnet50_coco_best_v2.1.0.h5', '/mnt/src/coco.csv')
        listModels.append(retinaResnet50)
    if 'yolo_darknet' in models_list:
        yoloDarknet = testTimeAugmentation.DarknetYoloPred(
            '/mnt/src/yolov3.weights', '/mnt/src/coco.names',
            '/mnt/src/yolov3.cfg')
        listModels.append(yoloDarknet)
    if 'ssd_resnet' in models_list:
        ssdResnet = testTimeAugmentation.MXnetSSD512Pred(
            '/mnt/src/ssd_512_resnet50_v1_voc-9c8b225a.params',
            '/mnt/src/classesMXnet.txt')
        listModels.append(ssdResnet)
    if 'faster_resnet' in models_list:
        fasterResnet = testTimeAugmentation.MXnetFasterRCNNPred(
            '/mnt/src/faster_rcnn_resnet50_v1b_voc-447328d8.params',
            '/mnt/src/classesMXnet.txt')
        listModels.append(fasterResnet)


#     listaModels = [retinaResnet50, maskRcnn]
    models(listModels, args.images_path, args.option, args.combine)
    print(os.listdir('/mnt/src/'))
    if notebook is False:
        shutil.rmtree(pathImg+'/../salida/')


if __name__== "__main__":
    #Enter the path of the folder that will contain the images
    ap = argparse.ArgumentParser()
    ap.add_argument("-d", "--dataset", required=True, help="path to the dataset of images")
    ap.add_argument("-o", "--option",  default='consensus', help="option to the ensemble: affirmative, consensus or unanimous")
    notebook = False
    args = vars(ap.parse_args())
    pathImg= args["dataset"]

    option = args["option"]

    #fichs = os.listdir(pathImg)

    imgFolder = pathImg
    #the user define configurations fichs

    yoloDarknet = testTimeAugmentation.DarknetYoloPred('/home/ancasag/Codigo/General/ensembleObjectDetection/peso/AlvaroPrueba1_600train_65000.weights', '../peso/vocEstomas.names','../peso/yolov3Estomas.cfg',0.7)
    ssdResnet = testTimeAugmentation.MXnetSSD512Pred('/home/ancasag/Codigo/General/ensembleObjectDetection/peso/ssd_512_resnet50_v1_voc-9c8b225a.params', '../peso/classesMXnet.txt',0.7)
    fasterResnet = testTimeAugmentation.MXnetFasterRCNNPred('/home/ancasag/Codigo/General/ensembleObjectDetection/peso/faster_rcnn_resnet50_v1b_voc-447328d8.params', '../peso/classesMXnet.txt',0.7)
    yoloResnet = testTimeAugmentation.MXnetYoloPred('/home/ancasag/Codigo/General/ensembleObjectDetection/peso/yolo3_darknet53_voc-f5ece5ce.params', '../peso/classesMXnet.txt',0.7)
    retinaResnet50 = testTimeAugmentation.RetinaNetResnet50Pred('/home/ancasag/Codigo/General/ensembleObjectDetection/peso/resnet50_coco_best_v2.1.0.h5', '../peso/coco.csv',0.7)
    maskRcnn = testTimeAugmentation.MaskRCNNPred('/home/ancasag/Codigo/General/ensembleObjectDetection/peso/mask_rcnn_coco.h5', '../peso/coco.names',0.7)

    listaModels = [retinaResnet50, maskRcnn,yoloResnet,yoloDarknet,fasterResnet,ssdResnet]

    models(listaModels,pathImg,option)
    pathImg = args["dataset"]

    option = args["option"]

    #fichs = os.listdir(pathImg)

    imgFolder = pathImg
    #the user define configurations fichs

    yoloDarknet = testTimeAugmentation.DarknetYoloPred(
        '/home/master/Desktop/peso/AlvaroPrueba1_600train_65000.weights',
        '../peso/vocEstomas.names', '../peso/yolov3Estomas.cfg')
    ssdResnet = testTimeAugmentation.MXnetSSD512Pred(
        '/home/master/Desktop/peso/ssd_512_resnet50_v1_voc-9c8b225a.params',
        '../peso/classesMXnet.txt')
    fasterResnet = testTimeAugmentation.MXnetFasterRCNNPred(
        '/home/master/Desktop/peso/faster_rcnn_resnet50_v1b_voc-447328d8.params',
        '../peso/classesMXnet.txt')
    yoloResnet = testTimeAugmentation.MXnetYoloPred(
        '/home/master/Desktop/peso/yolo3_darknet53_voc-f5ece5ce.params',
        '../peso/classesMXnet.txt')
    retinaResnet50 = testTimeAugmentation.RetinaNetResnet50Pred(
        '/home/master/Desktop/peso/resnet50_coco_best_v2.1.0.h5',
        '../peso/coco.csv')
    maskRcnn = testTimeAugmentation.MaskRCNNPred(
        '/home/master/Desktop/peso/mask_rcnn_coco.h5', '../peso/coco.names')

    listaModels = [retinaResnet50, maskRcnn]

    models(listaModels, pathImg, option)