Skip to content

Commit

Permalink
Don't build with AVIF by default, remove from deps, keep it private
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Aug 19, 2024
1 parent 096d7d5 commit 640a3d7
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion .github/scripts/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ conda create \
conda activate ci
conda install --quiet --yes libjpeg-turbo -c pytorch
pip install --progress-bar=off --upgrade setuptools==72.1.0
conda install libavif -c conda-forge --yes

# See https://github.com/pytorch/vision/issues/6790
if [[ "${PYTHON_VERSION}" != "3.11" ]]; then
Expand Down
2 changes: 0 additions & 2 deletions packaging/pre_build_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,5 @@ else
pip install auditwheel
fi

conda install libavif -c conda-forge -y

pip install numpy pyyaml future ninja
pip install --upgrade setuptools==72.1.0
2 changes: 0 additions & 2 deletions packaging/torchvision/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ requirements:
- libpng
- libjpeg-turbo
- libwebp
- libavif # -c conda-forge
- ffmpeg >=4.2.2, <5.0.0 # [linux]

host:
Expand All @@ -31,7 +30,6 @@ requirements:
- ffmpeg >=4.2.2, <5.0.0 # [linux]
- libjpeg-turbo
- libwebp
- libavif # -c conda-forge
- pillow >=5.3.0, !=8.3.*
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
{{ environ.get('CONDA_PYTORCH_CONSTRAINT', 'pytorch') }}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
USE_PNG = os.getenv("TORCHVISION_USE_PNG", "1") == "1"
USE_JPEG = os.getenv("TORCHVISION_USE_JPEG", "1") == "1"
USE_WEBP = os.getenv("TORCHVISION_USE_WEBP", "1") == "1"
USE_AVIF = os.getenv("TORCHVISION_USE_AVIF", "1") == "1"
USE_AVIF = os.getenv("TORCHVISION_USE_AVIF", "0") == "1" # TODO enable by default!
USE_NVJPEG = os.getenv("TORCHVISION_USE_NVJPEG", "1") == "1"
NVCC_FLAGS = os.getenv("NVCC_FLAGS", None)
# Note: the GPU video decoding stuff used to be called "video codec", which
Expand Down
3 changes: 0 additions & 3 deletions test/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ def smoke_test_torchvision_read_decode() -> None:
img_webp = read_image(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.webp"))
if img_webp.shape != (3, 100, 100):
raise RuntimeError(f"Unexpected shape of img_webp: {img_webp.shape}")
img_avif = read_image(str(SCRIPT_DIR / "assets/fakedata/logos/rgb_pytorch.avif"))
if img_avif.shape != (3, 100, 100):
raise RuntimeError(f"Unexpected shape of img_avif: {img_avif.shape}")


def smoke_test_torchvision_decode_jpeg(device: str = "cpu"):
Expand Down
9 changes: 4 additions & 5 deletions test/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from common_utils import assert_equal, cpu_and_cuda, IN_OSS_CI, needs_cuda
from PIL import __version__ as PILLOW_VERSION, Image, ImageOps, ImageSequence
from torchvision.io.image import (
decode_avif,
_decode_avif,
decode_gif,
decode_image,
decode_jpeg,
Expand Down Expand Up @@ -863,7 +863,7 @@ def test_decode_gif(tmpdir, name, scripted):
torch.testing.assert_close(tv_frame, pil_frame, atol=0, rtol=0)


@pytest.mark.parametrize("decode_fun", (decode_gif, decode_webp, decode_avif))
@pytest.mark.parametrize("decode_fun", (decode_gif, decode_webp))
def test_decode_gif_webp_errors(decode_fun):
encoded_data = torch.randint(0, 256, (100,), dtype=torch.uint8)
with pytest.raises(RuntimeError, match="Input tensor must be 1-dimensional"):
Expand All @@ -876,8 +876,6 @@ def test_decode_gif_webp_errors(decode_fun):
expected_match = re.escape("DGifOpenFileName() failed - 103")
elif decode_fun is decode_webp:
expected_match = "WebPDecodeRGB failed."
else:
expected_match = "avifDecoderParse failed: BMFF parsing failed"
with pytest.raises(RuntimeError, match=expected_match):
decode_fun(encoded_data)

Expand All @@ -893,7 +891,8 @@ def test_decode_webp(decode_fun, scripted):
assert img[None].is_contiguous(memory_format=torch.channels_last)


@pytest.mark.parametrize("decode_fun", (decode_avif, decode_image))
@pytest.mark.xfail(reason="AVIF support not enabled yet.")
@pytest.mark.parametrize("decode_fun", (_decode_avif, decode_image))
@pytest.mark.parametrize("scripted", (False, True))
def test_decode_avif(decode_fun, scripted):
encoded_bytes = read_file(next(get_images(FAKEDATA_DIR, ".avif")))
Expand Down
2 changes: 0 additions & 2 deletions torchvision/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
VideoMetaData,
)
from .image import (
decode_avif,
decode_gif,
decode_image,
decode_jpeg,
Expand Down Expand Up @@ -64,7 +63,6 @@
"decode_png",
"decode_webp",
"decode_gif",
"decode_avif",
"encode_jpeg",
"encode_png",
"read_file",
Expand Down
2 changes: 1 addition & 1 deletion torchvision/io/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def decode_webp(
return torch.ops.image.decode_webp(input)


def decode_avif(
def _decode_avif(
input: torch.Tensor,
) -> torch.Tensor:
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
Expand Down

0 comments on commit 640a3d7

Please sign in to comment.