Lightweight PyTorch utility library for training, evaluation, and TFLite export — without the framework lock-in.
Project description
torchloop
Lightweight PyTorch utility library for training, evaluation, and TFLite export — without the framework lock-in.
The Problem
You write the same PyTorch training loop in every project. Same checkpoint logic. Same metric assembly. Same TFLite export steps. It's tedious and inconsistent.
torchloop abstracts exactly that — nothing more.
Install
pip install torchloop
# With TFLite export support
pip install torchloop[export]
Usage
Training
from torchloop import Trainer
trainer = Trainer(
model,
optimizer=torch.optim.Adam(model.parameters()),
criterion=torch.nn.CrossEntropyLoss(),
device="cuda",
patience=5, # early stopping
)
history = trainer.fit(train_loader, val_loader, epochs=30)
trainer.save("best.pt")
Evaluation
from torchloop import Evaluator
ev = Evaluator(model, device="cuda")
results = ev.report(val_loader, class_names=["No Damage", "Minor", "Major", "Destroyed"])
# prints sklearn classification report
fig = ev.confusion_matrix(val_loader)
fig.savefig("cm.png")
per_class = ev.f1_per_class(val_loader)
# {'No Damage': 0.91, 'Minor': 0.78, ...}
Export
from torchloop.exporter import Exporter
exp = Exporter(model, input_shape=(1, 3, 224, 224))
exp.to_onnx("model.onnx")
exp.to_tflite("model.tflite", quantize=True)
Design Principles
- No lock-in: Works with any nn.Module. No subclassing required.
- Minimal surface area: Three modules. That's it.
- You own the model: torchloop wraps your loop, doesn't replace your architecture.
Roadmap
-
v0.1.0— Trainer, Evaluator, Exporter -
v0.2.0— LR scheduler support, mixed precision (AMP) -
v0.3.0— W&B / MLflow logging hooks
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torchloop-0.1.0.tar.gz.
File metadata
- Download URL: torchloop-0.1.0.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ec733544fcacc21db17a63d627be3b8700cd4a964a9f08783bc7de05c5f60d6
|
|
| MD5 |
b5f992e85454737b184daf8faa9326ed
|
|
| BLAKE2b-256 |
3bb3985aac0bd8a1488f06828fc8162521ce85c5ef2cbc25f4527937f7699a25
|
Provenance
The following attestation bundles were made for torchloop-0.1.0.tar.gz:
Publisher:
publish.yml on Tharun007-TK/torchlite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchloop-0.1.0.tar.gz -
Subject digest:
7ec733544fcacc21db17a63d627be3b8700cd4a964a9f08783bc7de05c5f60d6 - Sigstore transparency entry: 1179887783
- Sigstore integration time:
-
Permalink:
Tharun007-TK/torchlite@c6f910816f99a49f967e63091d53d701e3cc6341 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Tharun007-TK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c6f910816f99a49f967e63091d53d701e3cc6341 -
Trigger Event:
push
-
Statement type:
File details
Details for the file torchloop-0.1.0-py3-none-any.whl.
File metadata
- Download URL: torchloop-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c1e66a058de8a07e5a0f433945837f05a56435bad3c02b7f98ef257b6c469c9
|
|
| MD5 |
924b1820b16cec908b08d7908d40b299
|
|
| BLAKE2b-256 |
986c6172a6254efcd5c600097b396300fccb0d2e429a97f2896168d49b168f90
|
Provenance
The following attestation bundles were made for torchloop-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Tharun007-TK/torchlite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torchloop-0.1.0-py3-none-any.whl -
Subject digest:
9c1e66a058de8a07e5a0f433945837f05a56435bad3c02b7f98ef257b6c469c9 - Sigstore transparency entry: 1179887852
- Sigstore integration time:
-
Permalink:
Tharun007-TK/torchlite@c6f910816f99a49f967e63091d53d701e3cc6341 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Tharun007-TK
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c6f910816f99a49f967e63091d53d701e3cc6341 -
Trigger Event:
push
-
Statement type: