How to add a pre-process module on yolo11?

i want add a low-light enhancement module like enlightgan or zero-dce or etc,finally achive end-to-end effect ? need to modify yolo11.yaml?

Yes, whenever you create a custom module for a YOLO model, you’ll need to include it in the YOLO model YAML config

thank you ,very appreciate your help .:heart_hands:

Thanks! To make a low‑light enhancer end-to-end with YOLO11, add it as the first layer in the model YAML and register the module in the codebase so it’s included in training and export.

Minimal steps:

  • Define your module (e.g., Zero-DCE/EnlightenGAN wrapper) in ultralytics/nn/modules/block.py, expose it in ultralytics/nn/modules/__init__.py, and import it in ultralytics/nn/tasks.py so parse_model can resolve it. The process is outlined in the Model YAML guide under Custom Module Integration; see the examples in the Model YAML Configuration Guide.
  • Insert it as the first backbone layer in your YAML. Ensure it returns a 3×H×W tensor so downstream layers don’t need channel changes.

Example:

# ultralytics/nn/modules/block.py
import torch.nn as nn

class LowLightEnhance(nn.Module):
    def __init__(self):
        super().__init__()
        # self.net = YourZeroDCE()  # wrap your enhancer here
    def forward(self, x):
        # x = self.net(x)
        return x.clamp(0, 1)  # keep shape and range
# yolo11n_lowlight.yaml (excerpt)
nc: 80
backbone:
  - [-1, 1, LowLightEnhance, []]   # pre-process, returns Bx3xHxW
  - [-1, 1, Conv, [64, 3, 2]]
  # ... rest of YOLO11 backbone/head
head:
  # ...

Quick checks:

  • Build and inspect shapes with model.info().
  • Export to verify compatibility: model.export(format="onnx").

If you need both original and enhanced inputs, you can branch and Concat them, but then adjust following channels accordingly. For more on layer syntax and resolution order, see the section on [from, repeats, module, args] and module lookup in the YAML config guide and the parse_model reference in nn/tasks.py.

thank you,you r so kind.:heart_hands: