open-mmlab/mmdetection · error · RuntimeError

The `file_client_args` is deprecated, please use `backend_ar

Error message

The `file_client_args` is deprecated, please use `backend_args` instead, please refer tohttps://github.com/open-mmlab/mmdetection/blob/main/configs/_base_/datasets/coco_detection.py

What it means

CityscapesMetric dropped file_client_args in favor of backend_args (mmengine file backends). Passing the removed kwarg raises RuntimeError pointing to the migration example in the mmdetection configs.

Source

Thrown at mmdet/evaluation/metrics/cityscapes_metric.py:103

        if outfile_prefix is None:
            self.tmp_dir = tempfile.TemporaryDirectory()
            self.outfile_prefix = osp.join(self.tmp_dir.name, 'results')
        else:
            # the directory to save predicted panoptic segmentation mask
            self.outfile_prefix = osp.join(outfile_prefix, 'results')  # type: ignore # yapf: disable # noqa: E501

        dir_name = osp.expanduser(self.outfile_prefix)

        if osp.exists(dir_name) and is_main_process():
            logger: MMLogger = MMLogger.get_current_instance()
            logger.info('remove previous results.')
            shutil.rmtree(dir_name)
        os.makedirs(dir_name, exist_ok=True)

        self.backend_args = backend_args
        if file_client_args is not None:
            raise RuntimeError(
                'The `file_client_args` is deprecated, '
                'please use `backend_args` instead, please refer to'
                'https://github.com/open-mmlab/mmdetection/blob/main/configs/_base_/datasets/coco_detection.py'  # noqa: E501
            )

        self.seg_prefix = seg_prefix
        self.dump_matches = dump_matches

    def __del__(self) -> None:
        """Clean up the results if necessary."""
        if self.tmp_dir is not None:
            self.tmp_dir.cleanup()

    # TODO: data_batch is no longer needed, consider adjusting the
    #  parameter position
    def process(self, data_batch: dict, data_samples: Sequence[dict]) -> None:
        """Process one batch of data samples and predictions. The processed
        results should be stored in ``self.results``, which will be used to

View on GitHub (pinned to cfd5d3a985)

Solutions

  1. Remove file_client_args and pass backend_args=None or a backend dict
  2. For cloud storage, set backend_args={'backend':'petrel','path_mapping':{...}} per the referenced config example
  3. Grep configs for file_client_args and migrate all occurrences

Example fix

# before
metric = CityscapesMetric(file_client_args={'backend':'disk'})
# after
metric = CityscapesMetric(backend_args=None)
Defensive patterns

Strategy: validation

Validate before calling

assert 'file_client_args' not in kwargs, 'use backend_args, not file_client_args'

Prevention

When it happens

Trigger: Constructing CityscapesMetric(..., file_client_args={...}) in old configs or custom code after upgrading mmdet/mmdetection.

Common situations: Configs written for mmdet 2.x ported to 3.x; tutorials referencing the old file client API.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/0812bc406e5d3667. Report an issue: GitHub.