prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Docs for using `output` with `ObjectDetector`
  ## 🐛 Bug
  
  I'am trying to use FiftyOneDetectionLabelsOutput output for Object detection but i got the following error
  
  model = model_type.model(backbone=backbone, num_classes=num_classes, **kwargs)
  TypeError: model() got an unexpected keyword argument 'output'
  
  How can i correctly setup the output?
  
  ### To Reproduce
  from flash.image.detection.output import FiftyOneDetectionLabelsOutput
  from flash.image import ObjectDetector
  
  out= FiftyOneDetectionLabelsOutput(threshold=0.7)
  objDetc=ObjectDetector(num_classes=81,backbone="medium",head="yolov5",output=out)
  
  
  ### Expected behavior
  Class init correctly as described in documentation
  
  https://lightning-flash.readthedocs.io/en/latest/api/generated/flash.image.detection.model.ObjectDetector.html#flash.image.detection.model.ObjectDetector
  There is a parameter output in the description. Maybe is an old value
  
  
  ### Environment
  
   - OS (e.g., Linux): Linux
   - Python version: 3.8
   - PyTorch/Lightning/Flash Version (e.g., 1.10/1.5/0.7): 1.10 / 1.5.8 / 0.7.4
   - GPU models and configuration: cuda 11.3
   
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `flash/image/detection/model.py`
  Content:
  ```
  1 # Copyright The PyTorch Lightning team.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License");
  4 # you may not use this file except in compliance with the License.
  5 # You may obtain a copy of the License at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # Unless required by applicable law or agreed to in writing, software
  10 # distributed under the License is distributed on an "AS IS" BASIS,
  11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12 # See the License for the specific language governing permissions and
  13 # limitations under the License.
  14 from typing import Any, Dict, List, Optional, Type, Union
  15 
  16 from flash.core.adapter import AdapterTask
  17 from flash.core.data.io.input import ServeInput
  18 from flash.core.data.io.output import Output
  19 from flash.core.integrations.icevision.transforms import IceVisionInputTransform
  20 from flash.core.model import Task
  21 from flash.core.registry import FlashRegistry
  22 from flash.core.serve import Composition
  23 from flash.core.utilities.imports import requires
  24 from flash.core.utilities.types import INPUT_TRANSFORM_TYPE, LR_SCHEDULER_TYPE, OPTIMIZER_TYPE
  25 from flash.image.data import ImageDeserializer
  26 from flash.image.detection.backbones import OBJECT_DETECTION_HEADS
  27 from flash.image.detection.output import OBJECT_DETECTION_OUTPUTS
  28 
  29 
  30 class ObjectDetector(AdapterTask):
  31     """The ``ObjectDetector`` is a :class:`~flash.Task` for detecting objects in images. For more details, see
  32     :ref:`object_detection`.
  33 
  34     Args:
  35         num_classes: The number of object classes.
  36         backbone: String indicating the backbone CNN architecture to use.
  37         head: String indicating the head module to use ontop of the backbone.
  38         pretrained: Whether the model should be loaded with it's pretrained weights.
  39         optimizer: Optimizer to use for training.
  40         lr_scheduler: The LR scheduler to use during training.
  41         learning_rate: The learning rate to use for training.
  42         output: The :class:`~flash.core.data.io.output.Output` to use when formatting prediction outputs.
  43         predict_kwargs: dictionary containing parameters that will be used during the prediction phase.
  44         kwargs: additional kwargs nessesary for initializing the backbone task
  45     """
  46 
  47     heads: FlashRegistry = OBJECT_DETECTION_HEADS
  48     outputs = Task.outputs + OBJECT_DETECTION_OUTPUTS
  49 
  50     required_extras: List[str] = ["image", "icevision", "effdet"]
  51 
  52     def __init__(
  53         self,
  54         num_classes: Optional[int] = None,
  55         labels: Optional[List[str]] = None,
  56         backbone: Optional[str] = "resnet18_fpn",
  57         head: Optional[str] = "retinanet",
  58         pretrained: bool = True,
  59         optimizer: OPTIMIZER_TYPE = "Adam",
  60         lr_scheduler: LR_SCHEDULER_TYPE = None,
  61         learning_rate: Optional[float] = None,
  62         predict_kwargs: Dict = None,
  63         **kwargs: Any,
  64     ):
  65         self.save_hyperparameters()
  66 
  67         if labels is not None and num_classes is None:
  68             num_classes = len(labels)
  69 
  70         self.labels = labels
  71         self.num_classes = num_classes
  72 
  73         predict_kwargs = predict_kwargs if predict_kwargs else {}
  74         metadata = self.heads.get(head, with_metadata=True)
  75         adapter = metadata["metadata"]["adapter"].from_task(
  76             self,
  77             num_classes=num_classes,
  78             backbone=backbone,
  79             head=head,
  80             pretrained=pretrained,
  81             predict_kwargs=predict_kwargs,
  82             **kwargs,
  83         )
  84 
  85         super().__init__(
  86             adapter,
  87             learning_rate=learning_rate,
  88             optimizer=optimizer,
  89             lr_scheduler=lr_scheduler,
  90         )
  91 
  92     def _ci_benchmark_fn(self, history: List[Dict[str, Any]]) -> None:
  93         """This function is used only for debugging usage with CI."""
  94         # todo
  95 
  96     @property
  97     def predict_kwargs(self) -> Dict[str, Any]:
  98         """The kwargs used for the prediction step."""
  99         return self.adapter.predict_kwargs
  100 
  101     @predict_kwargs.setter
  102     def predict_kwargs(self, predict_kwargs: Dict[str, Any]):
  103         self.adapter.predict_kwargs = predict_kwargs
  104 
  105     @requires("serve")
  106     def serve(
  107         self,
  108         host: str = "127.0.0.1",
  109         port: int = 8000,
  110         sanity_check: bool = True,
  111         input_cls: Optional[Type[ServeInput]] = ImageDeserializer,
  112         transform: INPUT_TRANSFORM_TYPE = IceVisionInputTransform,
  113         transform_kwargs: Optional[Dict] = None,
  114         output: Optional[Union[str, Output]] = None,
  115     ) -> Composition:
  116         return super().serve(host, port, sanity_check, input_cls, transform, transform_kwargs, output)
  117
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/flash/image/detection/model.py b/flash/image/detection/model.py
  --- a/flash/image/detection/model.py
  +++ b/flash/image/detection/model.py
  @@ -39,7 +39,6 @@
           optimizer: Optimizer to use for training.
           lr_scheduler: The LR scheduler to use during training.
           learning_rate: The learning rate to use for training.
  -        output: The :class:`~flash.core.data.io.output.Output` to use when formatting prediction outputs.
           predict_kwargs: dictionary containing parameters that will be used during the prediction phase.
           kwargs: additional kwargs nessesary for initializing the backbone task
       """
  
verification_info: {"golden_diff": "diff --git a/flash/image/detection/model.py b/flash/image/detection/model.py\n--- a/flash/image/detection/model.py\n+++ b/flash/image/detection/model.py\n@@ -39,7 +39,6 @@\n         optimizer: Optimizer to use for training.\n         lr_scheduler: The LR scheduler to use during training.\n         learning_rate: The learning rate to use for training.\n-        output: The :class:`~flash.core.data.io.output.Output` to use when formatting prediction outputs.\n         predict_kwargs: dictionary containing parameters that will be used during the prediction phase.\n         kwargs: additional kwargs nessesary for initializing the backbone task\n     \"\"\"\n", "issue": "Docs for using `output` with `ObjectDetector`\n## \ud83d\udc1b Bug\r\n\r\nI'am trying to use FiftyOneDetectionLabelsOutput output for Object detection but i got the following error\r\n\r\nmodel = model_type.model(backbone=backbone, num_classes=num_classes, **kwargs)\r\nTypeError: model() got an unexpected keyword argument 'output'\r\n\r\nHow can i correctly setup the output?\r\n\r\n### To Reproduce\r\nfrom flash.image.detection.output import FiftyOneDetectionLabelsOutput\r\nfrom flash.image import ObjectDetector\r\n\r\nout= FiftyOneDetectionLabelsOutput(threshold=0.7)\r\nobjDetc=ObjectDetector(num_classes=81,backbone=\"medium\",head=\"yolov5\",output=out)\r\n\r\n\r\n### Expected behavior\r\nClass init correctly as described in documentation\r\n\r\nhttps://lightning-flash.readthedocs.io/en/latest/api/generated/flash.image.detection.model.ObjectDetector.html#flash.image.detection.model.ObjectDetector\r\nThere is a parameter output in the description. Maybe is an old value\r\n\r\n\r\n### Environment\r\n\r\n - OS (e.g., Linux): Linux\r\n - Python version: 3.8\r\n - PyTorch/Lightning/Flash Version (e.g., 1.10/1.5/0.7): 1.10 / 1.5.8 / 0.7.4\r\n - GPU models and configuration: cuda 11.3\r\n \n", "before_files": [{"content": "# Copyright The PyTorch Lightning team.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom typing import Any, Dict, List, Optional, Type, Union\n\nfrom flash.core.adapter import AdapterTask\nfrom flash.core.data.io.input import ServeInput\nfrom flash.core.data.io.output import Output\nfrom flash.core.integrations.icevision.transforms import IceVisionInputTransform\nfrom flash.core.model import Task\nfrom flash.core.registry import FlashRegistry\nfrom flash.core.serve import Composition\nfrom flash.core.utilities.imports import requires\nfrom flash.core.utilities.types import INPUT_TRANSFORM_TYPE, LR_SCHEDULER_TYPE, OPTIMIZER_TYPE\nfrom flash.image.data import ImageDeserializer\nfrom flash.image.detection.backbones import OBJECT_DETECTION_HEADS\nfrom flash.image.detection.output import OBJECT_DETECTION_OUTPUTS\n\n\nclass ObjectDetector(AdapterTask):\n    \"\"\"The ``ObjectDetector`` is a :class:`~flash.Task` for detecting objects in images. For more details, see\n    :ref:`object_detection`.\n\n    Args:\n        num_classes: The number of object classes.\n        backbone: String indicating the backbone CNN architecture to use.\n        head: String indicating the head module to use ontop of the backbone.\n        pretrained: Whether the model should be loaded with it's pretrained weights.\n        optimizer: Optimizer to use for training.\n        lr_scheduler: The LR scheduler to use during training.\n        learning_rate: The learning rate to use for training.\n        output: The :class:`~flash.core.data.io.output.Output` to use when formatting prediction outputs.\n        predict_kwargs: dictionary containing parameters that will be used during the prediction phase.\n        kwargs: additional kwargs nessesary for initializing the backbone task\n    \"\"\"\n\n    heads: FlashRegistry = OBJECT_DETECTION_HEADS\n    outputs = Task.outputs + OBJECT_DETECTION_OUTPUTS\n\n    required_extras: List[str] = [\"image\", \"icevision\", \"effdet\"]\n\n    def __init__(\n        self,\n        num_classes: Optional[int] = None,\n        labels: Optional[List[str]] = None,\n        backbone: Optional[str] = \"resnet18_fpn\",\n        head: Optional[str] = \"retinanet\",\n        pretrained: bool = True,\n        optimizer: OPTIMIZER_TYPE = \"Adam\",\n        lr_scheduler: LR_SCHEDULER_TYPE = None,\n        learning_rate: Optional[float] = None,\n        predict_kwargs: Dict = None,\n        **kwargs: Any,\n    ):\n        self.save_hyperparameters()\n\n        if labels is not None and num_classes is None:\n            num_classes = len(labels)\n\n        self.labels = labels\n        self.num_classes = num_classes\n\n        predict_kwargs = predict_kwargs if predict_kwargs else {}\n        metadata = self.heads.get(head, with_metadata=True)\n        adapter = metadata[\"metadata\"][\"adapter\"].from_task(\n            self,\n            num_classes=num_classes,\n            backbone=backbone,\n            head=head,\n            pretrained=pretrained,\n            predict_kwargs=predict_kwargs,\n            **kwargs,\n        )\n\n        super().__init__(\n            adapter,\n            learning_rate=learning_rate,\n            optimizer=optimizer,\n            lr_scheduler=lr_scheduler,\n        )\n\n    def _ci_benchmark_fn(self, history: List[Dict[str, Any]]) -> None:\n        \"\"\"This function is used only for debugging usage with CI.\"\"\"\n        # todo\n\n    @property\n    def predict_kwargs(self) -> Dict[str, Any]:\n        \"\"\"The kwargs used for the prediction step.\"\"\"\n        return self.adapter.predict_kwargs\n\n    @predict_kwargs.setter\n    def predict_kwargs(self, predict_kwargs: Dict[str, Any]):\n        self.adapter.predict_kwargs = predict_kwargs\n\n    @requires(\"serve\")\n    def serve(\n        self,\n        host: str = \"127.0.0.1\",\n        port: int = 8000,\n        sanity_check: bool = True,\n        input_cls: Optional[Type[ServeInput]] = ImageDeserializer,\n        transform: INPUT_TRANSFORM_TYPE = IceVisionInputTransform,\n        transform_kwargs: Optional[Dict] = None,\n        output: Optional[Union[str, Output]] = None,\n    ) -> Composition:\n        return super().serve(host, port, sanity_check, input_cls, transform, transform_kwargs, output)\n", "path": "flash/image/detection/model.py"}], "after_files": [{"content": "# Copyright The PyTorch Lightning team.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom typing import Any, Dict, List, Optional, Type, Union\n\nfrom flash.core.adapter import AdapterTask\nfrom flash.core.data.io.input import ServeInput\nfrom flash.core.data.io.output import Output\nfrom flash.core.integrations.icevision.transforms import IceVisionInputTransform\nfrom flash.core.model import Task\nfrom flash.core.registry import FlashRegistry\nfrom flash.core.serve import Composition\nfrom flash.core.utilities.imports import requires\nfrom flash.core.utilities.types import INPUT_TRANSFORM_TYPE, LR_SCHEDULER_TYPE, OPTIMIZER_TYPE\nfrom flash.image.data import ImageDeserializer\nfrom flash.image.detection.backbones import OBJECT_DETECTION_HEADS\nfrom flash.image.detection.output import OBJECT_DETECTION_OUTPUTS\n\n\nclass ObjectDetector(AdapterTask):\n    \"\"\"The ``ObjectDetector`` is a :class:`~flash.Task` for detecting objects in images. For more details, see\n    :ref:`object_detection`.\n\n    Args:\n        num_classes: The number of object classes.\n        backbone: String indicating the backbone CNN architecture to use.\n        head: String indicating the head module to use ontop of the backbone.\n        pretrained: Whether the model should be loaded with it's pretrained weights.\n        optimizer: Optimizer to use for training.\n        lr_scheduler: The LR scheduler to use during training.\n        learning_rate: The learning rate to use for training.\n        predict_kwargs: dictionary containing parameters that will be used during the prediction phase.\n        kwargs: additional kwargs nessesary for initializing the backbone task\n    \"\"\"\n\n    heads: FlashRegistry = OBJECT_DETECTION_HEADS\n    outputs = Task.outputs + OBJECT_DETECTION_OUTPUTS\n\n    required_extras: List[str] = [\"image\", \"icevision\", \"effdet\"]\n\n    def __init__(\n        self,\n        num_classes: Optional[int] = None,\n        labels: Optional[List[str]] = None,\n        backbone: Optional[str] = \"resnet18_fpn\",\n        head: Optional[str] = \"retinanet\",\n        pretrained: bool = True,\n        optimizer: OPTIMIZER_TYPE = \"Adam\",\n        lr_scheduler: LR_SCHEDULER_TYPE = None,\n        learning_rate: Optional[float] = None,\n        predict_kwargs: Dict = None,\n        **kwargs: Any,\n    ):\n        self.save_hyperparameters()\n\n        if labels is not None and num_classes is None:\n            num_classes = len(labels)\n\n        self.labels = labels\n        self.num_classes = num_classes\n\n        predict_kwargs = predict_kwargs if predict_kwargs else {}\n        metadata = self.heads.get(head, with_metadata=True)\n        adapter = metadata[\"metadata\"][\"adapter\"].from_task(\n            self,\n            num_classes=num_classes,\n            backbone=backbone,\n            head=head,\n            pretrained=pretrained,\n            predict_kwargs=predict_kwargs,\n            **kwargs,\n        )\n\n        super().__init__(\n            adapter,\n            learning_rate=learning_rate,\n            optimizer=optimizer,\n            lr_scheduler=lr_scheduler,\n        )\n\n    def _ci_benchmark_fn(self, history: List[Dict[str, Any]]) -> None:\n        \"\"\"This function is used only for debugging usage with CI.\"\"\"\n        # todo\n\n    @property\n    def predict_kwargs(self) -> Dict[str, Any]:\n        \"\"\"The kwargs used for the prediction step.\"\"\"\n        return self.adapter.predict_kwargs\n\n    @predict_kwargs.setter\n    def predict_kwargs(self, predict_kwargs: Dict[str, Any]):\n        self.adapter.predict_kwargs = predict_kwargs\n\n    @requires(\"serve\")\n    def serve(\n        self,\n        host: str = \"127.0.0.1\",\n        port: int = 8000,\n        sanity_check: bool = True,\n        input_cls: Optional[Type[ServeInput]] = ImageDeserializer,\n        transform: INPUT_TRANSFORM_TYPE = IceVisionInputTransform,\n        transform_kwargs: Optional[Dict] = None,\n        output: Optional[Union[str, Output]] = None,\n    ) -> Composition:\n        return super().serve(host, port, sanity_check, input_cls, transform, transform_kwargs, output)\n", "path": "flash/image/detection/model.py"}]}