apply transformation to the image. crop the image ot 640 short edge by default
(image_pth)
| 21 | |
| 22 | |
| 23 | def prepare_image(image_pth): |
| 24 | """ |
| 25 | apply transformation to the image. crop the image ot 640 short edge by default |
| 26 | """ |
| 27 | image = Image.open(image_pth).convert('RGB') |
| 28 | t = [] |
| 29 | t.append(transforms.Resize(640, interpolation=Image.BICUBIC)) |
| 30 | transform1 = transforms.Compose(t) |
| 31 | image_ori = transform1(image) |
| 32 | |
| 33 | image_ori = np.asarray(image_ori) |
| 34 | images = torch.from_numpy(image_ori.copy()).permute(2, 0, 1).cuda() |
| 35 | |
| 36 | return image_ori, images |
| 37 | |
| 38 | |
| 39 | def build_semantic_sam(model_type, ckpt): |
nothing calls this directly
no outgoing calls
no test coverage detected