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

UnpicklingError: Invalid load key when loading model from Ultralytics HUB #925

Open
1 task done
rjacaac211 opened this issue Nov 12, 2024 · 4 comments
Open
1 task done
Labels
bug Something isn't working HUB Ultralytics HUB issues info needed More information is required to proceed

Comments

@rjacaac211
Copy link

Search before asking

  • I have searched the HUB issues and found no similar bug report.

HUB Component

Models, Training

Bug

I am experiencing an UnpicklingError while attempting to load a model from Ultralytics HUB in Python. The error occurs despite successful authentication and confirmation that the model was downloaded.

Ultralytics HUB: View model at https://hub.ultralytics.com/models/NmBAojugSjGYoRfLmYoZ 🚀
Found https://storage.googleapis.com/ultralytics-hub.appspot.com/users/PXpjF6uXemg1w8IEmvatQ5fSPMW2/models/NmBAojugSjGYoRfLmYoZ/epoch-63.pt locally at weights/epoch-63.pt
---------------------------------------------------------------------------
UnpicklingError                           Traceback (most recent call last)
<ipython-input-8-dbff24cb0977> in <cell line: 2>()
      1 # Load your model from HUB
----> 2 model = YOLO('https://hub.ultralytics.com/models/NmBAojugSjGYoRfLmYoZ')

7 frames
/usr/local/lib/python3.10/dist-packages/torch/serialization.py in _legacy_load(f, map_location, pickle_module, **pickle_load_args)
   1626         )
   1627 
-> 1628     magic_number = pickle_module.load(f, **pickle_load_args)
   1629     if magic_number != MAGIC_NUMBER:
   1630         raise RuntimeError("Invalid magic number; corrupt file?")

UnpicklingError: invalid load key, '<'.

Environment

Using Google Colab

%pip install ultralytics  # install
from ultralytics import YOLO, checks, hub

checks()  # checks

Ultralytics 8.3.29 🚀 Python-3.10.12 torch-2.5.0+cu121 CUDA:0 (NVIDIA L4, 22700MiB)
Setup complete ✅ (12 CPUs, 53.0 GB RAM, 32.1/235.7 GB disk)

Minimal Reproducible Example

# Login to HUB using your API key
hub.login('2ab43a5d8c3ba1dddd1121b95e4d8bba83200728b2')

# Load your model from HUB
model = YOLO('https://hub.ultralytics.com/models/NmBAojugSjGYoRfLmYoZ')

Additional

No response

@rjacaac211 rjacaac211 added the bug Something isn't working label Nov 12, 2024
@UltralyticsAssistant UltralyticsAssistant added HUB Ultralytics HUB issues info needed More information is required to proceed labels Nov 12, 2024
@UltralyticsAssistant
Copy link
Member

👋 Hello @rjacaac211, thank you for bringing this issue to our attention regarding Ultralytics HUB 🚀! Please explore our comprehensive HUB Docs to maximize your understanding and usage of the platform:

It seems you're encountering an 🐛 error when attempting to load a model. To better assist you, please ensure the provided snippet accurately recreates the issue you're experiencing. This will help us diagnose and address the problem more effectively. Here's a link to guide you on creating a minimum reproducible example.

An Ultralytics engineer will soon delve into this to provide more detailed assistance. Thanks for your patience and collaboration! 😊

@glenn-jocher
Copy link
Member

@rjacaac211 thank you for the bug report. I'm able to reproduce this, but please don't share your API key in the future as other users can then use your account. You should delete this key and create another.

This problem may be transient and specific to just this model, can you try training another model quickly to see if this happens again, i.e. you can train COCO8 for 3 epochs quickly.

Screenshot 2024-11-12 at 11 18 40

@rjacaac211
Copy link
Author

@rjacaac211 thank you for the bug report. I'm able to reproduce this, but please don't share your API key in the future as other users can then use your account. You should delete this key and create another.

This problem may be transient and specific to just this model, can you try training another model quickly to see if this happens again, i.e. you can train COCO8 for 3 epochs quickly.

Screenshot 2024-11-12 at 11 18 40

Thank you for the response @glenn-jocher. Does that mean that I will never be able to continue my training in that model? If so, what can I do to prevent this from happening again?
Also, I have already deleted the API key.

@glenn-jocher
Copy link
Member

@rjacaac211 I suspect this particular model may not be salvageable, but you should be able to train a new model. If you have any problems there please let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working HUB Ultralytics HUB issues info needed More information is required to proceed
Projects
None yet
Development

No branches or pull requests

3 participants