Beispiel #1
0
 def delete_registers(self, registers:list):
     """
     将register列表中的register_image从data中删除
     @param: registers:list 需要删除的register图片的列表,注意列表中的每一项必须是register_path(because list.remove)
     @return: void 副作用,改变了self.data
     """
     print(f"Before deleting, {self.np}_data has registers: {self.total_registers}")
     print("There are {} registers should be deleted.".format(len(registers)))
     register2index = self.register2index()
     for register_path in registers:
         register_name = osp.basename(register_path)
         index = register2index[register_name]
         self.data["images"][index]["register_images"].remove(register_path)
     self.total_registers = ParseNP.total_registers(self.data)
     print(f"After deleting, {self.np}_data has registers: {self.total_registers}")
Beispiel #2
0
 def __init__(self, jsonfile, np:str):
     """
     对象化np_samples.json
     @param: jsonfile 可以是json的地址,或解析后的dict
     @param: np 是n_samples.json就填”n“,反之填”p“
     """
     if isinstance(jsonfile,str):
         self.data = ParseNP.read_json(jsonfile)
     elif isinstance(jsonfile,dict):
         self.data = jsonfile
     else:
         print("Unsupported sample file type: ",jsonfile)
     self.np = np
     self.group_id = self.data["images"][0]["group_id"]
     self.total_samples = ParseNP.total_samples(self.data)
     self.total_requests = ParseNP.total_requests(self.data)
     self.total_registers = ParseNP.total_registers(self.data)