Skip to content

Instantly share code, notes, and snippets.

@sayakpaul
Created June 21, 2020 15:56
Show Gist options
  • Save sayakpaul/4a2b46cc033d346059e7eed7ff5c18c1 to your computer and use it in GitHub Desktop.
Save sayakpaul/4a2b46cc033d346059e7eed7ff5c18c1 to your computer and use it in GitHub Desktop.
def get_gzipped_model_size(file):
_, zipped_file = tempfile.mkstemp('.zip')
with zipfile.ZipFile(zipped_file, 'w', compression=zipfile.ZIP_DEFLATED) as f:
f.write(file)
return os.path.getsize(zipped_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment