-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresolve.py
46 lines (37 loc) · 1.11 KB
/
resolve.py
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
46
# third-party imports
import tensorflow as tf
from pprint import PrettyPrinter
# module imports
from evaluator import Evaluator
# Instantiate pretty printer
pp = PrettyPrinter(indent=4)
# Test data folder and name
data_folder = "./"
test_data_name = "dummy"
# Image to resolve
image = "bird.jpeg"
if __name__ == "__main__":
# Load models
resnet = tf.saved_model.load("SuperResolutionResNet_99999")
generator = tf.saved_model.load("Generator_99999")
# Create evaluator
evaluator = Evaluator(
resnet=resnet,
generator=generator,
data_folder=data_folder,
test_data_name=test_data_name,
)
# Evaluate models
evaluator.evaluate()
# Perform super resolution
evaluator.super_resolve(img=image)
# Print metrics
print("Evaluation results:")
pp.pprint(
{
"PSNR (SRResNet)": evaluator.PSNRs_resnet.result().numpy(),
"PSNR (SRGAN)": evaluator.PSNRs_gan.result().numpy(),
"SSIM (SRResNet)": evaluator.SSIMs_resnet.result().numpy(),
"SSIM (SRGAN)": evaluator.SSIMs_gan.result().numpy(),
}
)