Skip to content

Commit

Permalink
new: added .pth support
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Oct 29, 2024
1 parent a8fa2fe commit 5ad824a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/pytorch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub(crate) fn is_pytorch(file_path: &Path) -> bool {
.to_ascii_lowercase();

file_ext == "pt"
|| file_ext == "pth"
|| file_name.ends_with("pytorch_model.bin")
// cases like diffusion_pytorch_model.fp16.bin
|| (file_name.contains("pytorch_model") && file_name.ends_with(".bin"))
Expand Down Expand Up @@ -54,6 +55,11 @@ mod tests {
assert!(is_pytorch(Path::new("path/to/model.pt")));
assert!(is_pytorch(Path::new("MODEL.PT"))); // Case insensitive

// Standard .pth extension
assert!(is_pytorch(Path::new("model.pth")));
assert!(is_pytorch(Path::new("path/to/model.pth")));
assert!(is_pytorch(Path::new("MODEL.PTH"))); // Case insensitive

// Standard pytorch_model.bin filename
assert!(is_pytorch(Path::new("pytorch_model.bin")));
assert!(is_pytorch(Path::new("path/to/pytorch_model.bin")));
Expand Down

0 comments on commit 5ad824a

Please sign in to comment.