praca-magisterska/generate.py

23 lines
733 B
Python
Raw Normal View History

2019-05-08 08:03:52 +02:00
import numpy as np
from keras.layers import Input, Dense, Conv2D
from keras.models import Model
GENERATED_BEAT_PATH = 'data/output/generated_bar'
MODEL_PATH = 'data/autoencoder_model.h5'
SAMPLES_PATH = 'data/samples.npz'
input = Input(shape=(1,96,128))
encoded = Conv2D(filters = 32, kernel_size = 1)(input)
decoded = Conv2D(filters = 128, kernel_size = 1)(encoded)
autoencoder = Model(input, decoded)
# load weights into new model
autoencoder.load_weights(MODEL_PATH)
print("Loaded model from disk")
# generate_seed = np.random.rand(1,1,96,128)
generate_seed = np.load(SAMPLES_PATH)['arr_0'][0:]
generated_beat = autoencoder.predict(generate_seed)
np.savez_compressed(GENERATED_BEAT_PATH, generated_beat)