Registry / ai-ml / resize-right

resize-right

JSON →
library0.0.2pypypiunverified

Resize Right is a Python library providing a single, highly flexible `resize` function for image resizing. It supports both NumPy arrays and PyTorch tensors, offering various scaling options, padding modes, and output shape controls. The current version is 0.0.2. Releases appear to be infrequent, indicating a stable, focused utility rather than a rapidly evolving project.

pip install resize-right
INSTALL
IMPORT
SIG · RESIZE-RIGHT
R
resize-right
ai-mlpythonv0.0.2
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

resize
from resize_right import resize
from resize_right import resize

Demonstrates resizing a batch of NumPy images using both `scale_factors` and `out_shape` parameters. The library handles `(B, H, W, C)` for NumPy and `(B, C, H, W)` for PyTorch tensors.

import numpy as np from resize_right import resize # Create a dummy 4D NumPy array (batch, H, W, channels) # representing a batch of 2 images, 100x100 pixels, 3 channels image_batch = np.random.rand(2, 100, 100, 3).astype(np.float32) print(f"Original shape: {image_batch.shape}") # Resize to half the size using scale_factors resized_batch_scale = resize(image_batch, scale_factors=0.5) print(f"Resized by scale_factors (0.5) shape: {resized_batch_scale.shape}") # Resize to a specific output shape [50, 50] (for H, W) resized_batch_shape = resize(image_batch, out_shape=[50, 50]) print(f"Resized by out_shape ([50, 50]) shape: {resized_batch_shape.shape}")
Debug
Known issues
gotchaInput array layout for NumPy: `resize_right` expects NumPy arrays in `(batch, height, width, channels)` format. Providing `(batch, channels, height, width)` (common in PyTorch) will lead to incorrect resizing or errors due to misinterpretation of dimensions.
fix
Ensure NumPy arrays are consistently `(B, H, W, C)`. If converting from a `(B, C, H, W)` source, use `array.transpose(0, 2, 3, 1)` before passing to `resize_right.resize`.
affects: 0.0.x
gotchaConflicting `out_shape` and `scale_factors` parameters: If both `out_shape` and `scale_factors` are provided, `out_shape` will take precedence, and `scale_factors` will be ignored. This might lead to unexpected output dimensions if the user intends `scale_factors` to be the primary control.
fix
Provide only one of `out_shape` or `scale_factors` to explicitly control the resizing behavior. If dynamic scaling is needed, calculate `out_shape` based on `scale_factors` manually and then pass only `out_shape`.
affects: 0.0.x
gotchaHandling of non-float data types: While `resize_right` generally works with various numeric types, it's primarily designed for floating-point image data (e.g., `float32`, `float64`) common in deep learning pipelines. Using integer types might lead to precision loss or unexpected results during interpolation, especially for downsampling.
fix
Convert input arrays to `float32` or `float64` using `array.astype(np.float32)` before resizing for optimal results and to avoid potential issues with interpolation algorithms.
affects: 0.0.x
Upgrade
Version history
0.0.2latest on PyPI · released May 5, 2022
Audit
Dependencies
numpyrequiredCore functionality relies on NumPy arrays for image manipulation.
torchoptionalRequired only if you intend to resize PyTorch tensors.
Agent activity
10 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
resize-right — pip install resize-right · libregistry