model_loads is an open-source Python package for pytorch load models easy.
PyTorch is a Python package that provides two high-level features:
- Tensor computation (like NumPy) with strong GPU acceleration
- Deep neural networks built on a tape-based autograd system
It's annoying to load cpu model to gpu devices or load multi-gpus trained model to single gpu devices sometimes, And this package try to simplify it.
Table of Contents
Installation
To install load_models, you can do as follow:
pip install model-loads
Or from source
git clone https://github.com/cwh94/model_loads.git
cd load_models
python setup.py bdist_egg
python setup.py install
Getting Started
- load pth model to GPU device
import model_loads as lo
import torchvision.models as models
model = models.MobileNetV2()
model_path = "../examples/models/pth/mobilenet_v2-b0353104.pth"
model, _ = lo.load_models(model_path, model, use_gpu=True)
print(model)
print(type(model))
- load tar model(which contains state_dict and optimization info or accuracy) to CPU device
from models.tar.mobilenet_v2 import MobileNetV2
model = MobileNetV2()
model_path = "models/tar/checkpoint.pth.tar"
model, other_param = lo.load_models(model_path, model)
print(model)
print(other_param)
- load model to CPU device
import os
os.environ["CUDA_VISIBLE_DEVICES"] = ""
model = models.MobileNetV2()
model_path = "models/pth/mobilenet_v2-b0353104.pth"
model, _ = lo.load_models(model_path, model, use_gpu=True)
print(model)
print(type(model))
Metadata
Release files for model-loads 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| model-loads-0.3.tar.gz | 11.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| model_loads-0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.4 kB
Release files / model-loads-0.3.tar.gz
| Download URL | model-loads-0.3.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e81b558903c2786554f4964884d34bb89d650d453b7f0b70ea707b4734067594
|
|
BLAKE2b-256 checksum How to use checksums |
0765606aad65aa1834a7591f4e42547bafa009eebdf1cc75200976d950c6ffea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Release files / model_loads-0.3-py3-none-any.whl
| Download URL | model_loads-0.3-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d427c2796916014867196730683c4d51f2f316e061b98b3e25e5aa90d4c91de9
|
|
BLAKE2b-256 checksum How to use checksums |
1da42ddddf0594646ac1e1979e43d2aa06ba738b5e1d35ccbf9afadb6242d9b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Security for model-loads 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.