Skip to content

Commit

Permalink
Fix copyright location and format
Browse files Browse the repository at this point in the history
Signed-off-by: blaz.rolih <blaz.rolih@fri.uni-lj.si>
  • Loading branch information
blaz-r committed Nov 21, 2024
1 parent 07e02fb commit fda2c4e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 32 deletions.
38 changes: 19 additions & 19 deletions src/anomalib/models/image/supersimplenet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Model Type: Segmentation

**SuperSimpleNet** is a simple yet strong discriminative defect / anomaly detection model evolved from the SimpleNet architecture. It consists of four components:
feature extractor with upscaling, feature adaptor, synthetic feature-level anomaly generation module, and
segmentation-detection module.
segmentation-detection module.

A ResNet-like feature extractor first extracts features, which are then upscaled and
average-pooled to capture neighboring context. Features are further refined for anomaly detection task in the adaptor module.
Expand All @@ -34,24 +34,24 @@ This implementation supports both unsupervised and supervised setting, but Anoma
## MVTec AD results

The following results were obtained using this Anomalib implementation trained for 300 epochs with seed 42, default params, and batch size 32.
| | **Image AUROC** | **Pixel AUPRO** |
The following results were obtained using this Anomalib implementation trained for 300 epochs with seed 42, default params, and batch size 32.
| | **Image AUROC** | **Pixel AUPRO** |
| ----------- | :-------------: | :-------------: |
| Bottle | 1.000 | 0.914 |
| Cable | 0.981 | 0.895 |
| Capsule | 0.990 | 0.926 |
| Carpet | 0.987 | 0.936 |
| Grid | 0.998 | 0.935 |
| Hazelnut | 0.999 | 0.946 |
| Leather | 1.000 | 0.972 |
| Metal_nut | 0.996 | 0.923 |
| Pill | 0.960 | 0.942 |
| Screw | 0.903 | 0.952 |
| Tile | 0.989 | 0.817 |
| Toothbrush | 0.917 | 0.861 |
| Transistor | 1.000 | 0.909 |
| Wood | 0.996 | 0.868 |
| Zipper | 0.996 | 0.944 |
| **Average** | 0.981 | 0.916 |
| Bottle | 1.000 | 0.914 |
| Cable | 0.981 | 0.895 |
| Capsule | 0.990 | 0.926 |
| Carpet | 0.987 | 0.936 |
| Grid | 0.998 | 0.935 |
| Hazelnut | 0.999 | 0.946 |
| Leather | 1.000 | 0.972 |
| Metal_nut | 0.996 | 0.923 |
| Pill | 0.960 | 0.942 |
| Screw | 0.903 | 0.952 |
| Tile | 0.989 | 0.817 |
| Toothbrush | 0.917 | 0.861 |
| Transistor | 1.000 | 0.909 |
| Wood | 0.996 | 0.868 |
| Zipper | 0.996 | 0.944 |
| **Average** | 0.981 | 0.916 |

For other results on VisA, SensumSODF, and KSDD2, refer to the [paper](https://arxiv.org/pdf/2408.03143).
6 changes: 3 additions & 3 deletions src/anomalib/models/image/supersimplenet/loss.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Loss function for the SuperSimpleNet model implementation."""

# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

from functools import partial

import torch
from torch import nn
from torchvision.ops.focal_loss import sigmoid_focal_loss

# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0


class SSNLoss(nn.Module):
"""SuperSimpleNet loss function.
Expand Down
22 changes: 12 additions & 10 deletions src/anomalib/models/image/supersimplenet/torch_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
"""PyTorch model for the SuperSimpleNet model implementation."""

# Original Code
# Copyright (c) 2024 Blaž Rolih
# https://github.com/blaz-r/SuperSimpleNet.
# SPDX-License-Identifier: MIT
#
# Modified
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

import math

import torch
Expand All @@ -11,15 +20,6 @@
from anomalib.models.components import GaussianBlur2d, TorchFXFeatureExtractor
from anomalib.models.image.supersimplenet.anomaly_generator import SSNAnomalyGenerator

# Original Code
# Copyright (c) 2024 Blaž Rolih
# https://github.com/blaz-r/SuperSimpleNet.
# SPDX-License-Identifier: MIT
#
# Modified
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0


class SuperSimpleNetModel(nn.Module):
"""SuperSimpleNet Pytorch model.
Expand Down Expand Up @@ -76,7 +76,9 @@ def forward(

if self.training:
masks = self.downsample_mask(masks, *features.shape[-2:])
labels = labels.type(torch.float32)
# make linter happy :)
if labels is not None:
labels = labels.type(torch.float32)

features, masks, labels = self.anomaly_generator(
adapted,
Expand Down

0 comments on commit fda2c4e

Please sign in to comment.