Unverified Commit 86cbd2ee authored by Reid's avatar Reid Committed by GitHub
Browse files

[Misc] improve gguf check (#15974)


Signed-off-by: default avatarreidliu41 <reid201711@gmail.com>
Co-authored-by: default avatarreidliu41 <reid201711@gmail.com>
parent 092475f7
...@@ -23,9 +23,14 @@ def check_gguf_file(model: Union[str, PathLike]) -> bool: ...@@ -23,9 +23,14 @@ def check_gguf_file(model: Union[str, PathLike]) -> bool:
elif model.suffix == ".gguf": elif model.suffix == ".gguf":
return True return True
with open(model, "rb") as f: try:
header = f.read(4) with model.open("rb") as f:
return header == b"GGUF" header = f.read(4)
return header == b"GGUF"
except Exception as e:
logger.debug("Error reading file %s: %s", model, e)
return False
def modelscope_list_repo_files( def modelscope_list_repo_files(
......
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