如何将物体检测标签倒入酱菜中?

问题描述 投票:0回答:1

我具有如下所示的对象检测标签。

item{
    id: 1
    name: 'red_light'
}
item{
    id: 2
    name: 'blue_light'
}
item{
    id: 3
    name: 'blue_left'
}
item{
    id: 4
    name:'red_left'
}
{
    id: 5
    name: 'yellow_light'
}

使用ssd moblienet v2 coco中的标签,我将检测交通信号。如何为标签创建泡菜?当我加载泡菜数据时,应该像

{1:'red_light', 2:'blue_light', 3:'blue_left', 4:'red_left', 5:'yellow_light'}

我会很感激您的建议。

object pickle detection
1个回答
0
投票
坚持原始标签格式并尝试进行转换是不明智的。而是只需输入所需的输出,如下所示。

import argparse import pickle # construct the argument parse and parse the arguments ap = argparse.ArgumentParser() ap.add_argument("-l", "--labels", required=True, help="path to output labels file") args = vars(ap.parse_args()) LABEL_ENCODINGS = {"red_light": 1, "blue_light": 2, "blue_left": 3, "red_left": 4, "yellow_light": 5, } # reverse the label encoding dictionary labels = {v: k for (k, v) in LABEL_ENCODINGS.items()} # save the class labels to disk f = open(args["labels"], "wb") f.write(pickle.dumps(labels)) f.close()

© www.soinside.com 2019 - 2024. All rights reserved.