當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。