Map images (as `PIL.Images`) to intermediate representations (as `np.ndarray`) from off-the-shelf vision models.
Project description
enczoo: a zoo of encoding models for images
enczoo is a Python library with a single goal: to map images (as PIL.Images) to intermediate representations (as np.ndarray) from off-the-shelf vision models, such as AlexNet and ResNet50.
This library is meant for those who just need to compute off-the-shelf image features once for their project (and perhaps cache them elsewhere).
Installation
enczoo requires Python 3.12 or above, and may be installed using uv with the following command:
uv add enczoo
Usage
import enczoo
import PIL.Image
image = PIL.Image.open('my-image.png')
model = enczoo.ResNet50(layer_name='avgpool') # try layer4, layer3, ...
features = model.compute_features(images=[image]) # np.ndarray
# Want another layer? Check out: print(enczoo.ResNet50.layer_names)
Things enczoo handles
enczoo aims to "just work" by solving several tiny problems which collectively make computing image features a bit annoying. enczoo handles:
- performing model-specific image normalization ("was it -1 to 1, 0 to 1, 0-255...? ImageNet channel normalization...?"),
- correctly encoding images ("my image was in mode L, not RGB!")
- turning off any batch normalization ("was the model in training mode...?")
- extracting intermediate layers by name ("how do I do that forward hook thing again...?")
- turning off autograd, and returning tensors as
np.ndarray(no more.cpu().numpy()) - image cropping to fit input tensor shape (default: center cropping. no black bars!)
- and more!
Project details
Release history Release notifications | RSS feed
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 enczoo-0.1.0.tar.gz.
File metadata
- Download URL: enczoo-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
305415d1ba69df070ec99ceeb2543a88807176c5e3dc45843849dfb33e22739d
|
|
| MD5 |
d76d716f42783387b0540e4e85a891dc
|
|
| BLAKE2b-256 |
6a8d6065e69f4a967191dba309b3dac4f071ebf3a46fb1659bc0844b41f9c43b
|
File details
Details for the file enczoo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: enczoo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50aa62e6c56a19db21269fc3c2d4ea6cdee66eb769510ca26623493e00dbbe44
|
|
| MD5 |
d4bbf3e89c8af8f05fe70aa6de55d2d5
|
|
| BLAKE2b-256 |
cbb0baa95189685b597be857b0e31a40332106aef91f1d2dac989f5d3010584b
|