segimg.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Semi-automatic-Annotation 作者: Luoyadan 项目源码 文件源码
def _ID2label_dict_add(self, ID, label):
        """
        add pair ID - label
        """
        print "@@@@@@@@@@@ [_ID2label_dict_add]>> ID: {}; label: {}".format(ID, label)
        print "1 self.line_ID2label: ", self.line_ID2label
        unique, counts = np.unique(self.final_ID, return_counts=True)
        unique_label, counts_label = np.unique(self.final_BI, return_counts=True)
        final_ID_cnt = dict(zip(unique, counts))
        final_BI_cnt = dict(zip(unique_label, counts_label))
        print "final_ID_cnt>>>>>>>: ", final_ID_cnt
        print "final_BI_cnt>>>>>>>: ", final_BI_cnt

        if ID not in final_ID_cnt.keys():
            print ">>> try to add pair, but ID: {} not in final_ID".format(ID)
            return

        if label not in final_BI_cnt.keys():
            print ">>> try to add pair, but label: {} not in final_BI".format(label)
            return

        if ID not in self.line_ID2label.keys():
            if ID not in final_ID_cnt.keys():
                print ">>> try to add pair, but ID: {} not in final_ID".format(ID)
            else:
                self.line_ID2label[ID] = [label]
        elif label not in self.line_ID2label[ID]:
            if label not in final_BI_cnt.keys():
                print ">>> try to add pair, but label: {} not in final_BI".format(label)
            else:
                self.line_ID2label[ID].append(label)

        print "2 >>>>>>>>>>>>>>>>>>>: ", self.line_ID2label
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号