MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / get_imagenet_dataflow

Function get_imagenet_dataflow

examples/ResNet/imagenet_utils.py:67–107  ·  view source on GitHub ↗

Args: augmentors (list[imgaug.Augmentor]): Defaults to `fbresnet_augmentor(isTrain)` Returns: A DataFlow which produces BGR images and labels. See explanations in the tutorial: http://tensorpack.readthedocs.io/tutorial/efficient-dataflow.html

(
        datadir, name, batch_size,
        augmentors=None, parallel=None)

Source from the content-addressed store, hash-verified

65
66
67def get_imagenet_dataflow(
68 datadir, name, batch_size,
69 augmentors=None, parallel=None):
70 """
71 Args:
72 augmentors (list[imgaug.Augmentor]): Defaults to `fbresnet_augmentor(isTrain)`
73
74 Returns: A DataFlow which produces BGR images and labels.
75
76 See explanations in the tutorial:
77 http://tensorpack.readthedocs.io/tutorial/efficient-dataflow.html
78 """
79 assert name in ['train', 'val', 'test']
80 isTrain = name == 'train'
81 assert datadir is not None
82 if augmentors is None:
83 augmentors = fbresnet_augmentor(isTrain)
84 assert isinstance(augmentors, list)
85 if parallel is None:
86 parallel = min(40, multiprocessing.cpu_count() // 2) # assuming hyperthreading
87
88 if isTrain:
89 ds = dataset.ILSVRC12(datadir, name, shuffle=True)
90 ds = AugmentImageComponent(ds, augmentors, copy=False)
91 if parallel < 16:
92 logger.warn("DataFlow may become the bottleneck when too few processes are used.")
93 ds = MultiProcessRunnerZMQ(ds, parallel)
94 ds = BatchData(ds, batch_size, remainder=False)
95 else:
96 ds = dataset.ILSVRC12Files(datadir, name, shuffle=False)
97 aug = imgaug.AugmentorList(augmentors)
98
99 def mapf(dp):
100 fname, cls = dp
101 im = cv2.imread(fname, cv2.IMREAD_COLOR)
102 im = aug.augment(im)
103 return im, cls
104 ds = MultiThreadMapData(ds, parallel, mapf, buffer_size=2000, strict=True)
105 ds = BatchData(ds, batch_size, remainder=True)
106 ds = MultiProcessRunnerZMQ(ds, 1)
107 return ds
108
109
110"""

Callers 4

load-resnet.pyFile · 0.90
get_configFunction · 0.90
imagenet-resnet.pyFile · 0.90
imagenet_utils.pyFile · 0.70

Calls 5

BatchDataClass · 0.90
MultiThreadMapDataClass · 0.90
fbresnet_augmentorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…