MCPcopy Index your code
hub / github.com/PaddlePaddle/PaddleDetection / decode_image

Function decode_image

deploy/python/preprocess.py:22–41  ·  view source on GitHub ↗

read rgb image Args: im_file (str|np.ndarray): input can be image path or np.ndarray im_info (dict): info of image Returns: im (np.ndarray): processed image (np.ndarray) im_info (dict): info of processed image

(im_file, im_info)

Source from the content-addressed store, hash-verified

20
21
22def decode_image(im_file, im_info):
23 """read rgb image
24 Args:
25 im_file (str|np.ndarray): input can be image path or np.ndarray
26 im_info (dict): info of image
27 Returns:
28 im (np.ndarray): processed image (np.ndarray)
29 im_info (dict): info of processed image
30 """
31 if isinstance(im_file, str):
32 with open(im_file, 'rb') as f:
33 im_read = f.read()
34 data = np.frombuffer(im_read, dtype='uint8')
35 im = cv2.imdecode(data, 1) # BGR mode, but need RGB mode
36 im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
37 else:
38 im = im_file
39 im_info['im_shape'] = np.array(im.shape[:2], dtype=np.float32)
40 im_info['scale_factor'] = np.array([1., 1.], dtype=np.float32)
41 return im, im_info
42
43
44class Resize_Mult32(object):

Callers 7

topdown_unite_predictFunction · 0.90
predict_imageMethod · 0.90
predict_imageMethod · 0.90
predict_imageMethod · 0.90
predict_imageMethod · 0.90
preprocessFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected