ultralytics / hub

Ultralytics HUB tutorials and support
https://hub.ultralytics.com
GNU Affero General Public License v3.0
136 stars 13 forks source link

AttributeError: 'DetectionTrainer' object has no attribute 'epoch' #491

Open Asman2010 opened 11 months ago

Asman2010 commented 11 months ago

Search before asking

HUB Component

No response

Bug

During the training of my custom model using Ultralytics, I encountered an error with the following details:

Code Location: in <cell line: 4>() Model Initialization: model = YOLO('https://hub.ultralytics.com/models/eMyxzmdYCHecAVVDwVIt') Error: AttributeError: 'DetectionTrainer' object has no attribute 'epoch' Error Location: /usr/local/lib/python3.10/dist-packages/ultralytics/utils/callbacks/hub.py Specifics: The error occurs during the execution of session.upload_model(trainer.epoch, trainer.best, map=trainer.metrics.get('metrics/mAP50-95(B)', 0), final=True), indicating that the 'DetectionTrainer' object lacks an 'epoch' attribute.

Screenshot 2023-12-11 183829

I'm seeking assistance to understand and resolve this issue. If you have insights or recommendations, please share them. Thank you!

Environment

Minimal Reproducible Example

No response

Additional

No response

github-actions[bot] commented 11 months ago

πŸ‘‹ Hello @Asman2010, thank you for raising an issue about Ultralytics HUB πŸš€! Please visit our HUB Docs to learn more:

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!

kalenmike commented 11 months ago

@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.

kalenmike commented 11 months ago

@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?

Asman2010 commented 11 months ago

@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:

  1. Initialize the YOLO model with this URL: https://hub.ultralytics.com/models/XW4ss6rScwzcdElUedCm
  2. 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:

Additional Information:

I would appreciate any assistance in resolving this issue.

kalenmike commented 11 months ago

@Asman2010 Thank you for the detailed steps. We will try and reproduce it.