fix: fix multiapp tasks (#229)

Co-authored-by: adlsdztony <zzl0712@connect.hku.hk>
This commit is contained in:
XXZ
2025-07-03 21:53:58 +08:00
committed by GitHub
parent 7b2120c843
commit ac24ccce99
12 changed files with 57 additions and 28 deletions

View File

@@ -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: