FasterRCNNDetection/data/coco_camera_traps_dataset.py [91:108]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def __init__(self, root, ann_file, max_images=None):
        self.root = root
        print('Loading annotations from: ' + os.path.basename(ann_file))
        with open(ann_file) as data_file:
            ann_data = json.load(data_file)

        # set up the filenames and annotations
        self.impaths = np.array([aa['file_name'] for aa in ann_data['images']])
        self.image_ids = np.array([aa['id'] for aa in ann_data['images']])
        
        # This loop reads the bboxes and corresponding labels and assigns them
        # the correct image. Kind of slow at the moment...
        self.bboxes = [[] for _ in self.image_ids]
        self.labels = [[] for _ in self.image_ids]
        # To speed up the loop, creating mapping for image_id to list index 
        image_id_to_idx = {id:idx for idx, id in enumerate(self.image_ids)}
        for ann in ann_data['annotations']:
            idx = image_id_to_idx[ann['image_id']] 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



FasterRCNNDetection/data/iwildcam_dataset.py [90:108]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def __init__(self, root, ann_file, max_images=None):

        self.root = root
        print('Loading annotations from: ' + os.path.basename(ann_file))
        with open(ann_file) as data_file:
            ann_data = json.load(data_file)

        # set up the filenames and annotations
        self.impaths = np.array([aa['file_name'] for aa in ann_data['images']])
        self.image_ids = np.array([aa['id'] for aa in ann_data['images']])
        
        # This loop reads the bboxes and corresponding labels and assigns them
        # the correct image. Kind of slow at the moment...
        self.bboxes = [[] for _ in self.image_ids]
        self.labels = [[] for _ in self.image_ids]
        # To speed up the loop, creating mapping for image_id to list index 
        image_id_to_idx = {id:idx for idx, id in enumerate(self.image_ids)}
        for ann in ann_data['annotations']:
            idx = image_id_to_idx[ann['image_id']]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



