-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhand_write_number_GAN.py
More file actions
38 lines (33 loc) · 1.05 KB
/
hand_write_number_GAN.py
File metadata and controls
38 lines (33 loc) · 1.05 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
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
from tensorflow.keras.datasets import mnist
from tensorflow.keras.layers import *
from tensorflow.keras.models import load_model
# model = load_model('./models/generator_mnist_5.h5')
# model.summary()
# exit()
number_GAN_models = []
for i in range(10):
try: number_GAN_models.append(load_model('./models/generator_mnist_{}.h5'.format(i)))
except: number_GAN_models.append(load_model('./models/generator_mnist_0.h5'.format(i)))
four_digit_number = '0187'
Numbers = list(four_digit_number)
print(Numbers)
imgs = []
for i in Numbers:
i = int(i)
z = np.random.normal(0, 1, (1, 100))
fake_imgs = number_GAN_models[i].predict(z)
fake_imgs = 0.5 * fake_imgs + 0.5
imgs.append(fake_imgs.reshape(28, 28))
print(fake_imgs.shape)
img = imgs[0]
for i in range(1,4):
img = np.append(img, imgs[i], axis=1)
print(img.shape)
plt.cool() # gray, cool, hot, spring, summer, autumn, winter, bone, copper, magma, pink, prism, plasma
plt.imshow(img)
plt.axis('off')
plt.show()