Skip to content

Commit

Permalink
mod
Browse files Browse the repository at this point in the history
  • Loading branch information
a-hanamoto committed Apr 27, 2020
1 parent 1c6fe9f commit 4829f61
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cfg/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ model_params:
num_of_nonzero: 3 # number of nonzero (default: 3)
cutoff_edge_width: 2
num_of_ch: 896 # number of channels used for anomaly detection (1<=num_of_ch<=896)
output_npy: True
output_npy: False
2 changes: 1 addition & 1 deletion cfg/sample_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ model_params:
num_of_nonzero: 3 # number of nonzero (default: 3)
cutoff_edge_width: 2
num_of_ch: 100 # number of channels used for anomaly detection (1<=num_of_ch<=896)
output_npy: True
output_npy: False
2 changes: 1 addition & 1 deletion src/dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TestDatasetandDataLoader(unittest.TestCase):

def test_dataset(self):
self.assertEqual(len(self.mvtec_dataset), 2)
self.assertEqual(len(self.mvtec_dataset[0]), 2)
self.assertEqual(len(self.mvtec_dataset[0]), 3)

def test_dataloader(self):
self.assertEqual(len(self.dataloader), 2)
Expand Down
15 changes: 12 additions & 3 deletions src/models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ class TestCalculateScore(unittest.TestCase):

model = models.SparseCodingWithMultiDict([], model_params)

def output_np_array(self):
batch_path = "test"
batch_name = "sample.png"
f_diff = np.ones([1, 10, 10])
self.model.output_np_array(batch_path, batch_name, f_diff)
self.assertTrue(os.path.exists("test/sample.npy"))
shutil.rmtree("test")

def test_output_image(self):
is_positive = True
batch_path = "good"
batch_name = "image.png"
ch_err = np.ones([896])
output_img = np.zeros([10, 10, 3])
self.model.output_image(is_positive, batch_name, ch_err, output_img)
self.assertTrue(os.path.exists("visualized_results/pos/image-896.png"))
self.model.output_image(batch_path, batch_name, ch_err, output_img)
self.assertTrue(os.path.exists(
"visualized_results/good/image-896.png"))
shutil.rmtree("visualized_results")

def test_calclate_ssim(self):
Expand Down

0 comments on commit 4829f61

Please sign in to comment.