MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / configure_crop

Method configure_crop

rtpose_wrapper/python/caffe/detector.py:181–216  ·  view source on GitHub ↗

Configure crop dimensions and amount of context for cropping. If context is included, make the special input mean for context padding. Parameters ---------- context_pad : amount of context for cropping.

(self, context_pad)

Source from the content-addressed store, hash-verified

179 return crop
180
181 def configure_crop(self, context_pad):
182 """
183 Configure crop dimensions and amount of context for cropping.
184 If context is included, make the special input mean for context padding.
185
186 Parameters
187 ----------
188 context_pad : amount of context for cropping.
189 """
190 # crop dimensions
191 in_ = self.inputs[0]
192 tpose = self.transformer.transpose[in_]
193 inv_tpose = [tpose[t] for t in tpose]
194 self.crop_dims = np.array(self.blobs[in_].data.shape[1:])[inv_tpose]
195 #.transpose(inv_tpose)
196 # context padding
197 self.context_pad = context_pad
198 if self.context_pad:
199 in_ = self.inputs[0]
200 transpose = self.transformer.transpose.get(in_)
201 channel_order = self.transformer.channel_swap.get(in_)
202 raw_scale = self.transformer.raw_scale.get(in_)
203 # Padding context crops needs the mean in unprocessed input space.
204 mean = self.transformer.mean.get(in_)
205 if mean is not None:
206 inv_transpose = [transpose[t] for t in transpose]
207 crop_mean = mean.copy().transpose(inv_transpose)
208 if channel_order is not None:
209 channel_order_inverse = [channel_order.index(i)
210 for i in range(crop_mean.shape[2])]
211 crop_mean = crop_mean[:, :, channel_order_inverse]
212 if raw_scale is not None:
213 crop_mean /= raw_scale
214 self.crop_mean = crop_mean
215 else:
216 self.crop_mean = np.zeros(self.crop_dims, dtype=np.float32)

Callers 1

__init__Method · 0.95

Calls 3

copyMethod · 0.80
indexMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected