Closed ZTurboX closed 3 years ago
请确认是否正确生成了taxonomy呢?
我也发现了这个问题,hierar_relations来自函数get_hierar_relations
self.hierar_relations = get_hierar_relations(self.conf.task_info.hierar_taxonomy, label_map)
存储了父子标签对应的label id
parent_label_id = label_map[parent_label]
children_label_ids = [label_map[child_label] \
for child_label in children_label if child_label in label_map]
hierar_relations[parent_label_id] = children_label_ids
我认为是在处理时,label_map和实际label不一致,所以导致结果为空。 label_map里的父子标签是完整的路径,函数中的child_label和parent_label则是单个节点。 我认为可以修改为
new_label_map = {}
for label_path, idx in label_map.items():
for label in label_path.split('--'):
new_label_map[label] = new_label_map.get(label, idx)
如有不当之处,还请作者大大指正。
@entropy2333 I also encountered the same with empty hierar_relations
with the inconsistency between older label map and categories in the taxonomy file.
我也发现了这个问题,hierar_relations来自函数get_hierar_relations
self.hierar_relations = get_hierar_relations(self.conf.task_info.hierar_taxonomy, label_map)
存储了父子标签对应的label id
parent_label_id = label_map[parent_label] children_label_ids = [label_map[child_label] \ for child_label in children_label if child_label in label_map] hierar_relations[parent_label_id] = children_label_ids
我认为是在处理时,label_map和实际label不一致,所以导致结果为空。 label_map里的父子标签是完整的路径,函数中的child_label和parent_label则是单个节点。 我认为可以修改为
new_label_map = {} for label_path, idx in label_map.items(): for label in label_path.split('--'): new_label_map[label] = new_label_map.get(label, idx)
如有不当之处,还请作者大大指正。 taxonomy 中label路径不完整会导致上述问题存在,可以先按照上述方式修改;
我在层级多标签分类调试时发现,hierar_relations = {} 为空,这是为什么?