Skip to content

Instantly share code, notes, and snippets.

@dhruvbird
Created November 16, 2021 22:35
Show Gist options
  • Save dhruvbird/5903fb62c83c2dc5abd374ba09fb343e to your computer and use it in GitHub Desktop.
Save dhruvbird/5903fb62c83c2dc5abd374ba09fb343e to your computer and use it in GitHub Desktop.
Print the contents of the model file and the contents of the newly added metadata file
zf = zipfile.ZipFile("AddTensorsModel.ptl")
zf.infolist()
[<ZipInfo filename='AddTensorsModel/extra/model_info.txt' file_size=70>,
<ZipInfo filename='AddTensorsModel/data.pkl' file_size=86>,
<ZipInfo filename='AddTensorsModel/code/__torch__.py' compress_type=deflate file_size=247 compress_size=166>,
<ZipInfo filename='AddTensorsModel/code/__torch__.py.debug_pkl' file_size=145>,
<ZipInfo filename='AddTensorsModel/constants.pkl' file_size=4>,
<ZipInfo filename='AddTensorsModel/bytecode.pkl' file_size=452>,
<ZipInfo filename='AddTensorsModel/version' file_size=2>,
<ZipInfo filename='AddTensorsModel/extra/dtype_info.txt' filemode='?rw-------' file_size=58>]
print(zf.read("{}/extra/dtype_info.txt".format(archive_name)))
b'Both tensors can be any dtype as long as they can be added'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment