forked from RaphaelMeudec/deblur-gan
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
35 lines (27 loc) · 1.01 KB
/
test.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
import numpy as np
from PIL import Image
import click
from model import generator_model
from utils import load_images, deprocess_image
def test(batch_size):
data = load_images('./images/test', batch_size)
y_test, x_test = data['B'], data['A']
g = generator_model()
g.load_weights('generator.h5')
generated_images = g.predict(x=x_test, batch_size=batch_size)
generated = np.array([deprocess_image(img) for img in generated_images])
x_test = deprocess_image(x_test)
y_test = deprocess_image(y_test)
for i in range(generated_images.shape[0]):
y = y_test[i, :, :, :]
x = x_test[i, :, :, :]
img = generated[i, :, :, :]
output = np.concatenate((y, x, img), axis=1)
im = Image.fromarray(output.astype(np.uint8))
im.save('results{}.png'.format(i))
@click.command()
@click.option('--batch_size', default=4, help='Number of images to process')
def test_command(batch_size):
return test(batch_size)
if __name__ == "__main__":
test_command()