---
title: Deep Image Structure And Texture Similarity (DISTS)
description: Calculates Deep Image Structure and Texture Similarity (DISTS) score.
canonical: 'https://lightning.ai/docs/torchmetrics/stable/image/dists'
---
# Deep Image Structure And Texture Similarity (DISTS) {#deep-image-structure-and-texture-similarity-dists}

## Module Interface {#module-interface}

### `class torchmetrics.image.dists.DeepImageStructureAndTextureSimilarity(reduction='mean', **kwargs)` {#torchmetrics.image.dists.DeepImageStructureAndTextureSimilarity}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/image/dists.py#L31-L136)

Calculates Deep Image Structure and Texture Similarity (DISTS) score.

The metric is a full-reference image quality assessment (IQA) model that combines sensitivity to structural distortions (e.g., artifacts due to noise, blur, or compression) with a tolerance of texture resampling (exchanging the content of a texture region with a new sample of the same texture). The metric is based on a convolutional neural network (CNN) that transforms the reference and distorted images to a new representation. Within this representation, a set of measurements are developed that are sufficient to capture the appearance of a variety of different visual distortions.

As input to `forward` and `update` the metric accepts the following input

*   `preds` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): tensor with images of shape `(N, 3, H, W)`
    
*   `target` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): tensor with images of shape `(N, 3, H, W)`
    

As output of forward and compute the metric returns the following output

*   `lpips` ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")): returns float scalar tensor with average LPIPS value over samples
    

Parameters:

*   **reduction** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'mean'`, `'sum'`\]\]) – specifies the reduction to apply to the output.
    
*   **kwargs** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.15)")) – Additional keyword arguments, see [Advanced metric settings](/docs/torchmetrics/1.9.0/user-guide/overview.md#metric-kwargs) for more info.
    

Raises:

[**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError "(in Python v3.15)") – If reduction is not one of \[“mean”, “sum”\]

Example

```python
>>> from torch import rand
>>> from torchmetrics.image.dists import DeepImageStructureAndTextureSimilarity
>>> metric = DeepImageStructureAndTextureSimilarity()
>>> preds = rand(10, 3, 100, 100)
>>> target = rand(10, 3, 100, 100)
>>> metric(preds, target)
tensor(0.1882, grad_fn=<CloneBackward0>)
```

#### `plot(val=None, ax=None)` {#torchmetrics.image.dists.DeepImageStructureAndTextureSimilarity.plot}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/image/dists.py#L96-L136)

Plot a single or multiple values from the metric.

Parameters:

*   **val** (`Union`\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)"), [`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence "(in Python v3.15)")\[[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")\], [`None`](https://docs.python.org/3/builtins/constants.html#None "(in Python v3.15)")\]) – Either a single result from calling metric.forward or metric.compute or a list of these results. If no value is provided, will automatically call metric.compute and plot that result.
    
*   **ax** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Axes`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes "(in Matplotlib v3.11.2)")\]) – An matplotlib axis object. If provided will add plot to that axis
    

Return type:

[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple "(in Python v3.15)")\[[`Figure`](https://matplotlib.org/stable/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure "(in Matplotlib v3.11.2)"), `Union`\[[`Axes`](https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.html#matplotlib.axes.Axes "(in Matplotlib v3.11.2)"), [`ndarray`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html#numpy.ndarray "(in NumPy v2.5)")\]\]

Returns:

Figure and Axes object

Raises:

[**ModuleNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#ModuleNotFoundError "(in Python v3.15)") – If matplotlib is not installed

```python
>>> # Example plotting a single value
>>> import torch
>>> from torchmetrics.image.dists import DeepImageStructureAndTextureSimilarity
>>> metric = DeepImageStructureAndTextureSimilarity()
>>> metric.update(torch.rand(10, 3, 100, 100), torch.rand(10, 3, 100, 100))
>>> fig_, ax_ = metric.plot()
```

[![../../\_images/dists-1.png](/docs/torchmetrics/1.9.0/static/_images/dists-1.png)](/docs/torchmetrics/1.9.0/static/_images/dists-1.png)

```python
>>> # Example plotting multiple values
>>> import torch
>>> from torchmetrics.image.dists import DeepImageStructureAndTextureSimilarity
>>> metric = DeepImageStructureAndTextureSimilarity()
>>> values = [ ]
>>> for _ in range(3):
...     values.append(metric(torch.rand(10, 3, 100, 100), torch.rand(10, 3, 100, 100)))
>>> fig_, ax_ = metric.plot(values)
```

[![../../\_images/dists-2.png](/docs/torchmetrics/1.9.0/static/_images/dists-2.png)](/docs/torchmetrics/1.9.0/static/_images/dists-2.png)

## Functional Interface {#functional-interface}

### `torchmetrics.functional.image.dists.deep_image_structure_and_texture_similarity(preds, target, reduction=None)` {#torchmetrics.functional.image.dists.deep_image_structure_and_texture_similarity}

[\[source\]](https://github.com/Lightning-AI/torchmetrics/blob/v1.9.0/src/torchmetrics/functional/image/dists.py#L193-L217)

Calculates [Deep Image Structure and Texture Similarity](https://arxiv.org/abs/2004.07728) (DISTS) score.

Parameters:

*   **preds** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – Predicted image tensor.
    
*   **target** ([`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")) – Target image tensor.
    
*   **reduction** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional "(in Python v3.15)")\[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal "(in Python v3.15)")\[`'sum'`, `'mean'`, `'none'`\]\]) – Reduction method for the output.
    

Return type:

[`Tensor`](https://docs.pytorch.org/docs/stable/tensors.html#torch.Tensor "(in PyTorch v2.15)")

Returns:

DISTS Similarity score between the two images.

Example

```python
>>> from torch import rand
>>> preds = rand(5, 3, 256, 256)
>>> target = rand(5, 3, 256, 256)
>>> deep_image_structure_and_texture_similarity(preds, target)
tensor([0.1285, 0.1344, 0.1356, 0.1277, 0.1276], grad_fn=<RsubBackward1>)
>>> deep_image_structure_and_texture_similarity(preds, target, reduction='mean')
tensor(0.1308, grad_fn=<MeanBackward0>)
```

---

**Navigation**

- Parent: [Image](/docs/torchmetrics/1.9.0/image.md)
