class_docstr: The Penn-Fudan Pedestrian detection and segmentation dataset
  
  Adapted from the "TorchVision Object Detection Finetuning Tutorial":
  https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html
code: def make_targets(self, idx):
      # load images and masks
      mask_path = self.masks[idx]
  
      # note that we haven't converted the mask to RGB,
      # because each color corresponds to a different instance
      # with 0 being background
      mask = self.mask_loader(mask_path)
      # convert the PIL Image into a numpy array
      mask = np.array(mask)
      # instances are encoded as different colors
      obj_ids = np.unique(mask)
      # first id is the background, so remove it
      obj_ids = obj_ids[1:]
  
      # split the color-encoded mask into a set
      # of binary masks
      masks = mask == obj_ids[:, None, None]
  
      # get bounding box coordinates for each mask
      num_objs = len(obj_ids)
      boxes = []
      for i in range(num_objs):
          pos = np.where(masks[i])
          xmin: np.integer = np.min(pos[1])
          xmax: np.integer = np.max(pos[1])
          ymin: np.integer = np.min(pos[0])
          ymax: np.integer = np.max(pos[0])
          boxes.append([xmin, ymin, xmax, ymax])
  
      # convert everything into a torch.Tensor
      boxes_as_tensor = torch.as_tensor(boxes, dtype=torch.float32)
      del boxes
      # there is only one class
      labels = torch.ones((num_objs,), dtype=torch.int64)
      masks = torch.as_tensor(masks, dtype=torch.uint8)
  
      image_id = torch.tensor([idx])
      area = (boxes_as_tensor[:, 3] - boxes_as_tensor[:, 1]) * (
          boxes_as_tensor[:, 2] - boxes_as_tensor[:, 0]
      )
      # suppose all instances are not crowd
      iscrowd = torch.zeros((num_objs,), dtype=torch.int64)
  
      target = {}
      target["boxes"] = boxes_as_tensor
      target["labels"] = labels
      target["masks"] = masks
      target["image_id"] = image_id
      target["area"] = area
      target["iscrowd"] = iscrowd
      return target
  
file_path: avalanche/avalanche/benchmarks/datasets/penn_fudan/penn_fudan_dataset.py
imports: from pathlib import Path
  from typing import Dict, List, Optional, Sequence, Union
  import numpy
  import torch
  from PIL import Image
  from torchvision.datasets.folder import default_loader
  from avalanche.benchmarks.datasets import SimpleDownloadableDataset, default_dataset_location
  from avalanche.benchmarks.datasets.penn_fudan.penn_fudan_data import penn_fudan_data
label_desc: Use image node_id 3 for calling the PennFudanDataset obj's underlying member method code with example usage: obj.make_targets(idx) and returns: target