MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / prepare_image

Function prepare_image

semantic_sam/build_semantic_sam.py:23–36  ·  view source on GitHub ↗

apply transformation to the image. crop the image ot 640 short edge by default

(image_pth)

Source from the content-addressed store, hash-verified

21
22
23def 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
39def build_semantic_sam(model_type, ckpt):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected