Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
Asman2010 opened this issue Dec 11, 2023 · 5 comments
Open
1 task done
Assignees
Labels
bug Something isn't working todo Further action is needed by Ultralytics

Comments

@Asman2010
Copy link

Search before asking

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

  • Google Colaboratory

Minimal Reproducible Example

No response

Additional

No response

@Asman2010 Asman2010 added the bug Something isn't working label Dec 11, 2023
Copy link

👋 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.
    • iOS. Learn about YOLO CoreML models accelerated on Apple's Neural Engine on iPhones and iPads.
    • Android. Explore TFLite acceleration on mobile devices.
  • 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!

@kalenmike
Copy link
Member

@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 kalenmike self-assigned this Dec 11, 2023
@kalenmike kalenmike added todo Further action is needed by Ultralytics non-reproducible Bug is not reproducible info needed More information is needed for action and removed todo Further action is needed by Ultralytics labels Dec 11, 2023
@kalenmike
Copy link
Member

@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
Copy link
Author

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

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

@kalenmike
Copy link
Member

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

@kalenmike kalenmike added todo Further action is needed by Ultralytics and removed non-reproducible Bug is not reproducible info needed More information is needed for action labels Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working todo Further action is needed by Ultralytics
Projects
None yet
Development

No branches or pull requests

2 participants