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 features (as np.ndarray) from intermediate layers of off-the-shelf vision models, such as AlexNet and ResNet50.

This library is meant for those who 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 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

You can also install enczoo using pip by running:

pip install 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)

Why develop enczoo?

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 normalization ("was it -1 to 1, 0 to 1, or 0-255...? ImageNet channel normalization...?"),
  • correctly encodes images ("my image was in mode L, not RGB!")
  • turns off batch normalization ("was the model in training mode...?")
  • extracts intermediate layers by name ("how do I do that forward hook thing again...?")
  • turns off autograd, and returns tensors as np.ndarray (no more .cpu().numpy())
  • performs image cropping to fit images to the expected input tensor shape
  • 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.2.tar.gz (10.1 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.2-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for enczoo-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e69a16f19c38e62edebc7764b2e7fc734659d91c23f9dd4ba3c6a76e91d47dde
MD5 0a35aee5eca3094871c2ffd8039c62a8
BLAKE2b-256 ea651f909767902936a403e9f7ba850c432e99d565d804398f7e2fbdfe7d414c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: enczoo-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.12

File hashes

Hashes for enczoo-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6ebb3ab9770f6db38aceabcc9e608247565e7f575fe1fbf7ec184758cbd07c5d
MD5 194335374b137261a948edd792a4956d
BLAKE2b-256 7e1cfdcd4164a40383b87408298b590420f48eb3dcdd8e3bc079b9e0425d6b43

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