Skip to content

Commit

Permalink
Update datasets to use PathManager
Browse files Browse the repository at this point in the history
Summary: Load datasets from manifold instead of gluster. Imagenet is loaded from local package so does not need to be updated

Reviewed By: vaibhava0

Differential Revision: D24165539

fbshipit-source-id: c17ae1e0cf0c6069861de1d9854969ae1af81efc
  • Loading branch information
theschnitz authored and facebook-github-bot committed Jan 13, 2021
1 parent b5063a6 commit 149fde7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pycls/datasets/cifar10.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy as np
import pycls.core.logging as logging
import torch.utils.data
from iopath.common.file_io import g_pathmgr
from pycls.core.config import cfg


Expand All @@ -27,7 +28,7 @@ class Cifar10(torch.utils.data.Dataset):
"""CIFAR-10 dataset."""

def __init__(self, data_path, split):
assert os.path.exists(data_path), "Data path '{}' not found".format(data_path)
assert g_pathmgr.exists(data_path), "Data path '{}' not found".format(data_path)
splits = ["train", "test"]
assert split in splits, "Split '{}' not supported for cifar".format(split)
logger.info("Constructing CIFAR-10 {}...".format(split))
Expand All @@ -47,7 +48,7 @@ def _load_data(self):
inputs, labels = [], []
for batch_name in batch_names:
batch_path = os.path.join(self._data_path, batch_name)
with open(batch_path, "rb") as f:
with g_pathmgr.open(batch_path, "rb") as f:
data = pickle.load(f, encoding="bytes")
inputs.append(data[b"data"])
labels += data[b"labels"]
Expand Down

0 comments on commit 149fde7

Please sign in to comment.