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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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