(img)
| 33 | |
| 34 | |
| 35 | def preprocess(img): |
| 36 | w, h = img.size |
| 37 | img = img.crop((0, (h - w) // 2, w, h - (h - w) // 2)) |
| 38 | img = img.resize((112, 112)) |
| 39 | img = np.array(img).astype(np.float32) |
| 40 | img = np.rollaxis(img, 2, 0) |
| 41 | img = np.expand_dims(img, axis=0) |
| 42 | return img |
| 43 | |
| 44 | |
| 45 | def get_image(): |