Self-Supervised Anomaly Segmentation


This is a PyToch implementation of A Novel Self-supervised Learning Task Designed for Anomaly Segmentation, it contains two mainly parts, Pseudo Mask Generator and Anomaly Segmentation Framework, as shown in next:

Pseudo Mask Generator:

Anomaly Segmentation Framework(ResNet50+FPN+DBNet):


  • we propose a novel self-supervised learning pretext task, which is different from generation-based methods or commonly contrastive leanring, it generat pseudo mask from other labeled dataset such as CoCo, and every suitable for pixelwise downstream tasks.
  • we present an end-to-end anomaly segmenation framework, it has both high speed and accuracy, and with no post-processing.
  • our method achieve SOTA in three anomaly detection/segmentation datasets. (#ToDo)

Anomaly Segmentation Demo(SHTech dataset)

Dataset Download

Installation and Usage

  1. prepare environment:

    conda create -n ssas python=3.7.6
    conda activate ssas
    pip install -r requirements.txt
    git clone
  2. prepare coco pseudo mask:

    cd dataset
    python --image_dir {coco img folder} --annotation_path {coco_annotation.json}
    cd ..
  3. training vad dataset(such as Ped2, SHTech):

    python --dataset_path {your dataset path}
  4. evaluation:

    python --dataset_path {your dataset path}
  5. testing(generating segmentation demo):

    python --input {test imgs or video or camera} --output {save dir} --weights {}

Training Sample


If you find our work useful, please cite as follow:

{   ssas,
    author = {Wu Fan},
    title = { Self-Supervised Anomaly Segmentation },
    year = {2021},
    url = {\url{}}


GitHub - wufan-tb/ssas at
Self-Supervised Anomaly Segmentation. Contribute to wufan-tb/ssas development by creating an account on GitHub.