question: model inference but self.training is save true
context: i use self.training param to judge what data return.
  return x if self.training else (torch.cat(z, 1), x)
  but when i load my model, i use debug mode find that the self.training is save True.
  self.model = CustomModel.load_from_checkpoint(model_path)
  self.model.training = False
  i use above code change model.training status, but its not work
  this is my inference full code:
  class CustomModelInference:
      def __init__(
              self,
              model_path: str,
              conf_thres: float = 0.25,
              iou_thres: float = 0.45,
              max_det: int = 1000,
              device: str = 'cuda:0',
              need_classes: list | None = None
      ):
          self.conf_thres = conf_thres
          self.iou_thres = iou_thres
          self.max_det = max_det
          self.device = device
          self.need_classes = need_classes
  
          self.model = CustomModel.load_from_checkpoint(model_path)
          self.model.training = False
          self.model.to(device)
          self.stride = int(self.model.stride.max())
          self.names = self.model.names
          self.imgsz = self.model.imgsz
  
      @torch.no_grad()
      def infer(self, img: np.ndarray):
          imgsz = check_img_size(self.imgsz, s=self.stride)
          cudnn.benchmark = True
          img = letterbox(img, imgsz, stride=self.stride, auto=True)[0]
          # img = np.stack(img, 0)
          if len(img.shape) == 3:
              img = img[None]
          img = img[..., ::-1].transpose((0, 3, 1, 2))
          img = np.ascontiguousarray(img)
          img = torch.from_numpy(img).to(self.device)
          img = img.float()
          img = img / 255.0
  
          out, train_out = self.model(img)
answer: fine, i know the answer, i have to set model.eval()......