-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsummarize_diff_stats.py
More file actions
executable file
·45 lines (38 loc) · 1.47 KB
/
summarize_diff_stats.py
File metadata and controls
executable file
·45 lines (38 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import re
from datetime import datetime
def parse_diff_stats(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
stats = {}
for line in lines[1:]: # Skip the first line with the date
match = re.match(r'(.+):\s+(\d+\.\d+)', line)
if match:
filename = match.group(1)
value = float(match.group(2))
stats[filename] = value
return stats
def summarize_stats(stats):
if not stats:
print("No valid statistics found.")
return
max_file = max(stats, key=stats.get)
min_file = min(stats, key=stats.get)
mean_value = sum(stats.values()) / len(stats)
above_threshold = [file for file, value in stats.items() if value > 0.03]
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(f"Summary of image differences (generated on {current_time}):")
print("")
print(f"- Total files: {len(stats)}")
print(f"- Maximum difference: {max_file} with value {stats[max_file]}")
print(f"- Minimum difference: {min_file} with value {stats[min_file]}")
print(f"- Mean difference: {mean_value}")
if above_threshold:
print("- Files above 3% threshold:")
for file in above_threshold:
print(f" - {file}: {stats[file]}")
else:
print("- No files above 3% threshold.")
if __name__ == "__main__":
diff_stats_file = "generated/image_diff_stats.txt"
stats = parse_diff_stats(diff_stats_file)
summarize_stats(stats)