我具有如下所示的对象检测标签。
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'}
我会很感激您的建议。
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()