Unverified Commit 4378ae4f authored by frob's avatar frob Committed by GitHub
Browse files

parser: don't check the file type of safetensors to prevent false negatives. (#12176)



* Don't check the file type of safetensor to prevent false negatives.

---------
Co-authored-by: default avatarPatrick Devine <patrick@infrahq.com>
parent 5994e8e8
...@@ -246,7 +246,7 @@ func filesForModel(path string) ([]string, error) { ...@@ -246,7 +246,7 @@ func filesForModel(path string) ([]string, error) {
for _, match := range matches { for _, match := range matches {
if ct, err := detectContentType(match); err != nil { if ct, err := detectContentType(match); err != nil {
return nil, err return nil, err
} else if ct != contentType { } else if len(contentType) > 0 && ct != contentType {
return nil, fmt.Errorf("invalid content type: expected %s for %s", ct, match) return nil, fmt.Errorf("invalid content type: expected %s for %s", ct, match)
} }
} }
...@@ -255,7 +255,8 @@ func filesForModel(path string) ([]string, error) { ...@@ -255,7 +255,8 @@ func filesForModel(path string) ([]string, error) {
} }
var files []string var files []string
if st, _ := glob(filepath.Join(path, "*.safetensors"), "application/octet-stream"); len(st) > 0 { // some safetensors files do not properly match "application/octet-stream", so skip checking their contentType
if st, _ := glob(filepath.Join(path, "*.safetensors"), ""); len(st) > 0 {
// safetensors files might be unresolved git lfs references; skip if they are // safetensors files might be unresolved git lfs references; skip if they are
// covers model-x-of-y.safetensors, model.fp32-x-of-y.safetensors, model.safetensors // covers model-x-of-y.safetensors, model.fp32-x-of-y.safetensors, model.safetensors
files = append(files, st...) files = append(files, st...)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment