You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m unsure if this is expected behavior or a bug since it does not align with what the documentation for these functions describes. Below is the code to reproduce the issue:
Expected behavior
importnumpyasnpimportsafetensorsfromsafetensors.numpyimportsave_file, load# Save as a safetensors filedata_ran_uint16=np.random.randint(0, 255, (2, 2, 2)).astype(np.uint16)
save_file({"toy": data_ran_uint16}, "toy.safetensors")
# Deserialize the filewithopen("toy.safetensors", "rb") asf:
fbytes=safetensors.deserialize(f.read())
# Expected to workserialized=safetensors.serialize({"toy": fbytes[0][1]})
# Workaroundfbytes[0][1]["data"] =bytes(fbytes[0][1]["data"]) # I had to convert the bytearray to bytesfbytes[0][1]["dtype"] ="uint16"# I had to change the dtype to uint16fbytes[0][1]["shape"]
serialized=safetensors.serialize({"toy": fbytes[0][1]})
load(serialized)
The text was updated successfully, but these errors were encountered:
System Info
transformers
version: 4.42.3Information
Reproduction
Hi,
I’m unsure if this is expected behavior or a bug since it does not align with what the documentation for these functions describes. Below is the code to reproduce the issue:
Expected behavior
The text was updated successfully, but these errors were encountered: