예제 #1
0
def prepare(srcpath, dstpath):
    """
    :param srcpath: train, val, test
          train --> trainval1024, val --> trainval1024, test --> test1024
    :return:
    """
    if not os.path.exists(os.path.join(dstpath, 'test1024')):
        os.mkdir(os.path.join(dstpath, 'test1024'))
    if not os.path.exists(os.path.join(dstpath, 'trainval1024')):
        os.mkdir(os.path.join(dstpath, 'trainval1024'))

    split_train = ImgSplit_multi_process.splitbase(os.path.join(srcpath, 'train'),
                       os.path.join(dstpath, 'train1024'),
                      gap=200,
                      subsize=1024,
                      num_process=32
                      )
    split_train.splitdata(1)

    split_val = ImgSplit_multi_process.splitbase(os.path.join(srcpath, 'val'),
                       os.path.join(dstpath, 'train1024'),
                      gap=200,
                      subsize=1024,
                      num_process=32
                      )
    split_val.splitdata(1)

    split_test = SplitOnlyImage_multi_process.splitbase(os.path.join(srcpath, 'test', 'images'),
                       os.path.join(dstpath, 'test1024', 'images'),
                      gap=200,
                      subsize=1024,
                      num_process=32
                      )
    split_test.splitdata(1)

    DOTA2COCOTrain(os.path.join(dstpath, 'train1024'), os.path.join(dstpath, 'train1024', 'DOTA_train1024.json'), wordname_15, difficult='2')
    DOTA2COCOTrain(os.path.join(dstpath, 'val1024'), os.path.join(dstpath, 'val1024', 'DOTA_val1024.json'), wordname_15, difficult='2')
    DOTA2COCOTest(os.path.join(dstpath, 'test1024'), os.path.join(dstpath, 'test1024', 'DOTA_test1024.json'), wordname_15)
예제 #2
0
        os.path.join(srcpath, 'test', 'images'),
        os.path.join(dstpath, 'test1024', 'images'),
        gap=200,
        subsize=1024,
        num_process=32)
    split_test.splitdata(1)

    DOTA2COCOTrain(os.path.join(dstpath, 'trainval1024'),
                   os.path.join(dstpath, 'trainval1024',
                                'DOTA_trainval1024.json'),
                   wordname_15,
                   difficult='-1')
    DOTA2COCOTest(os.path.join(dstpath, 'test1024'),
                  os.path.join(dstpath, 'test1024', 'DOTA_test1024.json'),
                  wordname_15)


if __name__ == '__main__':
    args = parse_args()
    srcpath = args.srcpath
    dstpath = args.dstpath
    # prepare(srcpath, dstpath)
    DOTA2COCOTrain(os.path.join(dstpath, 'trainval1024'),
                   os.path.join(dstpath, 'trainval1024',
                                'DOTA_trainval1024.json'),
                   wordname_15,
                   difficult='-1')
    DOTA2COCOTest(os.path.join(dstpath, 'test1024'),
                  os.path.join(dstpath, 'test1024', 'DOTA_test1024.json'),
                  wordname_15)
예제 #3
0
def prepare(srcpath, dstpath):
    """
    :param srcpath: train, val, test
          train --> trainval1024, val --> trainval1024, test --> test1024
    :return:
    """
    # if not os.path.exists(os.path.join(dstpath, 'test1024')):
    #     os.makedirs(os.path.join(dstpath, 'test1024'))
    if not os.path.exists(os.path.join(dstpath, 'test1024_ms')):
        os.makedirs(os.path.join(dstpath, 'test1024_ms'))
    # if not os.path.exists(os.path.join(dstpath, 'trainval1024')):
    #     os.makedirs(os.path.join(dstpath, 'trainval1024'))
    if not os.path.exists(os.path.join(dstpath, 'trainval1024_ms')):
        os.makedirs(os.path.join(dstpath, 'trainval1024_ms'))

    # split_train = ImgSplit_multi_process.splitbase(os.path.join(srcpath, 'train'),
    #                   os.path.join(dstpath, 'trainval1024'),
    #                   gap=200,
    #                   subsize=1024,
    #                   num_process=16
    #                   )
    # split_train.splitdata(1)

    split_train_ms = ImgSplit_multi_process.splitbase(
        os.path.join(srcpath, 'train'),
        os.path.join(dstpath, 'trainval1024_ms'),
        gap=200,
        subsize=1024,
        num_process=16)
    split_train_ms.splitdata(0.5)
    # split_train_ms.splitdata(1.5)

    # split_val = ImgSplit_multi_process.splitbase(os.path.join(srcpath, 'val'),
    #                    os.path.join(dstpath, 'trainval1024'),
    #                   gap=200,
    #                   subsize=1024,
    #                   num_process=16
    #                   )
    # split_val.splitdata(1)

    split_val_ms = ImgSplit_multi_process.splitbase(
        os.path.join(srcpath, 'val'),
        os.path.join(dstpath, 'trainval1024_ms'),
        gap=200,
        subsize=1024,
        num_process=16)
    split_val_ms.splitdata(0.5)
    # split_val_ms.splitdata(1.5)

    # split_test = SplitOnlyImage_multi_process.splitbase(os.path.join(srcpath, 'test', 'images'),
    #                   os.path.join(dstpath, 'test1024', 'images'),
    #                   gap=200,
    #                   subsize=1024,
    #                   num_process=16
    #                   )
    # split_test.splitdata(1)

    split_test_ms = SplitOnlyImage_multi_process.splitbase(
        os.path.join(srcpath, 'test', 'images'),
        os.path.join(dstpath, 'test1024_ms', 'images'),
        gap=200,
        subsize=1024,
        num_process=16)
    split_test_ms.splitdata(0.5)
    # split_test_ms.splitdata(1.5)

    # DOTA2COCOTrain(os.path.join(dstpath, 'trainval1024'), os.path.join(dstpath, 'trainval1024', 'DOTA_trainval1024.json'), wordname_15, difficult='2')
    DOTA2COCOTrain(os.path.join(dstpath, 'trainval1024_ms'),
                   os.path.join(dstpath, 'trainval1024_ms',
                                'DOTA_trainval1024_ms.json'),
                   wordname_15,
                   difficult='2')

    # DOTA2COCOTest(os.path.join(dstpath, 'test1024'), os.path.join(dstpath, 'test1024', 'DOTA_test1024.json'), wordname_15)
    DOTA2COCOTest(
        os.path.join(dstpath, 'test1024_ms'),
        os.path.join(dstpath, 'test1024_ms', 'DOTA_test1024_ms.json'),
        wordname_15)
예제 #4
0
파일: rotate.py 프로젝트: zwj1archer/CG-Net
    pool = Pool(16)
    imgnames = util.GetFileFromThisRootDir(os.path.join(srcpath, 'images'))
    names = [util.custombasename(x) for x in imgnames]

    dst_imgpath = os.path.join(dstpath, 'images')
    dst_labelTxt = os.path.join(dstpath, 'labelTxt')

    if not os.path.exists(dstpath):
        os.mkdir(dstpath)

    if not os.path.exists(dst_imgpath):
        os.mkdir(dst_imgpath)

    if not os.path.exists(dst_labelTxt):
        os.mkdir(dst_labelTxt)

    rotate_fun = partial(rotate_single_run, srcpath=srcpath, dstpath=dstpath)

    pool.map(rotate_fun, names)

if __name__ == '__main__':
    rotate(r'/home/gqx/GQX/AerialDetection/data/dota1-split-1024/trainval1024',
           r'/home/gqx/GQX/AerialDetection/data/dota1-split-1024/trainval_rotate')
    # rotate(r'/data/dj/dota/trainval_large-split-1024',
    #        r'/data/dj/dota/trainval_large-split_rotate')
    dstpath = '/home/gqx/GQX/AerialDetection/data/dota1-split-1024/'
    DOTA2COCOTrain(os.path.join(dstpath, 'trainval_rotate'),
                   os.path.join(dstpath, 'trainval_rotate', 'DOTA_trainval_rotate.json'), wordname_15, difficult='2')