当前位置: 首页>>代码示例>>Python>>正文


Python utils.check_integrity方法代码示例

本文整理汇总了Python中torchvision.datasets.utils.check_integrity方法的典型用法代码示例。如果您正苦于以下问题:Python utils.check_integrity方法的具体用法?Python utils.check_integrity怎么用?Python utils.check_integrity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在torchvision.datasets.utils的用法示例。


在下文中一共展示了utils.check_integrity方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_meta

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _load_meta(self):
        path = os.path.join(self.root, self.base_folder, self.meta['filename'])
        if not check_integrity(path, self.meta['md5']):
            raise RuntimeError('Dataset metadata file not found or corrupted.' +
                               ' You can use download=True to download it')
        with open(path, 'rb') as infile:
            if sys.version_info[0] == 2:
                data = pickle.load(infile)
            else:
                data = pickle.load(infile, encoding='latin1')
            self.classes = data[self.meta['key']]
        self.class_to_idx = {_class: i for i, _class in enumerate(self.classes)} 
开发者ID:sato9hara,项目名称:sgd-influence,代码行数:14,代码来源:MyCIFAR10.py

示例2: _check_integrity

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _check_integrity(self):
        root = self.root
        for fentry in (self.train_list + self.test_list):
            filename, md5 = fentry[0], fentry[1]
            fpath = os.path.join(root, self.base_folder, filename)
            if not check_integrity(fpath, md5):
                return False
        return True 
开发者ID:sato9hara,项目名称:sgd-influence,代码行数:10,代码来源:MyCIFAR10.py

示例3: _check_integrity

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _check_integrity(self):
        root = self.root
        md5 = self.split_list[self.split][2]
        fpath = os.path.join(root, self.filename)
        return check_integrity(fpath, md5) 
开发者ID:siit-vtt,项目名称:semi-supervised-learning-pytorch,代码行数:7,代码来源:loader_svhn.py

示例4: download

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def download(self):
        if not check_integrity(self.meta_file):
            tmpdir = os.path.join(self.root, 'tmp')

            archive_dict = ARCHIVE_DICT['devkit']
            download_and_extract_tar(archive_dict['url'], self.root,
                                     extract_root=tmpdir,
                                     md5=archive_dict['md5'])
            devkit_folder = _splitexts(os.path.basename(archive_dict['url']))[0]
            meta = parse_devkit(os.path.join(tmpdir, devkit_folder))
            self._save_meta_file(*meta)

            shutil.rmtree(tmpdir)

        if not os.path.isdir(self.split_folder):
            archive_dict = ARCHIVE_DICT[self.split]
            download_and_extract_tar(archive_dict['url'], self.root,
                                     extract_root=self.split_folder,
                                     md5=archive_dict['md5'])

            if self.split == 'train':
                prepare_train_folder(self.split_folder)
            elif self.split == 'val':
                val_wnids = self._load_meta_file()[1]
                prepare_val_folder(self.split_folder, val_wnids)
        else:
            msg = ("You set download=True, but a folder '{}' already exist in "
                   "the root directory. If you want to re-download or re-extract the "
                   "archive, delete the folder.")
            print(msg.format(self.split)) 
开发者ID:kakaobrain,项目名称:fast-autoaugment,代码行数:32,代码来源:imagenet.py

示例5: _load_meta_file

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _load_meta_file(self):
        if check_integrity(self.meta_file):
            return torch.load(self.meta_file)
        raise RuntimeError("Meta file not found or corrupted.",
                           "You can use download=True to create it.") 
开发者ID:kakaobrain,项目名称:fast-autoaugment,代码行数:7,代码来源:imagenet.py

示例6: download_and_extract_tar

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def download_and_extract_tar(url, download_root, extract_root=None, filename=None,
                             md5=None, **kwargs):
    download_root = os.path.expanduser(download_root)
    if extract_root is None:
        extract_root = download_root
    if filename is None:
        filename = os.path.basename(url)

    if not check_integrity(os.path.join(download_root, filename), md5):
        download_url(url, download_root, filename=filename, md5=md5)

    extract_tar(os.path.join(download_root, filename), extract_root, **kwargs) 
开发者ID:kakaobrain,项目名称:fast-autoaugment,代码行数:14,代码来源:imagenet.py

示例7: _load_meta

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _load_meta(self):
        path = os.path.join(self.root, self.base_folder, self.meta['filename'])
        if not utils.check_integrity(path, self.meta['md5']):
            raise RuntimeError('Dataset metadata file not found or corrupted.' +
                               ' You can use download=True to download it')
        with open(path, 'rb') as infile:
            if sys.version_info[0] == 2:
                data = pickle.load(infile)
            else:
                data = pickle.load(infile, encoding='latin1')
            self.classes = data[self.meta['key']]
        self.class_to_idx = {_class: i for i, _class in enumerate(self.classes)} 
开发者ID:automl,项目名称:nasbench-1shot1,代码行数:14,代码来源:utils.py

示例8: _check_integrity

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _check_integrity(self):
        root = self.root
        for fentry in (self.train_list + self.test_list):
            filename, md5 = fentry[0], fentry[1]
            fpath = os.path.join(root, self.base_folder, filename)
            if not utils.check_integrity(fpath, md5):
                return False
        return True 
开发者ID:automl,项目名称:nasbench-1shot1,代码行数:10,代码来源:utils.py

示例9: _check_integrity

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _check_integrity(self):

        root = self.root
        for fentry in (self.train_list + self.test_list):
            filename, md5 = fentry[0], fentry[1]
            fpath = os.path.join(root, self.base_folder, filename)
            if not check_integrity(fpath, md5):
                return False
        return True 
开发者ID:wang3702,项目名称:EnAET,代码行数:11,代码来源:Download_Cifar.py

示例10: _check_integrity

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _check_integrity(self,file_md5,filename):
        root = self.root
        fpath = os.path.join(root, filename)
        return check_integrity(fpath, file_md5) 
开发者ID:wang3702,项目名称:EnAET,代码行数:6,代码来源:Download_SVHN.py

示例11: _check_integrity

# 需要导入模块: from torchvision.datasets import utils [as 别名]
# 或者: from torchvision.datasets.utils import check_integrity [as 别名]
def _check_integrity(self,):
        root = self.root
        for fentry in (self.train_list + self.test_list):
            filename, md5 = fentry[0], fentry[1]
            fpath = os.path.join(root, self.base_folder, filename)
            if not check_integrity(fpath, md5):
                return False
        return True 
开发者ID:wang3702,项目名称:EnAET,代码行数:10,代码来源:Download_STL.py


注:本文中的torchvision.datasets.utils.check_integrity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。