def get_dataset_path(path, annotation, image_dir):
    """
    If path exists, return path.
    Otherwise, get dataset path from DATASET_HOME, if not exists,
    download it.
    """
    if _dataset_exists(path, annotation, image_dir):
        return path

    data_name = os.path.split(path.strip().lower())[-1]
    if data_name not in DOWNLOAD_DATASETS_LIST:
        raise ValueError(
            "Dataset {} is not valid for reason above, please check again.".
            format(osp.realpath(path)))
    else:
        logger.warning(
            "Dataset {} is not valid for reason above, try searching {} or "
            "downloading dataset...".format(osp.realpath(path), DATASET_HOME))

    for name, dataset in DATASETS.items():
        if data_name == name:
            logger.debug("Parse dataset_dir {} as dataset "
                         "{}".format(path, name))
            data_dir = osp.join(DATASET_HOME, name)

            if name == "spine_coco":
                if _dataset_exists(data_dir, annotation, image_dir):
                    return data_dir

            # For voc, only check dir VOCdevkit/VOC2012, VOCdevkit/VOC2007
            if name in ['voc', 'fruit', 'roadsign_voc']:
                exists = True
                for sub_dir in dataset[1]:
                    check_dir = osp.join(data_dir, sub_dir)
                    if osp.exists(check_dir):
                        logger.info("Found {}".format(check_dir))
                    else:
                        exists = False
                if exists:
                    return data_dir

            # voc exist is checked above, voc is not exist here
            check_exist = name != 'voc' and name != 'fruit' and name != 'roadsign_voc'
            for url, md5sum in dataset[0]:
                get_path(url, data_dir, md5sum, check_exist)

            # voc should create list after download
            if name == 'voc':
                create_voc_list(data_dir)
            return data_dir

    raise ValueError("Dataset automaticly downloading Error.")

    If path exists, return path.
    Otherwise, get dataset path from DATASET_HOME, if not exists,
    download it.
    
ppdet/utils/download.py