text: Title: How to Freeze Detection Head Layers in YOLOv8m-segment and Train Only Segmentation Head?
  Body: ### Search before asking
  
  - [x] I have searched the Ultralytics YOLO [issues](https://github.com/ultralytics/ultralytics/issues) and [discussions](https://github.com/orgs/ultralytics/discussions) and found no similar questions.
  
  
  ### Question
  
  Hi all,
  
  I'm working with yolov8m-seg.pt and want to freeze the detection head layers (bounding box/class prediction) while training only the segmentation head (mask prediction). The goal is to fine-tune the segmentation capability without updating the detection part. Has anyone done this before?
  
  I’m thinking of freezing layers by setting requires_grad = False for detection-related params, but I’m unsure how to precisely identify them in the head (e.g., model.22). Here’s my tentative code—can someone confirm if this approach works or suggest a better way?
  
  ### Additional
  
  `from ultralytics import YOLO
  
  # Load model
  model = YOLO("yolov8m-seg.pt")
  
  # Freeze detection head layers (guessing these are related to 'detect')
  for name, param in model.model.named_parameters():
      if "detect" in name.lower():  # Is this the right way to target detection head?
          param.requires_grad = False
  
  # Train only segmentation head
  model.train(data="path/to/data.yaml", epochs=50, imgsz=640)`
  Questions:
  
  Does detect correctly target the detection head, or should I use a different identifier (e.g., specific layer indices)?
  Will this setup ensure the segmentation head (e.g., mask coefficients/Proto) still trains properly?
  Any pitfalls to watch out for?
  Thanks for any insights!