mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[PR #462] fix torch.load after torch.jit.load #511
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#511
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/openai/CLIP/pull/462
Author: @scott-vsi
Created: 9/18/2024
Status: 🔄 Open
Base:
main← Head:patch-1📝 Commits (1)
45afa5ffix torch.load after torch.jit.load📊 Changes
1 file changed (+1 additions, -0 deletions)
View changed files
📝
clip/clip.py(+1 -0)📄 Description
If we try to load a CLIP model that has not been traced (and is saved as a state_dict), then this first tries to load it with
torch.jit.load(opened_file), which will raise a RuntimeError; this is then caught and you re-try loading the model withtorch.load(opened_file). However, the file pointer,opened_filehas been advanced bytorch.jit.load, so this attempt fails with aEOFError: Ran out of inputexception. To fix this, we simply need to reset the file pointer to the beginning of the file with.fseek(0)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.