Skip to content
Snippets Groups Projects

Fix Issues when running tests on the CI

Merged Daniel CARRON requested to merge ci-db-paths into update-tests
2 files
+ 35
20
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 25
16
@@ -203,7 +203,10 @@ class DatabaseCheckers:
@staticmethod
def check_image_quality(
datamodule, reference_histogram_file, pearson_coeff_threshold=0.005
datamodule,
reference_histogram_file,
compare_type="equal",
pearson_coeff_threshold=0.005,
):
ref_histogram_splits = JSONDatabaseSplit(reference_histogram_file)
@@ -226,21 +229,27 @@ class DatabaseCheckers:
dataset_sample_index
][0]
image_tensor = numpy.multiply(image_tensor.numpy(), 255).astype(
int
)
histogram = numpy.histogram(
image_tensor, bins=256, range=(0, 256)
)[0].tolist()
# We cannot test if histograms are exactly equal because
# the torch.resize transform is inconsistent depending on the environment.
# assert histogram == ref_hist_data
# Compute pearson coefficients between histogram and reference
# and check the similarity within a certain threshold
pearson_coeffs = numpy.corrcoef(histogram, ref_hist_data)
assert 1 - pearson_coeff_threshold <= pearson_coeffs[0][1] <= 1
histogram = []
for color_channel in image_tensor:
color_channel = numpy.multiply(
color_channel.numpy(), 255
).astype(int)
histogram.extend(
numpy.histogram(
color_channel, bins=256, range=(0, 256)
)[0].tolist()
)
if compare_type == "statistical":
# Compute pearson coefficients between histogram and reference
# and check the similarity within a certain threshold
pearson_coeffs = numpy.corrcoef(histogram, ref_hist_data)
assert (
1 - pearson_coeff_threshold <= pearson_coeffs[0][1] <= 1
)
else:
assert histogram == ref_hist_data
@pytest.fixture
Loading