nsharper
A lightweight Python framework for building and evaluating computer-vision models with a deliberately simple API.
Dataset → Model → Summary → Train → Test → Benchmark → Save
Keep the model definition simple. Keep the workflow obvious.
Full documentation lives in docs.md.
Install
pip install nsharper
A complete project
import nsharper as ns
train = ns.Dataset("dataset/train")
val = ns.Dataset("dataset/val")
model = ns.Model([
ns.Conv(224, 224, 3, 16, 3, 2),
ns.Conv(112, 112, 16, 32, 3, 2),
ns.Conv(56, 56, 32, 64, 3, 2),
ns.Detect(28, 28, 64, 10)
])
model.summary()
model.fit(train, epochs=50, batch_size=32, lr=0.001, val=val)
results = model.test(val)
results.show()
model.save("supercharger.nsh")
What each command answers
| Command | Question it answers |
|---|---|
summary() |
What is my model, and what does it cost? |
test() |
How well does it do on my dataset? |
benchmark() |
How well does it do on COCO? |
summary() reports parameters, FLOPs, model size, memory and measured
latency/FPS on every backend the machine offers, plus a Mermaid diagram of
the graph. It needs no trained weights, so architectures can be compared
before spending time on training.
Dataset layout
dataset/
├── images/001.jpg
└── labels/001.yaml
cat:
- [0.12, 0.20, 0.43, 0.61]
dog:
- [0.55, 0.31, 0.88, 0.72]
Boxes are normalized [x1, y1, x2, y2], all coordinates between 0.0 and 1.0.
Devices
"auto" (default) walks CUDA → MPS → CPU and takes the first available
backend. "cpu", "cuda", "mps" and "gpu" select one explicitly.
model.fit(train, epochs=50, device="mps")
ns.device() # 'mps'
Architecture errors surface immediately
ns.Model([
ns.Conv(224, 224, 3, 16, 3, 2),
ns.Conv(112, 112, 64, 32, 3, 2),
])
error: channel mismatch
layer: Conv
expected: 64
received: 16
COCO benchmark
COCO is not bundled. Point benchmark() at a local copy — by argument, via
NSHARPER_COCO, or by placing it in ~/.nsharper/coco:
ns.benchmark("supercharger.nsh")
ns.benchmark(model, data="~/datasets/coco")
Both the nsharper layout (images/ + labels/) and the official COCO
layout (val2017/ + annotations/instances_val2017.json) are read.
Examples
python examples/make_shapes.py dataset # generate a synthetic dataset
python examples/train.py # train, test and save a detector
python examples/predict.py dataset/val/images/0000.jpg
python examples/benchmark.py # benchmark saved models
Development
pip install -e ".[dev]"
pytest
Metadata
Release files for nsharper 0.1.0
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 | Actions |
|---|---|---|---|---|
| nsharper-0.1.0.tar.gz | 33.5 kB | Without provenance | Details for nsharper-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nsharper-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nsharper-0.1.0-py3-none-any.whl |
Total release size: 64.4 kB
Release files / nsharper-0.1.0.tar.gz
| Download URL | nsharper-0.1.0.tar.gz |
|---|---|
| Size | 33.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
36676d60a5bc4d05e646cb9aa1be8a371e8769194d2519c0e8421b417cd5b0dc
|
|
BLAKE2b-256 checksum How to use checksums |
5d51b6f34b9851de78eafe963c79790e6bd511d27481ff5ce841b28f6fb1b1e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / nsharper-0.1.0-py3-none-any.whl
| Download URL | nsharper-0.1.0-py3-none-any.whl |
|---|---|
| Size | 30.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea7b0f44e5b5f99bcc49da6fa54d20a133fc3440f747d3126fe7c9aafe08b78f
|
|
BLAKE2b-256 checksum How to use checksums |
f9efb80b1ba858d3f642d1ebf123ebc2795c27595a1513669689dee0734504d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for nsharper 0.1.0
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.