ultralytics / ultralytics

NEW - YOLOv8 πŸš€ in PyTorch > ONNX > OpenVINO > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
28.17k stars 5.6k forks source link

How to train YOLO in a different way instead of using '.yaml' file ? #14834

Open wzh506 opened 1 month ago

wzh506 commented 1 month ago

Search before asking

Question

I don't want to train by using train and .yaml files. I currently want to do a dynamic occlusion task and hope to use yolo for self-supervised training. So the code is as follows: self.map_generator= YOLO("yolov8n-seg.pt") print('Make visibility map v3 : yolov8') for name, param in self.map_generator.named_parameters(): param.requires_grad = True and I already add parameters to optimizer l: self.optimizer = torch.optim.Adam(l, lr=0.0, eps=1e-15) But by printing the model weights after the optimizer, optimizer.step() optimizer.zero_grad(set_to_none = True) after_update = {name: param.clone() for name, param in map_generator.named_parameters()} if iteration > opt.masks_iters: for name in before_update: print(f"{name}: ") print(f"Before update: {before_update[name]}") print(f"After update: {after_update[name]}") print(f"Difference: {after_update[name] - before_update[name]}") I found Difference is always zero,I wonder why?

Additional

No response

github-actions[bot] commented 1 month ago

πŸ‘‹ Hello @wzh506, thank you for your interest in Ultralytics YOLOv8 πŸš€! We recommend a visit to the Docs for new users where you can find many Python and CLI usage examples and where many of the most common questions may already be answered.

If this is a πŸ› Bug Report, please provide a minimum reproducible example to help us debug it.

If this is a custom training ❓ Question, please provide as much information as possible, including dataset image examples and training logs, and verify you are following our Tips for Best Training Results.

Join the vibrant Ultralytics Discord 🎧 community for real-time conversations and collaborations. This platform offers a perfect space to inquire, showcase your work, and connect with fellow Ultralytics users.

Install

Pip install the ultralytics package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.

pip install ultralytics

Environments

YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):

Status

Ultralytics CI

If this badge is green, all Ultralytics CI tests are currently passing. CI tests verify correct operation of all YOLOv8 Modes and Tasks on macOS, Windows, and Ubuntu every 24 hours and on every commit.