compressai_trainer.plot#

For plotting.

compressai_trainer.plot.featuremap_image(arr: numpy.ndarray, nrows: Optional[int] = None, ncols: Optional[int] = None, padding: Optional[int] = None, fill_value: Optional[float] = None, clim: Optional[Tuple[float, float]] = None, cmap: Optional[str] = None) numpy.ndarray[source]#

Returns 2D featuremap image of tiled channels for the given tensor.

Parameters
  • arr – tensor of shape (c, …)

  • nrows – number of tiled rows

  • ncols – number of tiled columns

  • padding – padding between tiles (default is 2 for arr.ndim > 2)

  • fill_value – value to set remaining area to

  • clim – colorbar limits

  • cmap – colormap; if None, no colormap is applied

compressai_trainer.plot.featuremap_matplotlib(arr: np.ndarray, *, nrows: Optional[int] = None, ncols: Optional[int] = None, padding: Optional[int] = None, fill_value: Optional[float] = None, clim: Optional[Tuple[float, float]] = None, cmap: str = 'plasma', cbar: bool = True, ax: Optional[plt.Axes] = None, tile_method: str = 'reshape', **fig_kw) plt.Figure[source]#

Plots 3D tensor as a 2D featuremap of tiled channels.

Note

tile_method="loop" is slow due to the nested loop. For a faster alternative with slightly lower publication quality, try tile_method="reshape".

Parameters
  • arr – chw tensor

  • nrows – number of tiled rows

  • ncols – number of tiled columns

  • padding – padding between tiles

  • fill_value – value to set remaining area to

  • clim – colorbar limits

  • cmap – colormap

  • cbar – whether to show colorbar

  • tile_method – “reshape” (default, fast) or “loop” (slow)

  • fig_kw – keyword arguments to pass to matplotlib

compressai_trainer.plot.plot_entropy_bottleneck_distributions(entropy_bottleneck: compressai.entropy_models.entropy_models.EntropyBottleneck, scatter_kwargs: dict[str, Any] = {}, layout_kwargs: dict[str, Any] = {}, hide_delta_distributions: bool = True)[source]#

Plots EntropyBottleneck distributions.

compressai_trainer.plot.plot_pdf_signatures(x: list[numpy.ndarray], p: list[numpy.ndarray], p_hat: list[numpy.ndarray], *, backend: str = 'matplotlib', **kwargs)[source]#

Plots PDF signatures of per-sample measured and encoding distributions.

Probability distribution functions (pdf) can be plotted as a 2D image.

  • The x-axis represents the channel index.

  • The y-axis represents the bin index.

  • Color intensity represents the negative log-likelihood (in bits) of the probability of the bin.

This is useful for visualizing the efficacy of probability distribution reconstruction/correction models.

Parameters
  • x – List of input images.

  • p – List of measured probability distributions (targets).

  • p_hat – List of encoding probability distributions.

  • backend – Backend to use for plotting (“matplotlib” or “plotly”).

compressai_trainer.plot.plot_rd(df: pd.DataFrame, metric: str = 'psnr', scatter_kwargs: dict[str, Any] = {}, layout_kwargs: dict[str, Any] = {})[source]#

Plots RD curve.