40 lines
885 B
Python
40 lines
885 B
Python
"""
|
|
|
|
"""
|
|
|
|
from time import time as now
|
|
import torch
|
|
|
|
|
|
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
|
|
def compute_all(ref_path, dist_path):
|
|
"""
|
|
Computes the distribution between a reference and distorted image folders.
|
|
"""
|
|
|
|
|
|
output = {}
|
|
|
|
metrics = []
|
|
|
|
for name, func in metrics:
|
|
start_time = now()
|
|
output[name] = (func(), now() - start_time)
|
|
|
|
return output
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# Paths to reference and distorted images
|
|
REF_IMG_PATH = "test_reference/001.jpg"
|
|
DIST_IMG_PATH = "test_distorted/001_CodeFace_1.4.jpg"
|
|
|
|
# Compute all metrics
|
|
results = compute_all(REF_IMG_PATH, DIST_IMG_PATH)
|
|
|
|
# Print results for each metric and the time taken to compute it
|
|
for metric, (value, duration) in results.items():
|
|
print(f"{metric}: {value:.8g} (computed in {duration:.6f} seconds)")
|