ultralytics/ultralytics · error · ValueError
Model has no Depth head with calibration buffers (cal_a/cal_
Error message
Model has no Depth head with calibration buffers (cal_a/cal_b).
What it means
Even with task=='depth', calibrate() requires the model's Depth head to carry calibration buffers (cal_a/cal_b); _depth_head() returning None means the head cannot be calibrated and a ValueError is raised. This distinguishes depth models with calibration support from custom depth heads without buffers.
Source
Thrown at ultralytics/engine/model.py:629
Args:
data (str, optional): Dataset YAML providing a labeled split to calibrate against.
**kwargs (Any): Extra validation arguments (e.g. ``imgsz``, ``batch``, ``device``, ``split``).
Returns:
(tuple | None): The fitted ``(a, b)``, or ``None`` if fewer than 2 images had valid depth pixels.
Examples:
>>> model = YOLO("yolo26s-depth.pt")
>>> model.calibrate(data="my_depth_dataset.yaml")
>>> model.save("yolo26s-depth-calibrated.pt")
"""
self._check_is_pytorch_model()
if self.task != "depth":
raise ValueError(f"calibrate() is only supported for depth models (task='depth'), got task={self.task!r}.")
from ultralytics.models.yolo.depth.calibrate import _depth_head, fit_calibration_selective
if _depth_head(self.model) is None:
raise ValueError("Model has no Depth head with calibration buffers (cal_a/cal_b).")
args = {**self.overrides, **kwargs, "mode": "val", "task": "depth"}
if data is not None:
args["data"] = data
validator = self._smart_load("validator")(args=args, _callbacks=self.callbacks)
validator(model=self.model) # builds the dataloader and reports metrics with the current calibration
res = fit_calibration_selective(
self.model, validator.dataloader, validator.device, max_depth=validator.data.get("max_depth") or 100.0
)
if res is None:
return None
LOGGER.info("Call model.save(...) to persist the calibration.")
return res["a"], res["b"]
def benchmark(self, data=None, format="", verbose=False, **kwargs: Any):
"""Benchmark the model across various export formats to evaluate performance.
This method assesses the model's performance in different export formats, such as ONNX, TorchScript, etc. It
uses the 'benchmark' function from the ultralytics.utils.benchmarks module. The benchmarking is configured usingView on GitHub (pinned to 0449ea011c)
Solutions
- Use a stock Ultralytics depth checkpoint (yolo26s-depth.pt family), which ships a calibratable head.
- If the head is custom, add cal_a/cal_b buffers to the Depth head so _depth_head() recognizes it.
- Rebuild the model from the official depth YAML and load matching weights.
Example fix
# before
custom_depth_model.calibrate(data='depth.yaml') # ValueError: no cal_a/cal_b
# after
YOLO('yolo26s-depth.pt').calibrate(data='depth.yaml') Defensive patterns
Strategy: validation
Validate before calling
from ultralytics.models.yolo.depth.calibrate import _depth_head
if _depth_head(model.model) is None:
raise SystemExit('This depth head has no cal_a/cal_b buffers; use a stock yolo26-depth model')
model.calibrate(data='my_depth_dataset.yaml') Type guard
def has_calibratable_head(model) -> bool:
from ultralytics.models.yolo.depth.calibrate import _depth_head
return _depth_head(model) is not None Prevention
- Calibrate only stock depth checkpoints or heads with cal_a/cal_b buffers.
- Keep custom heads' calibration logic in your own code.
When it happens
Trigger: `model.calibrate(...)` on a task='depth' model whose head is a custom Depth implementation without cal_a/cal_b buffers — e.g. a hand-built or modified depth network trained outside the stock yolo26-depth recipes.
Common situations: Custom depth architectures labeled task='depth'; checkpoints converted from other frameworks; heads replaced during finetuning.
Related errors
- calibrate() is only supported for depth models (task='depth'
- mask_ratio={self.mask_ratio} downsamples imgsz={(h, w)} mask
- Depth record '{record.get('file', '<unknown>')}' is missing
- Depth records require encoding='npy-f32' and unit='m'
- Depth records require a positive [height, width] shape
AI-assisted analysis of ultralytics/ultralytics@0449ea011c (2026-08-15).
Data as JSON: /api/errors/5649d36e2f62c63f.
Report an issue: GitHub.