fix: fix multiapp tasks (#229)
Co-authored-by: adlsdztony <zzl0712@connect.hku.hk>
This commit is contained in:
@@ -193,7 +193,7 @@ def structure_check_by_mse(img1, img2, threshold=0.03):
|
||||
(np.array(img1, dtype=np.float32) / 255
|
||||
- np.array(img2, dtype=np.float32) / 255) ** 2)
|
||||
structure_same = True if mse < threshold else False
|
||||
print("MSE: ", mse)
|
||||
print(f"MSE: {mse}, threshold: {threshold}")
|
||||
return structure_same
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ def structure_check_by_ssim(img1, img2, threshold=0.9):
|
||||
return similarity >= threshold
|
||||
|
||||
|
||||
def check_brightness_decrease_and_structure_sim(src_path, tgt_path):
|
||||
def check_brightness_decrease_and_structure_sim(src_path, tgt_path, threshold=0.03):
|
||||
"""
|
||||
Check the brightness of src is lower than tgt and the structures are similar
|
||||
gimp:7a4deb26-d57d-4ea9-9a73-630f66a7b568
|
||||
@@ -219,13 +219,15 @@ def check_brightness_decrease_and_structure_sim(src_path, tgt_path):
|
||||
brightness_src = calculate_brightness(img_src)
|
||||
brightness_tgt = calculate_brightness(img_tgt)
|
||||
brightness_reduced = brightness_tgt > brightness_src
|
||||
|
||||
# print(f"Brightness src: {brightness_src}, tgt: {brightness_tgt}, reduced: {brightness_reduced}")
|
||||
|
||||
# Normalize and compare images
|
||||
target_brightness = 128
|
||||
img_src_normalized = normalize_brightness(img_src, target_brightness)
|
||||
img_tgt_normalized = normalize_brightness(img_tgt, target_brightness)
|
||||
|
||||
structure_same = structure_check_by_mse(img_src_normalized, img_tgt_normalized)
|
||||
structure_same = structure_check_by_mse(img_src_normalized, img_tgt_normalized, threshold=threshold)
|
||||
if brightness_reduced and structure_same:
|
||||
return 1.
|
||||
else:
|
||||
|
||||
@@ -63,11 +63,13 @@ def compare_epub(result: str, expected: str) -> float:
|
||||
result_files: List[str] = process_epub(result)
|
||||
expected_files: List[str] = process_epub(expected)
|
||||
|
||||
metric: float = 1.
|
||||
metric: float = 0.
|
||||
for f1, f2 in zip(result_files, expected_files):
|
||||
current_metric: float = diff_text_file(f1, f2)
|
||||
logger.debug("%s vs %s: %f", f1, f2, current_metric)
|
||||
metric *= current_metric
|
||||
metric += current_metric
|
||||
if len(result_files) > 0:
|
||||
metric /= len(result_files)
|
||||
return metric
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user