-
Notifications
You must be signed in to change notification settings - Fork 0
/
produce.py
42 lines (34 loc) · 1.6 KB
/
produce.py
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
39
40
41
42
from dataprocessing import DataProcessor
from train import MuRNN
import argparse
from os.path import join
# make songs by running this file
parser = argparse.ArgumentParser(prog="MuRNN")
parser.add_argument("model_path",
type=str,
help="The path to your trained model")
parser.add_argument("-song_length",
type=int,
default=200,
help="The song length (aka: number of predictions for notes the model does)")
parser.add_argument("-target_dir",
type=str,
default=None,
help="Specify the target directory for the midi-files,\ndefaults to *path to your model*/songs/")
parser.add_argument("-weights_filename",
type=str,
default="weights.hdf5",
help="Specify the weights-file to load for your model,\ndefaults to 'weights.hdf5'")
parser.add_argument("-amount",
type=int,
default=1,
help="Specify how many songs to produce")
parser.add_argument("-alpha",
type=float,
default=0,
help="Specify how creative the network can get (0: not creative, 1: very creative)")
args = parser.parse_args()
model = MuRNN()
model.load_model(args.model_path, weights_filename=args.weights_filename)
for _ in range(args.amount):
DataProcessor.retrieve_midi_from_loaded_data(model.make_song(args.alpha, args.song_length), target_dir=args.target_dir if args.target_dir != None else join(args.model_path, "songs/"))