Code Monkey home page Code Monkey logo

dfr's Introduction

DFR

Project: Unsupervised Anomaly Detection and Segmentation

Paper: Unsupervised anomaly segmentation via deep feature reconstruction | [Neurocomputing]pdfcode | arxive preprintpdf

Introduction: Automatic detecting anomalous regions in images of objects or textures without priors of the anomalies is challenging, especially when the anomalies appear in very small areas of the images, making difficult-to-detect visual variations, such as defects on manufacturing products. This paper proposes an effective unsupervised anomaly segmentation approach that can detect and segment out the anomalies in small and confined regions of images. Concretely, we develop a multi-scale regional feature generator which can generate multiple spatial context-aware representations from pre-trained deep convolutional networks for every subregion of an image. The regional representations not only describe the local characteristics of corresponding regions but also encode their multiple spatial context information, making them discriminative and very beneficial for anomaly detection. Leveraging these descriptive regional features, we then design a deep yet efficient convolutional autoencoder and detect anomalous regions within images via fast feature reconstruction. Our method is simple yet effective and efficient. It advances the state-of-the-art performances on several benchmark datasets and shows great potential for real applications.

Qualitative results

image

Citation

If you find something useful, wellcome to cite our paper:

@article{YANG2022108874,
title = {Learning Deep Feature Correspondence for Unsupervised Anomaly Detection and Segmentation},
journal = {Pattern Recognition},
pages = {108874},
year = {2022},
issn = {0031-3203},
doi = {https://doi.org/10.1016/j.patcog.2022.108874},
url = {https://www.sciencedirect.com/science/article/pii/S0031320322003557},
author = {Jie Yang and Yong Shi and Zhiquan Qi},
}
@article{DFR2020,
    title = "Unsupervised anomaly segmentation via deep feature reconstruction",
    journal = "Neurocomputing",
    year = "2020",
    issn = "0925-2312",
    doi = "https://doi.org/10.1016/j.neucom.2020.11.018",
    url = "http://www.sciencedirect.com/science/article/pii/S0925231220317951",
    author = "Yong Shi and Jie Yang and Zhiquan Qi",
}
@misc{yang2020dfr,
      title={DFR: Deep Feature Reconstruction for Unsupervised Anomaly Segmentation}, 
      author={Jie Yang and Yong Shi and Zhiquan Qi},
      year={2020},
      eprint={2012.07122},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

dfr's People

Contributors

younggod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dfr's Issues

The loss function

In training, is the L2 distance used in the loss function and the relevant Euclidean distance not used? Is the experimental result of L2 distance better?
Thanks!

extractor.train()?

Hi, Thanks for your code!!

extractor was not included in the optimizer parameter.
So, I think the extractor was only used for inference, but wonder why used train().
In this case, batch_norm different results than eval().
because running_mean, running_var changed when train().

self.extractor.train()

self.extractor.train()

self.optimizer = optim.Adam(self.autoencoder.parameters(), lr=self.lr, weight_decay=0)

The evaluation images problem

I use the mask and anomaly_map of metrics_evaluation fuction write a out_image,but it is different with paper? Can you help me solve the problem?

Model not exists

Thanks for your code. Can you tell me what autoencoder.pth is? how to

Bug in evaluation code

Thanks for your open source!

I found a bug in the evaluation of Per Region Overlap.

props = measure.regionprops(label_map)
for prop in props:
x_min, y_min, x_max, y_max = prop.bbox # find the bounding box of an anomaly region
cropped_pred_label = binary_score_maps[i][x_min:x_max, y_min:y_max]
cropped_mask = masks[i][x_min:x_max, y_min:y_max]
intersection = np.logical_and(cropped_pred_label, cropped_mask).astype(np.float32).sum()
pro.append(intersection / prop.area)

When cropped_mask gets multiple regions as in the output below, intersection can return over 1.
image

Therefore, it needs to get only the center region of the crop area.
I think it will work correctly by changing cropped_mask to prop.filled_image.

Please check it out.

TestDataset error

class TestDataset(Dataset):
    ......
    def _get_image_files(self, path, ext={'.jpg', '.png'}):
        images = []
        for root, dirs, files in os.walk(path):
            if "check" in root:
                continue
            print('loading image files ' + root)

            # for file in files:
            #     if os.path.splitext(file)[-1] in ext and 'checkpoint' not in file:
            #         images.append(os.path.join(root, file))

            for dir in dirs:
                for file in os.listdir(os.path.join(path, dir)):
                    if os.path.splitext(file)[-1] in ext and 'checkpoint' not in file:
                        images.append(os.path.join(root, dir, file))
        return sorted(images)

visualization image

hi, during evaluation, how can I get the amomaly score map and the anomaly segmentation image?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.