Map images (as `PIL.Images`) to intermediate representations (as `np.ndarray`) from off-the-shelf vision models.
Project description
enczoo: easily extract image features from pretrained vision models
enczoo is a Python library with a single goal: to enable you to map images (as PIL.Images) to image features (as numpy arrays) as easily as possible.
Features may be extracted from a zoo of popular, pretrained vision models, such as Imagenet-pretrained ResNet50 and CLIP ViT-B/16.
Installation
enczoo requires Python 3.12 or above, and it's recommended you use the wonderful uv to install it. Assuming you have uv, just run the following command in your project:
uv add enczoo
Usage
import enczoo
from PIL import Image
image = Image.open('my-image.png')
model = enczoo.ResNet50(layer_name='avgpool')
features = model.compute_features(images=[image]) # np.ndarray
# Want another layer? Check out: print(enczoo.ResNet50.layer_names)
Why develop enczoo?
Under the hood, enczoo solves several tiny problems which make correctly computing image features more annoying and error-prone than it should be. For example, enczoo automatically:
- performs model-specific image transforms ("was it -1 to 1, 0 to 1, or 0-255...?"),
- ensures images are in RGB format
- puts the model in inference, not training, mode
- turns off autograd
- returns tensors as
np.ndarray(no more.cpu().numpy()) - resizes the image while preserving aspect ratio
- 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.3.tar.gz.
File metadata
- Download URL: enczoo-0.1.3.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19c6006bb8751b7800b9b77eca884ac250ae0d124b69c281befd322082bd3f88
|
|
| MD5 |
d7307df8c2d7980586e6e6cef11feef1
|
|
| BLAKE2b-256 |
8b4b89f97d4c8ed469bec5836845c918c7d109391def422c388dc6956673e782
|
File details
Details for the file enczoo-0.1.3-py3-none-any.whl.
File metadata
- Download URL: enczoo-0.1.3-py3-none-any.whl
- Upload date:
- Size: 17.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3e72c159b68456060cee226e57217df74e07dd3fd01d3d73d7b7510d2a38f1c
|
|
| MD5 |
875928d1b642e9fd84dc704201f476e6
|
|
| BLAKE2b-256 |
fbcff69d6a22f82a6424efcff599b6c97381e2ce2ae52e829035d5d1d0ce1d27
|