AttributeError: 'DetectionTrainer' object has no attribute 'epoch'
Search before asking
- [X] I have searched the HUB issues and found no similar bug report.
HUB Component
No response
Bug
During the training of my custom model using Ultralytics, I encountered an error with the following details:
Code Location:
I'm seeking assistance to understand and resolve this issue. If you have insights or recommendations, please share them. Thank you!
Environment
- Google Colaboratory
Minimal Reproducible Example
No response
Additional
No response
👋 Hello @Asman2010, thank you for raising an issue about Ultralytics HUB 🚀! Please visit our HUB Docs to learn more:
- Quickstart. Start training and deploying YOLO models with HUB in seconds.
- Datasets: Preparing and Uploading. Learn how to prepare and upload your datasets to HUB in YOLO format.
- Projects: Creating and Managing. Group your models into projects for improved organization.
- Models: Training and Exporting. Train YOLOv5 and YOLOv8 models on your custom datasets and export them to various formats for deployment.
- Integrations. Explore different integration options for your trained models, such as TensorFlow, ONNX, OpenVINO, CoreML, and PaddlePaddle.
- Ultralytics HUB App. Learn about the Ultralytics App for iOS and Android, which allows you to run models directly on your mobile device.
- Inference API. Understand how to use the Inference API for running your trained models in the cloud to generate predictions.
If this is a 🐛 Bug Report, please provide screenshots and steps to reproduce your problem to help us get started working on a fix.
If this is a ❓ Question, please provide as much information as possible, including dataset, model, environment details etc. so that we might provide the most helpful response.
We try to respond to all issues as promptly as possible. Thank you for your patience!
@Asman2010 Thanks for raising this bug. We are attempting to replicate this now. Once we are able to reproduce we will address the issue and update you with a solution.
@Asman2010 We are unable to reproduce this bug. It seems like this is related to the resume function. Can you give us detailed steps of how you got here?
@kalenmike
Detailed Information:
I was training a model using Ultralytics' YOLO implementation. I started training on my primary Google Colab account and completed the first 50 epochs. Then, I switched to my secondary Google Colab account and trained for the remaining 49 epochs. At the 100th epoch, I encountered the following error:
1 epochs completed in 0.001 hours. Optimizer stripped from runs/detect/train/weights/last.pt, 136.7MB Ultralytics HUB: Syncing final model... AttributeError Traceback (most recent call last) in <cell line: 4>() 2 3 model = YOLO('https://hub.ultralytics.com/models/XW4ss6rScwzcdElUedCm') ----> 4 model.train()
4 frames [/usr/local/lib/python3.10/dist-packages/ultralytics/yolo/utils/callbacks/hub.py](https://localhost:8080/#) in on_train_end(trainer) 51 # Upload final model and metrics with exponential standoff 52 LOGGER.info(f'{PREFIX}Syncing final model...') ---> 53 session.upload_model(trainer.epoch, trainer.best, map=trainer.metrics.get('metrics/mAP50-95(B)', 0), final=True) 54 session.alive = False # stop heartbeats 55 LOGGER.info(f'{PREFIX}Done ✅\n'
AttributeError: 'DetectionTrainer' object has no attribute 'epoch'
Steps to Reproduce:
- Initialize the YOLO model with this URL: https://hub.ultralytics.com/models/XW4ss6rScwzcdElUedCm
- Call the train() method on the model:
hub.login('')
model = YOLO('https://hub.ultralytics.com/models/XW4ss6rScwzcdElUedCm')
model.train()
Expected Behavior:
The model should train and optimize the weights without any errors.
Actual Behavior:
The training process fails with an attribute error, stating that the 'DetectionTrainer' object does not have the attribute 'epoch'.
Environment Information:
- Platform: Google Colab
- Python Version: 3.10.12
- Ultralytics Version: YOLOv8.0.117
- Hardware specifications: CUDA:0 (Tesla T4, 15102MiB)
- Setup complete: 2 CPUs, 12.7 GB RAM, 25.9/78.2 GB disk
Additional Information:
- I have verified that the model URL is correct and accessible.
- I have confirmed that all necessary dependencies and packages are installed.
- It appears there might be an issue with the current Ultralytics library and its interaction with the 'DetectionTrainer' object.
I would appreciate any assistance in resolving this issue.
@Asman2010 Thank you for the detailed steps. We will try and reproduce it.