Metadata-Version: 2.3
Name: enczoo
Version: 0.1.1
Summary: Map images (as `PIL.Images`) to intermediate representations (as `np.ndarray`) from off-the-shelf vision models.
Author: himjl
Author-email: himjl <mil@mit.edu>
License: MIT License
         
         Copyright (c) 2026 Michael J. Lee
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
Requires-Dist: pillow>=12.1.0
Requires-Dist: torch>=2.9.1
Requires-Dist: torchvision>=0.24.1
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# `enczoo`: a zoo of encoding models for images

[![CI](https://github.com/himjl/enczoo/actions/workflows/ci.yml/badge.svg)](https://github.com/himjl/enczoo/actions/workflows/ci.yml)

`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](https://docs.astral.sh/uv/) with the following command: 

>`uv add enczoo`
 
### Usage 

```python
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!
