MCPcopy Create free account
hub / github.com/Vegetebird/GraphMLP / prep_image

Function prep_image

demo/lib/yolov3/preprocess.py:24–38  ·  view source on GitHub ↗

Prepare image for inputting to the neural network. Returns a Variable

(img, inp_dim)

Source from the content-addressed store, hash-verified

22
23
24def prep_image(img, inp_dim):
25 """
26 Prepare image for inputting to the neural network.
27
28 Returns a Variable
29 """
30 if type(img) == str:
31 orig_im = cv2.imread(img)
32 else:
33 orig_im = img
34 dim = orig_im.shape[1], orig_im.shape[0]
35 img = (letterbox_image(orig_im, (inp_dim, inp_dim)))
36 img_ = img[:, :, ::-1].transpose((2, 0, 1)).copy()
37 img_ = torch.from_numpy(img_).float().div(255.0).unsqueeze(0)
38 return img_, orig_im, dim
39
40
41def prep_image_pil(img, network_dim):

Callers

nothing calls this directly

Calls 1

letterbox_imageFunction · 0.85

Tested by

no test coverage detected