def binary_encoder(data):
## Input
## data: dict
## 'id': sample ID(usually name of image file)
## 'image': path to image file
## 'objects': dict
## 'bbox': bounding box coordinate of object
## 'label': label of object
## Output
## string: encoded list
## [id, encoded_image, labels, nbboxes]
## encode image
image = cv2.imread(data['image'])
_, encoded_image = cv2.imencode('.jpg', image)
data['image'] = encoded_image
return pickle.dumps(data, pickle.HIGHEST_PROTOCOL)
评论列表
文章目录