Spaces:
Sleeping
Sleeping
Siyun He
commited on
Commit
·
b893355
1
Parent(s):
4c89354
upload evaluate.py. This file is not for showing the app. It includes performance evaluation metrics
Browse files- evaluation.py +22 -0
evaluation.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ASCII_functions import generate_ascii_art, calculate_similarity
|
2 |
+
from PIL import Image
|
3 |
+
import argparse
|
4 |
+
|
5 |
+
if __name__ == "__main__":
|
6 |
+
parser = argparse.ArgumentParser(description="Convert an image to ASCII art and evaluate its similarity.")
|
7 |
+
parser.add_argument("image_path", type=str, help="Path to the input image file")
|
8 |
+
|
9 |
+
args = parser.parse_args()
|
10 |
+
|
11 |
+
image_path = args.image_path
|
12 |
+
|
13 |
+
original_image = Image.open(image_path)
|
14 |
+
|
15 |
+
ascii_art = generate_ascii_art(original_image)
|
16 |
+
|
17 |
+
print(ascii_art)
|
18 |
+
|
19 |
+
ssim_value, mse = calculate_similarity(original_image, ascii_art)
|
20 |
+
|
21 |
+
print(f"SSIM: {ssim_value:.4f}")
|
22 |
+
print(f"MSE: {mse:.4f}")
|