The model save function in ultralytics has an option to use the dill module or not, which defaults to True. Setting this to False can free you from the dill import issue.

This is the code that created this PR. Reuse it if you like.

from pathlib import Path

from huggingface_hub import snapshot_download, upload_folder
from ultralytics.utils.files import update_models

repo_id = "Anzhc/Anzhcs_YOLOs"
local_dir = repo_id.split("/")[-1]
snapshot_download(repo_id=repo_id, local_dir=local_dir)
pt_files = [p.name for p in Path(local_dir).rglob("*.pt")]

update_models(pt_files, source_dir=Path(local_dir))

upload_folder(
    repo_id=repo_id,
    folder_path=Path(local_dir, "updated_models"),
    path_in_repo=".",
    create_pr=True,
    commit_message="models without dill",
)
Anzhc changed pull request status to merged

Sorry for getting to this so late. Im rarely checking HF. Merged this, hopefully will fix dill for people. Need to re-upload to civitai later e-e

Sign up or log in to comment