def _read_image_and_box(self, bboxes_csv):
"""Extract the filename from the queue, read the image and
produce a single box
Returns:
image, [y_min, x_min, y_max, x_max, label]
"""
reader = tf.TextLineReader(skip_header_lines=True)
_, row = reader.read(bboxes_csv)
# file ,y_min, x_min, y_max, x_max, label
record_defaults = [[""], [0.], [0.], [0.], [0.], [0.]]
# eg:
# 2008_000033,0.1831831831831832,0.208,0.7717717717717718,0.952,0
filename, y_min, x_min, y_max, x_max, label = tf.decode_csv(
row, record_defaults)
image_path = os.path.join(self._data_dir, 'VOCdevkit', 'VOC2012',
'JPEGImages') + "/" + filename + ".jpg"
# image is normalized in [-1,1]
image = read_image_jpg(image_path)
return image, tf.stack([y_min, x_min, y_max, x_max, label])
PASCALVOC2012Localization.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录