:py:mod:`anomalib.utils.loggers.wandb`
======================================
.. py:module:: anomalib.utils.loggers.wandb
.. autoapi-nested-parse::
wandb logger with add image interface.
Module Contents
---------------
Classes
~~~~~~~
.. autoapisummary::
anomalib.utils.loggers.wandb.AnomalibWandbLogger
.. py:class:: AnomalibWandbLogger(name: Optional[str] = None, save_dir: Optional[str] = None, offline: Optional[bool] = False, id: Optional[str] = None, anonymous: Optional[bool] = None, version: Optional[str] = None, project: Optional[str] = None, log_model: Union[str, bool] = False, experiment=None, prefix: Optional[str] = '', **kwargs)
Bases: :py:obj:`anomalib.utils.loggers.base.ImageLoggerBase`, :py:obj:`pytorch_lightning.loggers.wandb.WandbLogger`
Logger for wandb.
Adds interface for `add_image` in the logger rather than calling the experiment object.
.. note:: Same as the wandb Logger provided by PyTorch Lightning and the doc string is reproduced below.
Log using `Weights and Biases `_.
Install it with pip:
.. code-block:: bash
$ pip install wandb
:param name: Display name for the run.
:param save_dir: Path where data is saved (wandb dir by default).
:param offline: Run offline (data can be streamed later to wandb servers).
:param id: Sets the version, mainly used to resume a previous run.
:param version: Same as id.
:param anonymous: Enables or explicitly disables anonymous logging.
:param project: The name of the project to which this run will belong.
:param log_model: Save checkpoints in wandb dir to upload on W&B servers.
:param prefix: A string to put at the beginning of metric keys.
:param experiment: WandB experiment object. Automatically set when creating a run.
:param \*\*kwargs: Arguments passed to :func:`wandb.init` like `entity`, `group`, `tags`, etc.
:raises ImportError: If required WandB package is not installed on the device.
:raises MisconfigurationException: If both ``log_model`` and ``offline``is set to ``True``.
.. rubric:: Example
>>> from anomalib.utils.loggers import AnomalibWandbLogger
>>> from pytorch_lightning import Trainer
>>> wandb_logger = AnomalibWandbLogger()
>>> trainer = Trainer(logger=wandb_logger)
Note: When logging manually through `wandb.log` or `trainer.logger.experiment.log`,
make sure to use `commit=False` so the logging step does not increase.
.. seealso::
- `Tutorial `__
on how to use W&B with PyTorch Lightning
- `W&B Documentation `__
.. py:method:: add_image(image: Union[numpy.ndarray, matplotlib.figure.Figure], name: Optional[str] = None, **kwargs: Any)
Interface to add image to wandb logger.
:param image: Image to log
:type image: Union[np.ndarray, Figure]
:param name: The tag of the image
:type name: Optional[str]
.. py:method:: save() -> None
Upload images to wandb server.
.. note:: There is a limit on the number of images that can be logged together to the `wandb` server.