preprocess() emulate the pre-processing occurring in the vgg16 caffe prototxt.
(self, im)
| 25 | self.scale = scale |
| 26 | |
| 27 | def preprocess(self, im): |
| 28 | """ |
| 29 | preprocess() emulate the pre-processing occurring in the vgg16 caffe |
| 30 | prototxt. |
| 31 | """ |
| 32 | |
| 33 | im = np.float32(im) |
| 34 | im = im[:, :, ::-1] # change to BGR |
| 35 | im -= self.mean |
| 36 | im *= self.scale |
| 37 | im = im.transpose((2, 0, 1)) |
| 38 | |
| 39 | return im |
| 40 | |
| 41 | def deprocess(self, im): |
| 42 | """ |