prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add more logging to the pytorch lighning models.
  The feature consists of two parts:
    1. Add the validation loss to the progress bar by default
    2. Create boolean parameter for extended progress bar logging (showing the different components of the loss)
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `icevision/engines/lightning/lightning_model_adapter.py`
  Content:
  ```
  1 __all__ = ["LightningModelAdapter"]
  2 
  3 import pytorch_lightning as pl
  4 from icevision.imports import *
  5 from icevision.metrics import *
  6 
  7 
  8 class LightningModelAdapter(pl.LightningModule, ABC):
  9     def __init__(self, metrics: List[Metric] = None):
  10         super().__init__()
  11         self.metrics = metrics or []
  12 
  13     def accumulate_metrics(self, preds):
  14         for metric in self.metrics:
  15             metric.accumulate(preds=preds)
  16 
  17     def finalize_metrics(self) -> None:
  18         for metric in self.metrics:
  19             metric_logs = metric.finalize()
  20             for k, v in metric_logs.items():
  21                 self.log(f"{metric.name}/{k}", v)
  22
  ```
  --- 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/icevision/engines/lightning/lightning_model_adapter.py b/icevision/engines/lightning/lightning_model_adapter.py
  --- a/icevision/engines/lightning/lightning_model_adapter.py
  +++ b/icevision/engines/lightning/lightning_model_adapter.py
  @@ -6,9 +6,21 @@
   
   
   class LightningModelAdapter(pl.LightningModule, ABC):
  -    def __init__(self, metrics: List[Metric] = None):
  +    def __init__(
  +        self,
  +        metrics: List[Metric] = None,
  +        metrics_keys_to_log_to_prog_bar: List[tuple] = None,
  +    ):
  +        """
  +        To show a metric in the progressbar a list of tupels can be provided for metrics_keys_to_log_to_prog_bar, the first
  +        entry has to be the name of the metric to log and the second entry the display name in the progressbar. By default the
  +        mAP is logged to the progressbar.
  +        """
           super().__init__()
           self.metrics = metrics or []
  +        self.metrics_keys_to_log_to_prog_bar = metrics_keys_to_log_to_prog_bar or [
  +            ("AP (IoU=0.50:0.95) area=all", "COCOMetric")
  +        ]
   
       def accumulate_metrics(self, preds):
           for metric in self.metrics:
  @@ -18,4 +30,9 @@
           for metric in self.metrics:
               metric_logs = metric.finalize()
               for k, v in metric_logs.items():
  -                self.log(f"{metric.name}/{k}", v)
  +                for entry in self.metrics_keys_to_log_to_prog_bar:
  +                    if entry[0] == k:
  +                        self.log(entry[1], v, prog_bar=True)
  +                        self.log(f"{metric.name}/{k}", v)
  +                    else:
  +                        self.log(f"{metric.name}/{k}", v)
  
verification_info: {"golden_diff": "diff --git a/icevision/engines/lightning/lightning_model_adapter.py b/icevision/engines/lightning/lightning_model_adapter.py\n--- a/icevision/engines/lightning/lightning_model_adapter.py\n+++ b/icevision/engines/lightning/lightning_model_adapter.py\n@@ -6,9 +6,21 @@\n \n \n class LightningModelAdapter(pl.LightningModule, ABC):\n-    def __init__(self, metrics: List[Metric] = None):\n+    def __init__(\n+        self,\n+        metrics: List[Metric] = None,\n+        metrics_keys_to_log_to_prog_bar: List[tuple] = None,\n+    ):\n+        \"\"\"\n+        To show a metric in the progressbar a list of tupels can be provided for metrics_keys_to_log_to_prog_bar, the first\n+        entry has to be the name of the metric to log and the second entry the display name in the progressbar. By default the\n+        mAP is logged to the progressbar.\n+        \"\"\"\n         super().__init__()\n         self.metrics = metrics or []\n+        self.metrics_keys_to_log_to_prog_bar = metrics_keys_to_log_to_prog_bar or [\n+            (\"AP (IoU=0.50:0.95) area=all\", \"COCOMetric\")\n+        ]\n \n     def accumulate_metrics(self, preds):\n         for metric in self.metrics:\n@@ -18,4 +30,9 @@\n         for metric in self.metrics:\n             metric_logs = metric.finalize()\n             for k, v in metric_logs.items():\n-                self.log(f\"{metric.name}/{k}\", v)\n+                for entry in self.metrics_keys_to_log_to_prog_bar:\n+                    if entry[0] == k:\n+                        self.log(entry[1], v, prog_bar=True)\n+                        self.log(f\"{metric.name}/{k}\", v)\n+                    else:\n+                        self.log(f\"{metric.name}/{k}\", v)\n", "issue": "Add more logging to the pytorch lighning models.\nThe feature consists of two parts:\r\n  1. Add the validation loss to the progress bar by default\r\n  2. Create boolean parameter for extended progress bar logging (showing the different components of the loss)\n", "before_files": [{"content": "__all__ = [\"LightningModelAdapter\"]\n\nimport pytorch_lightning as pl\nfrom icevision.imports import *\nfrom icevision.metrics import *\n\n\nclass LightningModelAdapter(pl.LightningModule, ABC):\n    def __init__(self, metrics: List[Metric] = None):\n        super().__init__()\n        self.metrics = metrics or []\n\n    def accumulate_metrics(self, preds):\n        for metric in self.metrics:\n            metric.accumulate(preds=preds)\n\n    def finalize_metrics(self) -> None:\n        for metric in self.metrics:\n            metric_logs = metric.finalize()\n            for k, v in metric_logs.items():\n                self.log(f\"{metric.name}/{k}\", v)\n", "path": "icevision/engines/lightning/lightning_model_adapter.py"}], "after_files": [{"content": "__all__ = [\"LightningModelAdapter\"]\n\nimport pytorch_lightning as pl\nfrom icevision.imports import *\nfrom icevision.metrics import *\n\n\nclass LightningModelAdapter(pl.LightningModule, ABC):\n    def __init__(\n        self,\n        metrics: List[Metric] = None,\n        metrics_keys_to_log_to_prog_bar: List[tuple] = None,\n    ):\n        \"\"\"\n        To show a metric in the progressbar a list of tupels can be provided for metrics_keys_to_log_to_prog_bar, the first\n        entry has to be the name of the metric to log and the second entry the display name in the progressbar. By default the\n        mAP is logged to the progressbar.\n        \"\"\"\n        super().__init__()\n        self.metrics = metrics or []\n        self.metrics_keys_to_log_to_prog_bar = metrics_keys_to_log_to_prog_bar or [\n            (\"AP (IoU=0.50:0.95) area=all\", \"COCOMetric\")\n        ]\n\n    def accumulate_metrics(self, preds):\n        for metric in self.metrics:\n            metric.accumulate(preds=preds)\n\n    def finalize_metrics(self) -> None:\n        for metric in self.metrics:\n            metric_logs = metric.finalize()\n            for k, v in metric_logs.items():\n                for entry in self.metrics_keys_to_log_to_prog_bar:\n                    if entry[0] == k:\n                        self.log(entry[1], v, prog_bar=True)\n                        self.log(f\"{metric.name}/{k}\", v)\n                    else:\n                        self.log(f\"{metric.name}/{k}\", v)\n", "path": "icevision/engines/lightning/lightning_model_adapter.py"}]}