Skip to content

Create delivery_fix.pt to fix windowspath error on linux#3

Open
rbflurry wants to merge 1 commit intoVideoDad:mainfrom
rbflurry:main
Open

Create delivery_fix.pt to fix windowspath error on linux#3
rbflurry wants to merge 1 commit intoVideoDad:mainfrom
rbflurry:main

Conversation

@rbflurry
Copy link

Fixed the windowspath error on linux using the following setup. Working well for me inside docker.

import pathlib, torch

✅ Correct monkey-patch: make any WindowsPath unpickle as PosixPath

pathlib.WindowsPath = pathlib.PosixPath

ckpt = torch.load("/workspace/models/delivery.pt", map_location="cpu") # this should now work

Pull out the model (YOLOv5 checkpoints usually store 'model')

model = ckpt.get("model", ckpt)
model.eval()

Save a Linux-safe checkpoint stripped of optimizer/etc.

clean = {"model": model, "epoch": -1, "optimizer": None, "training_results": None}
torch.save(clean, "/workspace/models/delivery_linux.pt")
print("Wrote /workspace/models/delivery_linux.pt")

Fixed the windows env bug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant