Skip to content

API Reference

This section documents the Tinify Python API.

Module Overview

Module Description
tinify.models Compression model architectures
tinify.entropy_models Entropy bottleneck and hyperprior models
tinify.latent_codecs Latent space encoding/decoding
tinify.layers Neural network layers (GDN, attention, etc.)
tinify.losses Rate-distortion loss functions
Metrics Quality and performance metrics
tinify.datasets Dataset loading utilities
tinify.transforms Data transformations
tinify.ops Custom operations

Top-Level Functions

available_entropy_coders

available_entropy_coders()

Return the list of available entropy coders.

Source code in tinify/__init__.py
def available_entropy_coders() -> list[str]:
    """
    Return the list of available entropy coders.
    """
    return _available_entropy_coders

get_entropy_coder

get_entropy_coder()

Return the name of the default entropy coder used to encode the bit-streams.

Source code in tinify/__init__.py
def get_entropy_coder() -> str:
    """
    Return the name of the default entropy coder used to encode the bit-streams.
    """
    return _entropy_coder

set_entropy_coder

set_entropy_coder(entropy_coder)

Specifies the default entropy coder used to encode the bit-streams.

Use :mod:available_entropy_coders to list the possible values.

Parameters:

Name Type Description Default
entropy_coder string

Name of the entropy coder

required
Source code in tinify/__init__.py
def set_entropy_coder(entropy_coder: str) -> None:
    """
    Specifies the default entropy coder used to encode the bit-streams.

    Use :mod:`available_entropy_coders` to list the possible values.

    Args:
        entropy_coder (string): Name of the entropy coder
    """
    global _entropy_coder
    if entropy_coder not in _available_entropy_coders:
        raise ValueError(
            f'Invalid entropy coder "{entropy_coder}", choose from'
            f'({", ".join(_available_entropy_coders)}).'
        )
    _entropy_coder = entropy_coder