computer-vision - 可以在 RecordIO 中用图像打包边界框和标签吗?

标签 computer-vision object-detection mxnet

我正在尝试使用 MXNet/Gluon 训练对象检测模型(特别是图像中一种类型对象的多个实例),并且 im2rec 工具似乎没有将边界框信息添加到 .rec 文件中。

mxnet.recordio.pack_img() 似乎完成了将图像和标签打包在一起的工作,但我找不到在哪里/如何在像素空间中包含边界框信息。来自文档:

label = 4 # label can also be a 1-D array, for example: label = [1,2,3]
id = 2574
header = mx.recordio.IRHeader(0, label, id, 0)
img = cv2.imread('test.jpg')
packed_s = mx.recordio.pack_img(header, img)

标题没有用于放置边界框信息的位置。知道如何做到这一点吗?

最佳答案

我相信我已经找到答案了。 .lst 文件中的标签打包可以包含一组扩展信息。 documentation这里描述了如何预期该信息。

那么剩下的就是编辑 im2rec.py用扩展信息替换单纯的标签索引(截至撰写本文时第 50 和 60 行)。像这样的东西:

def parse_label_file(fp):
    with open(fp, 'r') as f:
        data = f.readlines() # or json.load() if appropriate
        ### Some code here to parse and return the image dimensions
        ### width, height, id, xmin, ymin, xmax, ymax
    return (4, 5, width, id, height, xmin, ymin, xmax, ymax)

...
label_file_path = path[:-4] + ".txt" # or .json as appropriate
if path not in cat:
    cat[path] = parse_label_file(label_file_path)
...

关于computer-vision - 可以在 RecordIO 中用图像打包边界框和标签吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47745218/

相关文章:

neural-network - 如何使用学习参数编写自定义 MXNet 层

python - Tensorflow TFRecordDataset.map 错误

python - 如何在python中计算多边形的IOU?

python - 使用实时视频源监视Python中的模拟量规

c++ - 如何在 C++ 中使用 MXNet 模型?

python - 在Python中使用MXNet预训练图像分类模型

opencv - 如何去除图像数字之间不需要的噪声

algorithm - k表示使用现有信息进行分割

image - Java或C进行图像处理

tensorflow - 如何获得车牌上每个符号的边界框