original_docstring: Load all image paths and labels from JSON annotation files into buffer.
docstring: Load all image paths and labels from JSON annotation files into buffer.
docstring_tokens: Load all image paths and labels from JSON annotation files into buffer .
code: def _load_jsons(self):
          """Load all image paths and labels from JSON annotation files into buffer."""
          items = []
          labels = []
          # lazy import pycocotools
          try_import_pycocotools()
          from pycocotools.coco import COCO
          for split in self._splits:
              anno = os.path.join(self._root, 'annotations', split) + '.json'
              _coco = COCO(anno)
              self._coco.append(_coco)
              classes = [c['name'] for c in _coco.loadCats(_coco.getCatIds())]
              if not classes == self.classes:
                  raise ValueError("Incompatible category names with COCO: ")
              assert classes == self.classes
              json_id_to_contiguous = {
                  v: k for k, v in enumerate(_coco.getCatIds())}
              if self.json_id_to_contiguous is None:
                  self.json_id_to_contiguous = json_id_to_contiguous
                  self.contiguous_id_to_json = {
                      v: k for k, v in self.json_id_to_contiguous.items()}
              else:
                  assert self.json_id_to_contiguous == json_id_to_contiguous
              # iterate through the annotations
              image_ids = sorted(_coco.getImgIds())
              for entry in _coco.loadImgs(image_ids):
                  dirname, filename = entry['coco_url'].split('/')[-2:]
                  abs_path = os.path.join(self._root, dirname, filename)
                  if not os.path.exists(abs_path):
                      raise IOError('Image: {} not exists.'.format(abs_path))
                  label = self._check_load_keypoints(_coco, entry)
                  if not label:
                      continue
  
                  # num of items are relative to person, not image
                  for obj in label:
                      items.append(abs_path)
                      labels.append(obj)
          return items, labels
code_tokens: def _load_jsons ( self ) : items = [ ] labels = [ ] try_import_pycocotools ( ) from pycocotools . coco import COCO for split in self . _splits : anno = os . path . join ( self . _root , 'annotations' , split ) + '.json' _coco = COCO ( anno ) self . _coco . append ( _coco ) classes = [ c [ 'name' ] for c in _coco . loadCats ( _coco . getCatIds ( ) ) ] if not classes == self . classes : raise ValueError ( "Incompatible category names with COCO: " ) assert classes == self . classes json_id_to_contiguous = { v : k for k , v in enumerate ( _coco . getCatIds ( ) ) } if self . json_id_to_contiguous is None : self . json_id_to_contiguous = json_id_to_contiguous self . contiguous_id_to_json = { v : k for k , v in self . json_id_to_contiguous . items ( ) } else : assert self . json_id_to_contiguous == json_id_to_contiguous image_ids = sorted ( _coco . getImgIds ( ) ) for entry in _coco . loadImgs ( image_ids ) : dirname , filename = entry [ 'coco_url' ] . split ( '/' ) [ - 2 : ] abs_path = os . path . join ( self . _root , dirname , filename ) if not os . path . exists ( abs_path ) : raise IOError ( 'Image: {} not exists.' . format ( abs_path ) ) label = self . _check_load_keypoints ( _coco , entry ) if not label : continue for obj in label : items . append ( abs_path ) labels . append ( obj ) return items , labels
short_docstring: Load all image paths and labels from JSON annotation files into buffer.
short_docstring_tokens: Load all image paths and labels from JSON annotation files into buffer .
comment: """Load all image paths and labels from JSON annotation files into buffer."""$SEP$# lazy import pycocotools$SEP$# iterate through the annotations$SEP$# num of items are relative to person, not image