MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / __init__

Method __init__

tensorpack/dataflow/image.py:49–65  ·  view source on GitHub ↗

Args: files (list): list of file paths. channel (int): 1 or 3. Will convert grayscale to RGB images if channel==3. Will produce (h, w, 1) array if channel==1. resize (tuple): int or (h, w) tuple. If given, resize the image.

(self, files, channel=3, resize=None, shuffle=False)

Source from the content-addressed store, hash-verified

47class ImageFromFile(RNGDataFlow):
48 """ Produce images read from a list of files as (h, w, c) arrays. """
49 def __init__(self, files, channel=3, resize=None, shuffle=False):
50 """
51 Args:
52 files (list): list of file paths.
53 channel (int): 1 or 3. Will convert grayscale to RGB images if channel==3.
54 Will produce (h, w, 1) array if channel==1.
55 resize (tuple): int or (h, w) tuple. If given, resize the image.
56 """
57 assert len(files), "No image files given to ImageFromFile!"
58 self.files = files
59 self.channel = int(channel)
60 assert self.channel in [1, 3], self.channel
61 self.imread_mode = cv2.IMREAD_GRAYSCALE if self.channel == 1 else cv2.IMREAD_COLOR
62 if resize is not None:
63 resize = shape2d(resize)
64 self.resize = resize
65 self.shuffle = shuffle
66
67 def __len__(self):
68 return len(self.files)

Callers 3

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 1

shape2dFunction · 0.85

Tested by

no test coverage detected