Skip to main content

This project can write json file from pth and can write the pth again from the json.

Project description

OneView Logo

Readable PTH

Upload Python Package GitHub license

About this project

Make pth readable.
This project can write json file from pth and can write the pth again from the json.
model.pth <--> model.json

Limitation

model.pth must be the state_dict of a Pytorch model: torch.save(model.state_dict(), 'model.pth')

Installation

pip install readablePTH

For develop

Please clone the project

git clone https://github.com/oneview-space/readablePTH.git

And then install

cd readablePTH
pip install -e .

Usage

For now this is only working with [encode, decode] commands

decode from pth to json

rpth decode -i test/models/model_small.pth -o test/models/model_small.json 

encode from json to pth

rpth encode -i test/models/model_small.json -o test/models/model_small_restored.pth

Test

For testing with small model run:

cd test
python test_small_net.py

TODO:

  • Add the ability to use any torch version
  • Add args to map_location (CPU/GPU) when writing pth file
  • Add compare state_dict or json methods for checking results

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

readablePTH-0.1.4.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

readablePTH-0.1.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file readablePTH-0.1.4.tar.gz.

File metadata

  • Download URL: readablePTH-0.1.4.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for readablePTH-0.1.4.tar.gz
Algorithm Hash digest
SHA256 baf719581c3950d915d1d939f2b3a712faa47a7d7b7decdd17152b2c97c9e7fe
MD5 67d9ad5718f45cf5ab38060e8bb38231
BLAKE2b-256 3dc2aa5184c83e2bb5ec9901afb82c5e609541c9e450f51497cc368f244f4c0a

See more details on using hashes here.

File details

Details for the file readablePTH-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: readablePTH-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for readablePTH-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6594b403c7a782d6183d5ef0aa5d2627d7538c946627a3faf6da8ba72a74af25
MD5 cf437ad124b2f9d5d4bb9c6905bf9fff
BLAKE2b-256 1337673042512c1bb576d96c77bd82d2cce6433bd045fd726e5cfe96b2142eed

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page