47 lines
916 B
Python
47 lines
916 B
Python
|
|
from test2 import *
|
||
|
|
|
||
|
|
import numpy as np
|
||
|
|
from PIL import Image
|
||
|
|
from os import listdir as ls
|
||
|
|
|
||
|
|
a = []
|
||
|
|
|
||
|
|
for i in ls("../pics/yes"):
|
||
|
|
a.append(np.asarray(Image.open(f"../pics/yes/{i}").resize((1024,1024)).convert("RGB")))
|
||
|
|
|
||
|
|
a = np.array(a)
|
||
|
|
|
||
|
|
aug = km.Sequential([
|
||
|
|
kl.Input(shape = (1024, 1024, 3)),
|
||
|
|
kl.RandomRotation((-0.5, 0.5)),
|
||
|
|
kl.RandomSaturation((0.2, 0.6)),
|
||
|
|
kl.RandomContrast((0.6, 0.6)),
|
||
|
|
kl.Resizing(300, 300)
|
||
|
|
])
|
||
|
|
|
||
|
|
aug.compile()
|
||
|
|
aug.summary()
|
||
|
|
|
||
|
|
|
||
|
|
'''
|
||
|
|
from matplotlib import pyplot as plt
|
||
|
|
|
||
|
|
plt.figure()
|
||
|
|
f, g = plt.subplots(3, 3)
|
||
|
|
for i in range(9):
|
||
|
|
g[i//3][i%3].imshow(res[i])
|
||
|
|
|
||
|
|
plt.show()
|
||
|
|
'''
|
||
|
|
|
||
|
|
#print(res[0].numpy().shape)
|
||
|
|
|
||
|
|
#Image.fromarray(res[0].numpy().astype("uint8")).show()
|
||
|
|
|
||
|
|
for i in range(10):
|
||
|
|
print(i)
|
||
|
|
res = aug(a, batch_size = 32, training = True)
|
||
|
|
|
||
|
|
for k, img in enumerate(res):
|
||
|
|
Image.fromarray(img.numpy().astype("uint8")).save(f"../pics-exp/yes/{i:02d}-{k}.jpg")
|