microsoft / microsoft/Biodiversity

Issue Saving MegaDetectorV6: Cannot Pickle '_thread.lock' Object

Open
#565 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
1.1k
Forks
297
PR merge metrics
No merged PRs in 30d

Description

When saving the MegaDetectorV6 model using the following code:

import torch
from PytorchWildlife.models import detection as pw_detection

model = pw_detection.MegaDetectorV6(
    device="cpu",
    pretrained=True,
    version="MDV6-yolov10-e"
)

torch.save(model, "MegaDetectorV6.pt")

I encountered the error:

TypeError: cannot pickle '_thread.lock' object

Could you please advise on:
A recommended method to export this model directly to Hugging Face Transformers?
How to save the model as a .pt file or convert it to ONNX given this serialization issue?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the torch.save failure with the MegaDetectorV6 example and inspect the model's serialization path. Investigate the requested Hugging Face and ONNX export routes, then define done as a supported export or save method with clear usage guidance and validation of the resulting artifact.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-vision, machine-learning
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.