parameters: (self, anno_file, shuffle)
docstring: initialize all entries given annotation json file
  
          Parameters:
          ----------
          anno_file: str
              annotation json file
          shuffle: bool
              whether to shuffle image list
docstring_summary: initialize all entries given annotation json file
docstring_tokens: initialize all entries given annotation json file
function: def _load_all(self, anno_file, shuffle):
          """
          initialize all entries given annotation json file
  
          Parameters:
          ----------
          anno_file: str
              annotation json file
          shuffle: bool
              whether to shuffle image list
          """
          image_set_index = []
          labels = []
          coco = COCO(anno_file)
          img_ids = coco.getImgIds()
          for img_id in img_ids:
              # filename
              image_info = coco.loadImgs(img_id)[0]
              filename = image_info["file_name"]
              subdir = filename.split('_')[1]
              height = image_info["height"]
              width = image_info["width"]
              # label
              anno_ids = coco.getAnnIds(imgIds=img_id)
              annos = coco.loadAnns(anno_ids)
              label = []
              for anno in annos:
                  cat_id = int(anno["category_id"])
                  bbox = anno["bbox"]
                  assert len(bbox) == 4
                  xmin = float(bbox[0]) / width
                  ymin = float(bbox[1]) / height
                  xmax = xmin + float(bbox[2]) / width
                  ymax = ymin + float(bbox[3]) / height
                  label.append([cat_id, xmin, ymin, xmax, ymax, 0])
              if label:
                  labels.append(np.array(label))
                  image_set_index.append(os.path.join(subdir, filename))
  
          if shuffle:
              import random
              indices = range(len(image_set_index))
              random.shuffle(indices)
              image_set_index = [image_set_index[i] for i in indices]
              labels = [labels[i] for i in indices]
          # store the results
          self.image_set_index = image_set_index
          self.labels = labels
function_tokens: def _load_all ( self , anno_file , shuffle ) : image_set_index = [ ] labels = [ ] coco = COCO ( anno_file ) img_ids = coco . getImgIds ( ) for img_id in img_ids : # filename image_info = coco . loadImgs ( img_id ) [ 0 ] filename = image_info [ "file_name" ] subdir = filename . split ( '_' ) [ 1 ] height = image_info [ "height" ] width = image_info [ "width" ] # label anno_ids = coco . getAnnIds ( imgIds = img_id ) annos = coco . loadAnns ( anno_ids ) label = [ ] for anno in annos : cat_id = int ( anno [ "category_id" ] ) bbox = anno [ "bbox" ] assert len ( bbox ) == 4 xmin = float ( bbox [ 0 ] ) / width ymin = float ( bbox [ 1 ] ) / height xmax = xmin + float ( bbox [ 2 ] ) / width ymax = ymin + float ( bbox [ 3 ] ) / height label . append ( [ cat_id , xmin , ymin , xmax , ymax , 0 ] ) if label : labels . append ( np . array ( label ) ) image_set_index . append ( os . path . join ( subdir , filename ) ) if shuffle : import random indices = range ( len ( image_set_index ) ) random . shuffle ( indices ) image_set_index = [ image_set_index [ i ] for i in indices ] labels = [ labels [ i ] for i in indices ] # store the results self . image_set_index = image_set_index self . labels = labels