hcw-00 / PatchCore_anomaly_detection

Unofficial implementation of PatchCore anomaly detection
Apache License 2.0
317 stars 95 forks source link

when i tested some images by the code, the usage is getting bigger #31

Open leolv131 opened 2 years ago

leolv131 commented 2 years ago

when i tested some images by the code, the usage is getting bigger。 I find the problem is caused by the line code(features = self(x)): def test_step(self, batch, batch_idx): # Nearest Neighbour Search self.embedding_coreset = pickle.load(open(os.path.join(self.embedding_dir_path, 'embedding.pickle'), 'rb')) x, gt, label, file_name, x_type = batch

extract embedding

    features = self(x)
    embeddings = []
    for feature in features:
        m = torch.nn.AvgPool2d(3, 1, 1)
        embeddings.append(m(feature)) 

I used torch.no_gard() and torch.cuda.empty_cache(), but it is unuseful. why?