Merge branch 'main' into zhoujun/gimp

This commit is contained in:
BlankCheng
2024-01-30 14:36:21 +08:00
30 changed files with 669 additions and 214 deletions

View File

@@ -211,7 +211,10 @@ def check_brightness_decrease_and_structure_sim(src_path, tgt_path):
img_tgt_normalized = normalize_brightness(img_tgt, target_brightness)
structure_same = structure_check_by_mse(img_src_normalized, img_tgt_normalized)
return brightness_reduced and structure_same
if brightness_reduced and structure_same:
return 1.
else:
return 0.
def check_saturation_increase_and_structure_sim(src_path, tgt_path):
@@ -240,7 +243,10 @@ def check_saturation_increase_and_structure_sim(src_path, tgt_path):
else:
structure_same = False
return saturation_increased and structure_same
if saturation_increased and structure_same:
return 1.
else:
return 0.
def check_file_exists_and_structure_sim(src_path, tgt_path):
@@ -294,7 +300,10 @@ def check_triangle_position(tgt_path):
tolerance = 0.05 * np.array(img_array.shape[:2])
middle = np.all(np.abs(centroid - image_center) < tolerance)
return middle
if bool(middle):
return 1.
else:
return 0.
def check_structure_sim(src_path, tgt_path):
@@ -325,7 +334,10 @@ def check_contrast_increase_and_structure_sim(src_path, tgt_path):
# Check structure
structure_same = structure_check_by_ssim(source_image, target_image, threshold=0.65)
return higher_contrast and structure_same
if higher_contrast and structure_same:
return 1.
else:
return 0.
def check_config_status(actual_config_path, rule):
@@ -341,13 +353,13 @@ def check_config_status(actual_config_path, rule):
items = line.strip().lstrip('(').rstrip(')\n').split()
if isinstance(rule["key"], str):
if items[0] == rule["key"] and items[-1] == rule["value"]:
return True
return 1.
elif isinstance(rule["key"], list) and len(rule["key"]) == 2:
if items[0] == rule["key"][0] \
and items[1] == rule["key"][1] \
and items[-1] == rule["value"]:
return True
return False
return 1.
return 0.
def check_image_size_and_structure_sim(src_path, tgt_path, height=512, width=None):
@@ -373,7 +385,10 @@ def check_image_size_and_structure_sim(src_path, tgt_path, height=512, width=Non
resized_target_image = target_image.resize(source_image.size)
structure_same = structure_check_by_ssim(source_image, resized_target_image)
return width_same and height_same and structure_same
if width_same and height_same and structure_same:
return 1.
else:
return 0.
def check_palette_and_structure_sim(src_path, tgt_path):
@@ -389,7 +404,10 @@ def check_palette_and_structure_sim(src_path, tgt_path):
target_image = Image.open(tgt_path)
source_image = source_image.convert('RGB')
structure_same = structure_check_by_ssim(source_image, target_image)
return palette_based and structure_same
if palette_based and structure_same:
return 1.
else:
return 0.
def check_textbox_on_leftside(src_path):
@@ -411,7 +429,10 @@ def check_textbox_on_leftside(src_path):
break # Stop after finding the first dark pixel in this row
# Here we define "almost" on the left side as being within the left 5% of the image
return left_most_dark_pixel < width * 0.05
if left_most_dark_pixel < width * 0.05:
return 1.
else:
return 0.
def check_image_mirror(src_path, tgt_path):