class_docstr: The ``InstanceSegmentation`` is a :class:`~flash.Task` for detecting objects in images. For more details, see
  :ref:`object_detection`.
  
  Args:
      num_classes: The number of object classes.
      backbone: String indicating the backbone CNN architecture to use.
      head: String indicating the head module to use on top of the backbone.
      pretrained: Whether the model should be loaded with it's pretrained weights.
      optimizer: Optimizer to use for training.
      lr_scheduler: The LR scheduler to use during training.
      learning_rate: The learning rate to use for training.
      predict_kwargs: dictionary containing parameters that will be used during the prediction phase.
      **kwargs: additional kwargs used for initializing the task
class_docstr_tok: ["The","``","InstanceSegmentation","``","is","a",":","class",":","`","~flash.Task","`","for","detecting","objects","in","images",".","For","more","details",",","see",":","ref",":","`","object_detection","`",".","Args",":","num_classes",":","The","number","of","object","classes",".","backbone",":","String","indicating","the","backbone","CNN","architecture","to","use",".","head",":","String","indicating","the","head","module","to","use","on","top","of","the","backbone",".","pretrained",":","Whether","the","model","should","be","loaded","with","it","'s","pretrained","weights",".","optimizer",":","Optimizer","to","use","for","training",".","lr_scheduler",":","The","LR","scheduler","to","use","during","training",".","learning_rate",":","The","learning","rate","to","use","for","training",".","predict_kwargs",":","dictionary","containing","parameters","that","will","be","used","during","the","prediction","phase",".","*","*","kwargs",":","additional","kwargs","used","for","initializing","the","task"]
code: def __init__(
      self,
      num_classes: int,
      backbone: Optional[str] = "resnet18_fpn",
      head: Optional[str] = "mask_rcnn",
      pretrained: bool = True,
      optimizer: OPTIMIZER_TYPE = "Adam",
      lr_scheduler: LR_SCHEDULER_TYPE = None,
      learning_rate: Optional[float] = None,
      output_transform: OUTPUT_TRANSFORM_TYPE = InstanceSegmentationOutputTransform(),
      predict_kwargs: Dict = None,
      **kwargs: Any,
  ):
      self.save_hyperparameters()
  
      predict_kwargs = predict_kwargs if predict_kwargs else {}
      metadata = self.heads.get(head, with_metadata=True)
      adapter = metadata["metadata"]["adapter"].from_task(
          self,
          num_classes=num_classes,
          backbone=backbone,
          head=head,
          pretrained=pretrained,
          predict_kwargs=predict_kwargs,
          **kwargs,
      )
  
      super().__init__(
          adapter,
          learning_rate=learning_rate,
          optimizer=optimizer,
          lr_scheduler=lr_scheduler,
          output_transform=output_transform,
      )
  
file_path: lightning-flash/src/flash/image/instance_segmentation/model.py
imports: from typing import Any, Dict, List, Optional
  from flash.core.adapter import AdapterTask
  from flash.core.registry import FlashRegistry
  from flash.core.utilities.types import LR_SCHEDULER_TYPE, OPTIMIZER_TYPE, OUTPUT_TRANSFORM_TYPE
  from flash.image.instance_segmentation.backbones import INSTANCE_SEGMENTATION_HEADS
  from flash.image.instance_segmentation.data import InstanceSegmentationOutputTransform
label_desc: Use image node_id 1 to create a new InstanceSegmentation object from inherited base classes: AdapterTask with example: obj = InstanceSegmentation(num_classes, backbone, head, pretrained, optimizer, lr_scheduler, learning_rate, output_transform, predict_kwargs)