djkgfhkfdj::q!
Merge branch 'master' of github.com:Unity-Technologies/Keras-GAN
This commit is contained in:
Коммит
295aebfdbc
|
@ -179,7 +179,7 @@ class INFOGAN():
|
|||
# Select a random half batch of images
|
||||
idx = np.random.randint(0, X_train.shape[0], batch_size)
|
||||
imgs = X_train[idx]
|
||||
|
||||
|
||||
# Sample noise and categorical labels
|
||||
sampled_noise, sampled_labels = self.sample_generator_input(batch_size)
|
||||
gen_input = np.concatenate((sampled_noise, sampled_labels), axis=1)
|
||||
|
@ -220,6 +220,7 @@ class INFOGAN():
|
|||
gen_input = np.concatenate((sampled_noise, label), axis=1)
|
||||
gen_imgs = self.generator.predict(gen_input)
|
||||
self.save_samples("generated_" + str(i), gen_imgs)
|
||||
|
||||
#gen_imgs = 0.5 * gen_imgs + 0.5
|
||||
#for j in range(r):
|
||||
# formatted = (gen_imgs[j,:,:] * 255 / np.max(gen_imgs[j,:,:])).astype('uint8')
|
||||
|
|
|
@ -26,17 +26,28 @@ def encode_word_presence(words, all_words):
|
|||
array[i] = 1.0
|
||||
return array.tolist()
|
||||
|
||||
def augment(x_train, y_train, resize):
|
||||
images_to_augments = len(x_train)
|
||||
for i in range(images_to_augments):
|
||||
im = Image.fromarray(x_train[i].astype('uint8').reshape((resize,resize,3)))
|
||||
f1 = im.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
f2 = im.transpose(Image.FLIP_TOP_BOTTOM)
|
||||
x_train.append(np.asarray(f1, dtype="int32"))
|
||||
x_train.append(np.asarray(f2, dtype="int32"))
|
||||
y_train.append(y_train[i])
|
||||
y_train.append(y_train[i])
|
||||
|
||||
def semantic_maps(resize=None):
|
||||
seen_labels = list()
|
||||
x_train = np.array([load_image(f, resize) for f in glob.glob("../data/semantic_maps/train/img/*.png")])
|
||||
x_test = np.array([load_image(f, resize) for f in glob.glob("../data/semantic_maps/test/img/*.png")])
|
||||
y_train = np.array([load_labels(f, seen_labels) for f in glob.glob("../data/semantic_maps/train/txt/*.txt")])
|
||||
y_test = np.array([load_labels(f, seen_labels) for f in glob.glob("../data/semantic_maps/test/txt/*.txt")])
|
||||
|
||||
x_train = ([load_image(f, resize) for f in glob.glob("../data/semantic_maps/train/img/*.png")])
|
||||
x_test = ([load_image(f, resize) for f in glob.glob("../data/semantic_maps/test/img/*.png")])
|
||||
y_train = ([load_labels(f, seen_labels) for f in glob.glob("../data/semantic_maps/train/txt/*.txt")])
|
||||
y_test = ([load_labels(f, seen_labels) for f in glob.glob("../data/semantic_maps/test/txt/*.txt")])
|
||||
augment (x_train, y_train, resize)
|
||||
seen_labels = sorted(list(set(seen_labels)))
|
||||
y_train = np.array([encode_word_presence(a, seen_labels) for a in y_train])
|
||||
y_test = np.array([encode_word_presence(a, seen_labels) for a in y_test])
|
||||
return (x_train, y_train), (x_test, y_test)
|
||||
y_train = ([encode_word_presence(a, seen_labels) for a in y_train])
|
||||
y_test = ([encode_word_presence(a, seen_labels) for a in y_test])
|
||||
return (np.array(x_train), np.array(y_train)), (np.array(x_test), np.array(y_test))
|
||||
|
||||
def get_number_of_unique_classes():
|
||||
seen_labels = list()
|
||||
|
@ -45,4 +56,4 @@ def get_number_of_unique_classes():
|
|||
return unique_labels
|
||||
|
||||
def semantic_maps_shape():
|
||||
return 256, 3, get_number_of_unique_classes()
|
||||
return 64, 3, get_number_of_unique_classes()
|
Загрузка…
Ссылка в новой задаче