Skip to main content

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

CI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

enczoo-0.1.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

enczoo-0.1.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file enczoo-0.1.1.tar.gz.

File metadata

  • Download URL: enczoo-0.1.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for enczoo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4305c36374ea3b86d02ad2c9c6aa37f6b94a6edc594d97ca93d576a5404992fd
MD5 804dc6426b02161028934f04ba12bf01
BLAKE2b-256 d55e5f73ed60edfbadd15b819f7eeb64312b9b37eb237c7622743135394627a6

See more details on using hashes here.

File details

Details for the file enczoo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: enczoo-0.1.1-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

Hashes for enczoo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1c6c50927e012e9e8ae83fea15613115e404c86955ede54ea304a011798b537
MD5 3593d909df93b5341d4400c8ebf0310b
BLAKE2b-256 e004c94d2e5829ed5fefcd63df18f7f1d5b27632419bf37f48fb0f0ee117df50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page