pytorch-image
Minimalistic library designed to be an interface for the model input with a lightweight Image class.
from my_model import MyModel, Image
image = Image.from_numpy(numpy_image)
predictions = model(image)
It also offers a simple interface for essential image operations such as loading, resizing, augmenting, and saving.
Installation
pip install pytorch-image
poetry add pytorch-image
Usage
from pytorch_image import Image
import albumentations
image = Image.open("path/to/image.png")
image.augment(albumentations.HorizontalFlip())
image.torch()
Available Methods
The Image class provides the following methods:
Class Methods
Image.open(path): Open an image file and create an Image instance.Image.from_pil_image(pil_image): Create an Image instance from a PIL Image.Image.from_numpy(numpy_image): Create an Image instance from a NumPy array. Expects HWC format, uint8 (0-255).Image.from_torch(torch_tensor): Create an Image instance from a PyTorch tensor. Expects NCHW format, float (0-1).Image.cat(images, dim=0): Concatenate multiple Image instances.
Instance Methods
resize(shape, mode="bicubic", align_corners=None, antialias=None): Resize the image.augment(augmenter): Apply augmentations to the image.map(func): Apply a function to the image data.replace(**kwargs): Create a new Image instance with replaced attributes.torch(): Get the image data as a PyTorch tensor.numpy(): Get the image data as a NumPy array.representation(): Get a normalized representation of the image data.save(path): Save the image to a file.pil_image(): Convert the image to a PIL Image.
Properties and Special Methods
shape: Get the shape of the image data.__len__(): Get the number of images in the batch.__iter__(): Iterate over images in the batch.__getitem__(index): Get a specific image from the batch._repr_png_(): Get a PNG representation for Jupyter notebook display.
For detailed information on each method, please refer to the docstrings in the source code.
Metadata
Release files for pytorch-image 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pytorch_image-1.0.2.tar.gz | 3.7 kB | Without provenance | Details for pytorch_image-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pytorch_image-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for pytorch_image-1.0.2-py3-none-any.whl |
Total release size: 8.0 kB
Release files / pytorch_image-1.0.2.tar.gz
| Download URL | pytorch_image-1.0.2.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29c40ea3d778f7fd54e47d1f3e1d1e0e4eaa734ef5de392b3a099804438d0e38
|
|
BLAKE2b-256 checksum How to use checksums |
afe52b9547ae127d311287a4c416a2bf683fc3f0f6ce9b2e156817bec2973175
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.20 Linux/6.8.0-1014-azure
|
Release files / pytorch_image-1.0.2-py3-none-any.whl
| Download URL | pytorch_image-1.0.2-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d64363159ac96e3a6715ee03f550fb8b71e81606912f5fe0f4455b5d7980ca5d
|
|
BLAKE2b-256 checksum How to use checksums |
295b7f933d67fb94dfb5baa8b8f9f6b503da48ef1dcc85c00d204a2b634a9127
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.20 Linux/6.8.0-1014-azure
|
Security for pytorch-image 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.