Open ddeellttaa opened 2 months ago
👋 Hello @ddeellttaa, 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.
Pip install the ultralytics
package including all requirements in a Python>=3.8 environment with PyTorch>=1.8.
pip install ultralytics
YOLOv8 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
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.
@ddeellttaa thank you for your question. The line self.loss, self.loss_items = self.model(batch)
in trainer.py
is indeed calling the model, which is a subclass of nn.Module
. In this context, the model's forward
method is overridden to return both the loss and the loss items when it is in training mode. This is why you see the loss being returned instead of just a tensor. If you need further clarification, please refer to the forward
method implementation in the model class. If the issue persists, ensure you are using the latest version of the package.
Search before asking
Question
I'm confused about this code in trainer.py.
self.loss, self.loss_items = self.model(batch)
since model is a nn.Module, I believe the result of running self.model(batch) is tensor instead of loss. I check the /enfgin/model.py and /yolo/model.py and can't find out why.Additional
No response