mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 00:19:58 +01:00
WebP offers both lossless and lossy compression that can be superior to JPEG or PNG. Requests for WebP support directly in TF have come up before (e.g., https://github.com/tensorflow/tensorflow/issues/18250) but has been kept out of tree in the TFIO (https://github.com/tensorflow/io/pull/43). Unfortunately, the TFIO implementation hardcodes channels_ = 4, and doesn't have the same ShapeInferenceFn style of support that DecodeImage does. Let's just bring native WebP decode support into TF for tf.data directly. Animation is supported, and similar to decode_gif, decode_webp produces a tensor of [num_frames, height, width, channels], even for a still frame (num_frames = 1). To get 3D tensors instead, use decode_image with expand_animations = False. Note: libwebp (and maybe the WebP format?) only supports 4-channel animation, so channels will always be 4 for animations. PiperOrigin-RevId: 736966060
14 lines
514 B
Python
14 lines
514 B
Python
"""Point to the libwebp repo on GitHub."""
|
|
|
|
load("//third_party:repo.bzl", "tf_http_archive", "tf_mirror_urls")
|
|
|
|
def repo():
|
|
# Use the same libwebp release as tensorstore
|
|
tf_http_archive(
|
|
name = "libwebp",
|
|
strip_prefix = "libwebp-1.4.0",
|
|
sha256 = "12af50c45530f0a292d39a88d952637e43fb2d4ab1883c44ae729840f7273381",
|
|
urls = tf_mirror_urls("https://github.com/webmproject/libwebp/archive/v1.4.0.tar.gz"),
|
|
build_file = "//third_party/libwebp:libwebp.BUILD.bazel",
|
|
)
|