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

Method draw_patches

tensorpack/utils/viz.py:131–148  ·  view source on GitHub ↗
(self, plist)

Source from the content-addressed store, hash-verified

129 self.channel), dtype='uint8')
130
131 def draw_patches(self, plist):
132 assert self.nr_row * self.nr_col >= len(plist), \
133 "{}*{} < {}".format(self.nr_row, self.nr_col, len(plist))
134 if self.channel == 3 and plist.shape[3] == 1:
135 plist = np.repeat(plist, 3, axis=3)
136 cur_row, cur_col = 0, 0
137 if self.channel == 1:
138 self.canvas.fill(self.bgcolor)
139 else:
140 self.canvas[:, :, :] = self.bgcolor
141 for patch in plist:
142 r0 = cur_row * (self.ph + self.border)
143 c0 = cur_col * (self.pw + self.border)
144 self.canvas[r0:r0 + self.ph, c0:c0 + self.pw] = patch
145 cur_col += 1
146 if cur_col == self.nr_col:
147 cur_col = 0
148 cur_row += 1
149
150 def get_patchid_from_coord(self, x, y):
151 x = x // (self.pw + self.border)

Callers 2

stack_patchesFunction · 0.95
gen_stack_patchesFunction · 0.95

Calls 2

formatMethod · 0.80
fillMethod · 0.80

Tested by

no test coverage detected