Merge main
This commit is contained in:
@@ -1,6 +1,23 @@
|
||||
import os
|
||||
from PIL import Image, ImageStat, ImageChops
|
||||
from typing import List, Union
|
||||
from skimage.metrics import structural_similarity as ssim
|
||||
from PIL import Image, ImageChops, ImageStat
|
||||
|
||||
|
||||
def compare_images(pred_img_path_list: Union[str, List[str]],
|
||||
gold_img_path_list: Union[str, List[str]]) -> float:
|
||||
""" Compare two image lists, only if all images are the same, return 1.0, otherwise return 0.0
|
||||
"""
|
||||
if type(pred_img_path_list) != list:
|
||||
pred_img_path_list = [pred_img_path_list]
|
||||
gold_img_path_list = [gold_img_path_list]
|
||||
for pred_img_path, gold_img_path in zip(pred_img_path_list, gold_img_path_list):
|
||||
pred_img = Image.open(pred_img_path)
|
||||
gold_img = Image.open(gold_img_path)
|
||||
diff = ImageChops.difference(pred_img, gold_img)
|
||||
if diff.getbbox():
|
||||
return 0.0
|
||||
return 1.0
|
||||
|
||||
|
||||
def get_gimp_export_path():
|
||||
|
||||
Reference in New Issue
Block a user