Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ def prepare_sequences(notes, pitchnames, n_vocab , seq_length):
|
|
45 |
n_patterns = len(network_input)
|
46 |
|
47 |
# reshape the input into a format compatible with LSTM layers
|
48 |
-
normalized_input =
|
49 |
# normalize input
|
50 |
normalized_input = normalized_input / float(n_vocab)
|
51 |
|
@@ -84,7 +84,7 @@ def create_network(network_input, n_vocab):
|
|
84 |
def generate_notes(model, network_input, pitchnames, n_vocab , x):
|
85 |
""" Generate notes from the neural network based on a sequence of notes """
|
86 |
# pick a random sequence from the input as a starting point for the prediction
|
87 |
-
start =
|
88 |
|
89 |
int_to_note = dict((number, note) for number, note in enumerate(pitchnames))
|
90 |
|
@@ -93,12 +93,12 @@ def generate_notes(model, network_input, pitchnames, n_vocab , x):
|
|
93 |
|
94 |
# generate x notes (x entered by user)
|
95 |
for note_index in range(x):
|
96 |
-
prediction_input =
|
97 |
prediction_input = prediction_input / float(n_vocab)
|
98 |
|
99 |
prediction = model.predict(prediction_input, verbose=0)
|
100 |
|
101 |
-
index =
|
102 |
result = int_to_note[index]
|
103 |
prediction_output.append(result)
|
104 |
|
|
|
45 |
n_patterns = len(network_input)
|
46 |
|
47 |
# reshape the input into a format compatible with LSTM layers
|
48 |
+
normalized_input = np.reshape(network_input, (n_patterns, sequence_length, 1))
|
49 |
# normalize input
|
50 |
normalized_input = normalized_input / float(n_vocab)
|
51 |
|
|
|
84 |
def generate_notes(model, network_input, pitchnames, n_vocab , x):
|
85 |
""" Generate notes from the neural network based on a sequence of notes """
|
86 |
# pick a random sequence from the input as a starting point for the prediction
|
87 |
+
start = np.random.randint(0, len(network_input)-1)
|
88 |
|
89 |
int_to_note = dict((number, note) for number, note in enumerate(pitchnames))
|
90 |
|
|
|
93 |
|
94 |
# generate x notes (x entered by user)
|
95 |
for note_index in range(x):
|
96 |
+
prediction_input = np.reshape(pattern, (1, len(pattern), 1))
|
97 |
prediction_input = prediction_input / float(n_vocab)
|
98 |
|
99 |
prediction = model.predict(prediction_input, verbose=0)
|
100 |
|
101 |
+
index = np.argmax(prediction)
|
102 |
result = int_to_note[index]
|
103 |
prediction_output.append(result)
|
104 |
|