Download src/openpi/shared/image_tools_test.py from Dengliming/StreamPIReal6_3w: direct link, hf CLI and curl.
- Browser
- Download file 1.42 kB
-
https://huggingface.co/Dengliming/StreamPIReal6_3w/resolve/main/src/openpi/shared/image_tools_test.py
- Command line
-
hf download hf://Dengliming/StreamPIReal6_3w/src/openpi/shared/image_tools_test.py
-
curl -L -o image_tools_test.py https://huggingface.co/Dengliming/StreamPIReal6_3w/resolve/main/src/openpi/shared/image_tools_test.py
1.42 kB
| import jax.numpy as jnp | |
| from openpi.shared import image_tools | |
| def test_resize_with_pad_shapes(): | |
| # Test case 1: Resize image with larger dimensions | |
| images = jnp.zeros((2, 10, 10, 3), dtype=jnp.uint8) # Input images of shape (batch_size, height, width, channels) | |
| height = 20 | |
| width = 20 | |
| resized_images = image_tools.resize_with_pad(images, height, width) | |
| assert resized_images.shape == (2, height, width, 3) | |
| assert jnp.all(resized_images == 0) | |
| # Test case 2: Resize image with smaller dimensions | |
| images = jnp.zeros((3, 30, 30, 3), dtype=jnp.uint8) | |
| height = 15 | |
| width = 15 | |
| resized_images = image_tools.resize_with_pad(images, height, width) | |
| assert resized_images.shape == (3, height, width, 3) | |
| assert jnp.all(resized_images == 0) | |
| # Test case 3: Resize image with the same dimensions | |
| images = jnp.zeros((1, 50, 50, 3), dtype=jnp.uint8) | |
| height = 50 | |
| width = 50 | |
| resized_images = image_tools.resize_with_pad(images, height, width) | |
| assert resized_images.shape == (1, height, width, 3) | |
| assert jnp.all(resized_images == 0) | |
| # Test case 3: Resize image with odd-numbered padding | |
| images = jnp.zeros((1, 256, 320, 3), dtype=jnp.uint8) | |
| height = 60 | |
| width = 80 | |
| resized_images = image_tools.resize_with_pad(images, height, width) | |
| assert resized_images.shape == (1, height, width, 3) | |
| assert jnp.all(resized_images == 0) | |