diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 8b13789..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ - diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..f8b4888 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..172a049 Binary files /dev/null and b/.vs/slnx.sqlite differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..c1ec002 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# tfworldhackathon +GitHub repo for the Tensorflow World hackathon diff --git a/logs/train/events.out.tfevents.1577835437.DESKTOP-QGK95I8.7468.930.v2 b/logs/train/events.out.tfevents.1577835437.DESKTOP-QGK95I8.7468.930.v2 new file mode 100644 index 0000000..86c1848 Binary files /dev/null and b/logs/train/events.out.tfevents.1577835437.DESKTOP-QGK95I8.7468.930.v2 differ diff --git a/models/128.h5 b/models/128.h5 new file mode 100644 index 0000000..963cad2 Binary files /dev/null and b/models/128.h5 differ diff --git a/models/js/group1-shard10of19.bin b/models/js/group1-shard10of19.bin new file mode 100644 index 0000000..f66ea8e Binary files /dev/null and b/models/js/group1-shard10of19.bin differ diff --git a/models/js/group1-shard11of19.bin b/models/js/group1-shard11of19.bin new file mode 100644 index 0000000..58ef36a Binary files /dev/null and b/models/js/group1-shard11of19.bin differ diff --git a/models/js/group1-shard12of19.bin b/models/js/group1-shard12of19.bin new file mode 100644 index 0000000..3ab5065 Binary files /dev/null and b/models/js/group1-shard12of19.bin differ diff --git a/models/js/group1-shard13of19.bin b/models/js/group1-shard13of19.bin new file mode 100644 index 0000000..5ba07de Binary files /dev/null and b/models/js/group1-shard13of19.bin differ diff --git a/models/js/group1-shard14of19.bin b/models/js/group1-shard14of19.bin new file mode 100644 index 0000000..a903aff Binary files /dev/null and b/models/js/group1-shard14of19.bin differ diff --git a/models/js/group1-shard15of19.bin b/models/js/group1-shard15of19.bin new file mode 100644 index 0000000..8ef1f59 Binary files /dev/null and b/models/js/group1-shard15of19.bin differ diff --git a/models/js/group1-shard16of19.bin b/models/js/group1-shard16of19.bin new file mode 100644 index 0000000..86fa247 Binary files /dev/null and b/models/js/group1-shard16of19.bin differ diff --git a/models/js/group1-shard17of19.bin b/models/js/group1-shard17of19.bin new file mode 100644 index 0000000..e6cd21b Binary files /dev/null and b/models/js/group1-shard17of19.bin differ diff --git a/models/js/group1-shard18of19.bin b/models/js/group1-shard18of19.bin new file mode 100644 index 0000000..72da0e8 Binary files /dev/null and b/models/js/group1-shard18of19.bin differ diff --git a/models/js/group1-shard19of19.bin b/models/js/group1-shard19of19.bin new file mode 100644 index 0000000..c74e2e4 Binary files /dev/null and b/models/js/group1-shard19of19.bin differ diff --git a/models/js/group1-shard1of19.bin b/models/js/group1-shard1of19.bin new file mode 100644 index 0000000..286cf47 Binary files /dev/null and b/models/js/group1-shard1of19.bin differ diff --git a/models/js/group1-shard2of19.bin b/models/js/group1-shard2of19.bin new file mode 100644 index 0000000..f7c1a5c Binary files /dev/null and b/models/js/group1-shard2of19.bin differ diff --git a/models/js/group1-shard3of19.bin b/models/js/group1-shard3of19.bin new file mode 100644 index 0000000..23f7d34 Binary files /dev/null and b/models/js/group1-shard3of19.bin differ diff --git a/models/js/group1-shard4of19.bin b/models/js/group1-shard4of19.bin new file mode 100644 index 0000000..78a3eb4 Binary files /dev/null and b/models/js/group1-shard4of19.bin differ diff --git a/models/js/group1-shard5of19.bin b/models/js/group1-shard5of19.bin new file mode 100644 index 0000000..c5dcdfc Binary files /dev/null and b/models/js/group1-shard5of19.bin differ diff --git a/models/js/group1-shard6of19.bin b/models/js/group1-shard6of19.bin new file mode 100644 index 0000000..3a14ec9 Binary files /dev/null and b/models/js/group1-shard6of19.bin differ diff --git a/models/js/group1-shard7of19.bin b/models/js/group1-shard7of19.bin new file mode 100644 index 0000000..a972423 Binary files /dev/null and b/models/js/group1-shard7of19.bin differ diff --git a/models/js/group1-shard8of19.bin b/models/js/group1-shard8of19.bin new file mode 100644 index 0000000..25ffdf8 Binary files /dev/null and b/models/js/group1-shard8of19.bin differ diff --git a/models/js/group1-shard9of19.bin b/models/js/group1-shard9of19.bin new file mode 100644 index 0000000..8612020 Binary files /dev/null and b/models/js/group1-shard9of19.bin differ diff --git a/models/js/model.json b/models/js/model.json new file mode 100644 index 0000000..4035c06 --- /dev/null +++ b/models/js/model.json @@ -0,0 +1 @@ +{"format": "layers-model", "generatedBy": "keras v2.2.4-tf", "convertedBy": "TensorFlow.js Converter v1.4.0", "modelTopology": {"keras_version": "2.2.4-tf", "backend": "tensorflow", "model_config": {"class_name": "Model", "config": {"name": "model", "layers": [{"class_name": "InputLayer", "config": {"batch_input_shape": [null, 100], "dtype": "float32", "sparse": false, "name": "input_1"}, "name": "input_1", "inbound_nodes": []}, {"class_name": "Dense", "config": {"name": "dense", "trainable": true, "dtype": "float32", "units": 16384, "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null}, "name": "dense", "inbound_nodes": [[["input_1", 0, 0, {}]]]}, {"class_name": "Reshape", "config": {"name": "reshape", "trainable": true, "dtype": "float32", "target_shape": [16, 1024]}, "name": "reshape", "inbound_nodes": [[["dense", 0, 0, {}]]]}, {"class_name": "ReLU", "config": {"name": "re_lu", "trainable": true, "dtype": "float32", "max_value": null, "negative_slope": 0.0, "threshold": 0.0}, "name": "re_lu", "inbound_nodes": [[["reshape", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAQAAABTAAAAcw4AAAB0AGoBfABkAWQCjQJTACkDTukBAAAAKQHaBGF4aXMp\nAtoBS9oLZXhwYW5kX2RpbXMpAdoBeKkAcgYAAAD6QUM6L1VzZXJzL0hhcnJ5L3NvdXJjZS9yZXBv\ncy90ZndvcmxkaGFja2F0aG9uL3NjcmlwdHMvR0FOTW9kZWxzLnB52gg8bGFtYmRhPhAAAADzAAAA\nAA==\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda", "inbound_nodes": [[["re_lu", 0, 0, {}]]]}, {"class_name": "Conv2DTranspose", "config": {"name": "conv2d_transpose", "trainable": true, "dtype": "float32", "filters": 512, "kernel_size": [1, 25], "strides": [1, 4], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "output_padding": null}, "name": "conv2d_transpose", "inbound_nodes": [[["lambda", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_1", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAMAAABTAAAAcxAAAAB8AGQAZACFAmQBZgIZAFMAKQJO6QAAAACpACkB2gF4\ncgIAAAByAgAAAPpBQzovVXNlcnMvSGFycnkvc291cmNlL3JlcG9zL3Rmd29ybGRoYWNrYXRob24v\nc2NyaXB0cy9HQU5Nb2RlbHMucHnaCDxsYW1iZGE+EgAAAPMAAAAA\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_1", "inbound_nodes": [[["conv2d_transpose", 0, 0, {}]]]}, {"class_name": "ReLU", "config": {"name": "re_lu_1", "trainable": true, "dtype": "float32", "max_value": null, "negative_slope": 0.0, "threshold": 0.0}, "name": "re_lu_1", "inbound_nodes": [[["lambda_1", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_2", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAQAAABTAAAAcw4AAAB0AGoBfABkAWQCjQJTACkDTukBAAAAKQHaBGF4aXMp\nAtoBS9oLZXhwYW5kX2RpbXMpAdoBeKkAcgYAAAD6QUM6L1VzZXJzL0hhcnJ5L3NvdXJjZS9yZXBv\ncy90ZndvcmxkaGFja2F0aG9uL3NjcmlwdHMvR0FOTW9kZWxzLnB52gg8bGFtYmRhPhYAAADzAAAA\nAA==\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_2", "inbound_nodes": [[["re_lu_1", 0, 0, {}]]]}, {"class_name": "Conv2DTranspose", "config": {"name": "conv2d_transpose_1", "trainable": true, "dtype": "float32", "filters": 256, "kernel_size": [1, 25], "strides": [1, 4], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "output_padding": null}, "name": "conv2d_transpose_1", "inbound_nodes": [[["lambda_2", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_3", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAMAAABTAAAAcxAAAAB8AGQAZACFAmQBZgIZAFMAKQJO6QAAAACpACkB2gF4\ncgIAAAByAgAAAPpBQzovVXNlcnMvSGFycnkvc291cmNlL3JlcG9zL3Rmd29ybGRoYWNrYXRob24v\nc2NyaXB0cy9HQU5Nb2RlbHMucHnaCDxsYW1iZGE+GAAAAPMAAAAA\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_3", "inbound_nodes": [[["conv2d_transpose_1", 0, 0, {}]]]}, {"class_name": "ReLU", "config": {"name": "re_lu_2", "trainable": true, "dtype": "float32", "max_value": null, "negative_slope": 0.0, "threshold": 0.0}, "name": "re_lu_2", "inbound_nodes": [[["lambda_3", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_4", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAQAAABTAAAAcw4AAAB0AGoBfABkAWQCjQJTACkDTukBAAAAKQHaBGF4aXMp\nAtoBS9oLZXhwYW5kX2RpbXMpAdoBeKkAcgYAAAD6QUM6L1VzZXJzL0hhcnJ5L3NvdXJjZS9yZXBv\ncy90ZndvcmxkaGFja2F0aG9uL3NjcmlwdHMvR0FOTW9kZWxzLnB52gg8bGFtYmRhPhwAAADzAAAA\nAA==\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_4", "inbound_nodes": [[["re_lu_2", 0, 0, {}]]]}, {"class_name": "Conv2DTranspose", "config": {"name": "conv2d_transpose_2", "trainable": true, "dtype": "float32", "filters": 128, "kernel_size": [1, 25], "strides": [1, 4], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "output_padding": null}, "name": "conv2d_transpose_2", "inbound_nodes": [[["lambda_4", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_5", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAMAAABTAAAAcxAAAAB8AGQAZACFAmQBZgIZAFMAKQJO6QAAAACpACkB2gF4\ncgIAAAByAgAAAPpBQzovVXNlcnMvSGFycnkvc291cmNlL3JlcG9zL3Rmd29ybGRoYWNrYXRob24v\nc2NyaXB0cy9HQU5Nb2RlbHMucHnaCDxsYW1iZGE+HgAAAPMAAAAA\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_5", "inbound_nodes": [[["conv2d_transpose_2", 0, 0, {}]]]}, {"class_name": "ReLU", "config": {"name": "re_lu_3", "trainable": true, "dtype": "float32", "max_value": null, "negative_slope": 0.0, "threshold": 0.0}, "name": "re_lu_3", "inbound_nodes": [[["lambda_5", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_6", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAQAAABTAAAAcw4AAAB0AGoBfABkAWQCjQJTACkDTukBAAAAKQHaBGF4aXMp\nAtoBS9oLZXhwYW5kX2RpbXMpAdoBeKkAcgYAAAD6QUM6L1VzZXJzL0hhcnJ5L3NvdXJjZS9yZXBv\ncy90ZndvcmxkaGFja2F0aG9uL3NjcmlwdHMvR0FOTW9kZWxzLnB52gg8bGFtYmRhPiIAAADzAAAA\nAA==\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_6", "inbound_nodes": [[["re_lu_3", 0, 0, {}]]]}, {"class_name": "Conv2DTranspose", "config": {"name": "conv2d_transpose_3", "trainable": true, "dtype": "float32", "filters": 64, "kernel_size": [1, 25], "strides": [1, 4], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "output_padding": null}, "name": "conv2d_transpose_3", "inbound_nodes": [[["lambda_6", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_7", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAMAAABTAAAAcxAAAAB8AGQAZACFAmQBZgIZAFMAKQJO6QAAAACpACkB2gF4\ncgIAAAByAgAAAPpBQzovVXNlcnMvSGFycnkvc291cmNlL3JlcG9zL3Rmd29ybGRoYWNrYXRob24v\nc2NyaXB0cy9HQU5Nb2RlbHMucHnaCDxsYW1iZGE+JAAAAPMAAAAA\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_7", "inbound_nodes": [[["conv2d_transpose_3", 0, 0, {}]]]}, {"class_name": "ReLU", "config": {"name": "re_lu_4", "trainable": true, "dtype": "float32", "max_value": null, "negative_slope": 0.0, "threshold": 0.0}, "name": "re_lu_4", "inbound_nodes": [[["lambda_7", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_8", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAQAAABTAAAAcw4AAAB0AGoBfABkAWQCjQJTACkDTukBAAAAKQHaBGF4aXMp\nAtoBS9oLZXhwYW5kX2RpbXMpAdoBeKkAcgYAAAD6QUM6L1VzZXJzL0hhcnJ5L3NvdXJjZS9yZXBv\ncy90ZndvcmxkaGFja2F0aG9uL3NjcmlwdHMvR0FOTW9kZWxzLnB52gg8bGFtYmRhPicAAADzAAAA\nAA==\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_8", "inbound_nodes": [[["re_lu_4", 0, 0, {}]]]}, {"class_name": "Conv2DTranspose", "config": {"name": "conv2d_transpose_4", "trainable": true, "dtype": "float32", "filters": 1, "kernel_size": [1, 25], "strides": [1, 4], "padding": "same", "data_format": "channels_last", "dilation_rate": [1, 1], "activation": "linear", "use_bias": true, "kernel_initializer": {"class_name": "GlorotUniform", "config": {"seed": null}}, "bias_initializer": {"class_name": "Zeros", "config": {}}, "kernel_regularizer": null, "bias_regularizer": null, "activity_regularizer": null, "kernel_constraint": null, "bias_constraint": null, "output_padding": null}, "name": "conv2d_transpose_4", "inbound_nodes": [[["lambda_8", 0, 0, {}]]]}, {"class_name": "Lambda", "config": {"name": "lambda_9", "trainable": true, "dtype": "float32", "function": ["4wEAAAAAAAAAAQAAAAMAAABTAAAAcxAAAAB8AGQAZACFAmQBZgIZAFMAKQJO6QAAAACpACkB2gF4\ncgIAAAByAgAAAPpBQzovVXNlcnMvSGFycnkvc291cmNlL3JlcG9zL3Rmd29ybGRoYWNrYXRob24v\nc2NyaXB0cy9HQU5Nb2RlbHMucHnaCDxsYW1iZGE+KQAAAPMAAAAA\n", null, null], "function_type": "lambda", "module": "GANModels", "output_shape": null, "output_shape_type": "raw", "output_shape_module": null, "arguments": {}}, "name": "lambda_9", "inbound_nodes": [[["conv2d_transpose_4", 0, 0, {}]]]}, {"class_name": "Activation", "config": {"name": "activation", "trainable": true, "dtype": "float32", "activation": "tanh"}, "name": "activation", "inbound_nodes": [[["lambda_9", 0, 0, {}]]]}], "input_layers": [["input_1", 0, 0]], "output_layers": [["activation", 0, 0]]}}}, "weightsManifest": [{"paths": ["group1-shard1of19.bin", "group1-shard2of19.bin", "group1-shard3of19.bin", "group1-shard4of19.bin", "group1-shard5of19.bin", "group1-shard6of19.bin", "group1-shard7of19.bin", "group1-shard8of19.bin", "group1-shard9of19.bin", "group1-shard10of19.bin", "group1-shard11of19.bin", "group1-shard12of19.bin", "group1-shard13of19.bin", "group1-shard14of19.bin", "group1-shard15of19.bin", "group1-shard16of19.bin", "group1-shard17of19.bin", "group1-shard18of19.bin", "group1-shard19of19.bin"], "weights": [{"name": "conv2d_transpose/kernel", "shape": [1, 25, 512, 1024], "dtype": "float32"}, {"name": "conv2d_transpose/bias", "shape": [512], "dtype": "float32"}, {"name": "conv2d_transpose_1/kernel", "shape": [1, 25, 256, 512], "dtype": "float32"}, {"name": "conv2d_transpose_1/bias", "shape": [256], "dtype": "float32"}, {"name": "conv2d_transpose_2/kernel", "shape": [1, 25, 128, 256], "dtype": "float32"}, {"name": "conv2d_transpose_2/bias", "shape": [128], "dtype": "float32"}, {"name": "conv2d_transpose_3/kernel", "shape": [1, 25, 64, 128], "dtype": "float32"}, {"name": "conv2d_transpose_3/bias", "shape": [64], "dtype": "float32"}, {"name": "conv2d_transpose_4/kernel", "shape": [1, 25, 1, 64], "dtype": "float32"}, {"name": "conv2d_transpose_4/bias", "shape": [1], "dtype": "float32"}, {"name": "dense/kernel", "shape": [100, 16384], "dtype": "float32"}, {"name": "dense/bias", "shape": [16384], "dtype": "float32"}]}]} \ No newline at end of file diff --git a/output/piano/0-0.wav b/output/piano/0-0.wav new file mode 100644 index 0000000..22a503a Binary files /dev/null and b/output/piano/0-0.wav differ diff --git a/output/piano/100-0.wav b/output/piano/100-0.wav new file mode 100644 index 0000000..239cda6 Binary files /dev/null and b/output/piano/100-0.wav differ diff --git a/output/piano/104-0.wav b/output/piano/104-0.wav new file mode 100644 index 0000000..8ce7448 Binary files /dev/null and b/output/piano/104-0.wav differ diff --git a/output/piano/108-0.wav b/output/piano/108-0.wav new file mode 100644 index 0000000..8a00c0c Binary files /dev/null and b/output/piano/108-0.wav differ diff --git a/output/piano/112-0.wav b/output/piano/112-0.wav new file mode 100644 index 0000000..9eb873c Binary files /dev/null and b/output/piano/112-0.wav differ diff --git a/output/piano/12-0.wav b/output/piano/12-0.wav new file mode 100644 index 0000000..40959de Binary files /dev/null and b/output/piano/12-0.wav differ diff --git a/output/piano/16-0.wav b/output/piano/16-0.wav new file mode 100644 index 0000000..a9c1808 Binary files /dev/null and b/output/piano/16-0.wav differ diff --git a/output/piano/20-0.wav b/output/piano/20-0.wav new file mode 100644 index 0000000..c91f824 Binary files /dev/null and b/output/piano/20-0.wav differ diff --git a/output/piano/24-0.wav b/output/piano/24-0.wav new file mode 100644 index 0000000..ea0b71b Binary files /dev/null and b/output/piano/24-0.wav differ diff --git a/output/piano/28-0.wav b/output/piano/28-0.wav new file mode 100644 index 0000000..adc43e8 Binary files /dev/null and b/output/piano/28-0.wav differ diff --git a/output/piano/32-0.wav b/output/piano/32-0.wav new file mode 100644 index 0000000..a6f379e Binary files /dev/null and b/output/piano/32-0.wav differ diff --git a/output/piano/36-0.wav b/output/piano/36-0.wav new file mode 100644 index 0000000..4eb63d3 Binary files /dev/null and b/output/piano/36-0.wav differ diff --git a/output/piano/4-0.wav b/output/piano/4-0.wav new file mode 100644 index 0000000..43f388a Binary files /dev/null and b/output/piano/4-0.wav differ diff --git a/output/piano/40-0.wav b/output/piano/40-0.wav new file mode 100644 index 0000000..5cb49b8 Binary files /dev/null and b/output/piano/40-0.wav differ diff --git a/output/piano/44-0.wav b/output/piano/44-0.wav new file mode 100644 index 0000000..9addaa7 Binary files /dev/null and b/output/piano/44-0.wav differ diff --git a/output/piano/48-0.wav b/output/piano/48-0.wav new file mode 100644 index 0000000..370f6be Binary files /dev/null and b/output/piano/48-0.wav differ diff --git a/output/piano/52-0.wav b/output/piano/52-0.wav new file mode 100644 index 0000000..027303f Binary files /dev/null and b/output/piano/52-0.wav differ diff --git a/output/piano/56-0.wav b/output/piano/56-0.wav new file mode 100644 index 0000000..92cd9d5 Binary files /dev/null and b/output/piano/56-0.wav differ diff --git a/output/piano/60-0.wav b/output/piano/60-0.wav new file mode 100644 index 0000000..ee444c6 Binary files /dev/null and b/output/piano/60-0.wav differ diff --git a/output/piano/64-0.wav b/output/piano/64-0.wav new file mode 100644 index 0000000..c65a787 Binary files /dev/null and b/output/piano/64-0.wav differ diff --git a/output/piano/68-0.wav b/output/piano/68-0.wav new file mode 100644 index 0000000..e7fd859 Binary files /dev/null and b/output/piano/68-0.wav differ diff --git a/output/piano/72-0.wav b/output/piano/72-0.wav new file mode 100644 index 0000000..25448a1 Binary files /dev/null and b/output/piano/72-0.wav differ diff --git a/output/piano/76-0.wav b/output/piano/76-0.wav new file mode 100644 index 0000000..c2da6c5 Binary files /dev/null and b/output/piano/76-0.wav differ diff --git a/output/piano/8-0.wav b/output/piano/8-0.wav new file mode 100644 index 0000000..d6d2a16 Binary files /dev/null and b/output/piano/8-0.wav differ diff --git a/output/piano/80-0.wav b/output/piano/80-0.wav new file mode 100644 index 0000000..6be383d Binary files /dev/null and b/output/piano/80-0.wav differ diff --git a/output/piano/84-0.wav b/output/piano/84-0.wav new file mode 100644 index 0000000..ebe1111 Binary files /dev/null and b/output/piano/84-0.wav differ diff --git a/output/piano/88-0.wav b/output/piano/88-0.wav new file mode 100644 index 0000000..b970603 Binary files /dev/null and b/output/piano/88-0.wav differ diff --git a/output/piano/92-0.wav b/output/piano/92-0.wav new file mode 100644 index 0000000..fd00841 Binary files /dev/null and b/output/piano/92-0.wav differ diff --git a/output/piano/96-0.wav b/output/piano/96-0.wav new file mode 100644 index 0000000..985a63e Binary files /dev/null and b/output/piano/96-0.wav differ diff --git a/output/piano/real-0.wav b/output/piano/real-0.wav new file mode 100644 index 0000000..cf48359 Binary files /dev/null and b/output/piano/real-0.wav differ diff --git a/output/piano/real-1.wav b/output/piano/real-1.wav new file mode 100644 index 0000000..dad0054 Binary files /dev/null and b/output/piano/real-1.wav differ diff --git a/output/piano/real-2.wav b/output/piano/real-2.wav new file mode 100644 index 0000000..c887c7f Binary files /dev/null and b/output/piano/real-2.wav differ diff --git a/output/piano/real-3.wav b/output/piano/real-3.wav new file mode 100644 index 0000000..ce99b7c Binary files /dev/null and b/output/piano/real-3.wav differ diff --git a/output/piano/real-4.wav b/output/piano/real-4.wav new file mode 100644 index 0000000..59f2126 Binary files /dev/null and b/output/piano/real-4.wav differ diff --git a/output/piano/real-5.wav b/output/piano/real-5.wav new file mode 100644 index 0000000..194bafc Binary files /dev/null and b/output/piano/real-5.wav differ diff --git a/output/piano/real-6.wav b/output/piano/real-6.wav new file mode 100644 index 0000000..9a98e54 Binary files /dev/null and b/output/piano/real-6.wav differ diff --git a/output/piano/real-7.wav b/output/piano/real-7.wav new file mode 100644 index 0000000..a80cd7d Binary files /dev/null and b/output/piano/real-7.wav differ diff --git a/output/piano/real-8.wav b/output/piano/real-8.wav new file mode 100644 index 0000000..683de58 Binary files /dev/null and b/output/piano/real-8.wav differ diff --git a/output/piano/real-9.wav b/output/piano/real-9.wav new file mode 100644 index 0000000..3ace800 Binary files /dev/null and b/output/piano/real-9.wav differ diff --git a/scripts/GANModels.py b/scripts/GANModels.py new file mode 100644 index 0000000..b4cc44c --- /dev/null +++ b/scripts/GANModels.py @@ -0,0 +1,124 @@ +# Import modules +import tensorflow as tf +from tensorflow.keras.models import Model +from tensorflow.keras.layers import Lambda, Dense, LSTM, Activation, Input, Bidirectional, Dropout +from tensorflow.keras.layers import Reshape, Conv2DTranspose, TimeDistributed, Conv1D, LeakyReLU, Layer, ReLU +from tensorflow.keras.optimizers import Adam +import tensorflow.keras.backend as K + +def Generator(d, num_samples, c=16): + + input_layer = Input(shape=(100,)) + + # output shape = (None, 16, 16d) + dense_layer0 = Dense(16*c*d)(input_layer) + reshape_layer0 = Reshape((c, c*d))(dense_layer0) + relu_layer0 = ReLU()(reshape_layer0) + + # Upsampling + # output shape = (None, 64, 8d) + c //= 2 + expanded_layer0 = Lambda(lambda x: K.expand_dims(x, axis=1))(relu_layer0) + conv1d_t_layer0 = Conv2DTranspose(c*d, (1, 25), strides=(1, 4), padding='same')(expanded_layer0) + slice_layer0 = Lambda(lambda x: x[:, 0])(conv1d_t_layer0) + relu_layer1 = ReLU()(slice_layer0) + + # output shape = (None, 256, 4d) + c //= 2 + expanded_layer1 = Lambda(lambda x: K.expand_dims(x, axis=1))(relu_layer1) + conv1d_t_layer1 = Conv2DTranspose(c*d, (1, 25), strides=(1, 4), padding='same')(expanded_layer1) + slice_layer1 = Lambda(lambda x: x[:, 0])(conv1d_t_layer1) + relu_layer2 = ReLU()(slice_layer1) + + # output shape = (None, 1024, 2d) + c //= 2 + expanded_layer2 = Lambda(lambda x: K.expand_dims(x, axis=1))(relu_layer2) + conv1d_t_layer2 = Conv2DTranspose(c*d, (1, 25), strides=(1, 4), padding='same')(expanded_layer2) + slice_layer2 = Lambda(lambda x: x[:, 0])(conv1d_t_layer2) + relu_layer3 = ReLU()(slice_layer2) + + # output shape = (None, 4096, d) + c //= 2 + expanded_layer3 = Lambda(lambda x: K.expand_dims(x, axis=1))(relu_layer3) + conv1d_t_layer3 = Conv2DTranspose(c*d, (1, 25), strides=(1, 4), padding='same')(expanded_layer3) + slice_layer3 = Lambda(lambda x: x[:, 0])(conv1d_t_layer3) + relu_layer4 = ReLU()(slice_layer3) + + # output shape = (None, 16384, 1) + expanded_layer4 = Lambda(lambda x: K.expand_dims(x, axis=1))(relu_layer4) + conv1d_t_layer4 = Conv2DTranspose(1, (1, 25), strides=(1, 4), padding='same')(expanded_layer4) + slice_layer4 = Lambda(lambda x: x[:, 0])(conv1d_t_layer4) + + #### The number of transposed convolution operations should be modified + #### in accordance with num_samples. This current architecture expects + #### num_samples == 16384 + + # Squeeze values between (-1, 1) + tanh_layer0 = Activation('tanh')(slice_layer4) + + model = Model(inputs=input_layer, outputs=tanh_layer0) + + return model + +# Makes critic invariant to upsampling artifacts of generator to avoid the critic learning to +# easily identify generated audio from said artifacts +def _apply_phaseshuffle(x, rad=2, pad_type='reflect'): + b, x_len, nch = x.get_shape().as_list() + + phase = tf.random.uniform([], minval=-rad, maxval=rad + 1, dtype=tf.int32) + pad_l = tf.maximum(phase, 0) + pad_r = tf.maximum(-phase, 0) + phase_start = pad_r + x = tf.pad(x, [[0, 0], [pad_l, pad_r], [0, 0]], mode=pad_type) + + x = x[:, phase_start:phase_start+x_len] + x.set_shape([b, x_len, nch]) + + return x + +def Critic(d, num_samples, c=1): + + input_layer = Input(shape=(num_samples, 1)) + + # Downsampling + # output shape = (None, 4096, d) + conv1d_layer0 = Conv1D(c*d, 25, strides=4, padding='same')(input_layer) + LReLU_layer0 = LeakyReLU(alpha=0.2)(conv1d_layer0) + phaseshuffle_layer0 = Lambda(lambda x: _apply_phaseshuffle(x))(LReLU_layer0) + + # output shape = (None, 1024, 2d) + c *= 2 + conv1d_layer1 = Conv1D(c*d, 25, strides=4, padding='same')(phaseshuffle_layer0) + LReLU_layer1 = LeakyReLU(alpha=0.2)(conv1d_layer1) + phaseshuffle_layer1 = Lambda(lambda x: _apply_phaseshuffle(x))(LReLU_layer1) + + # output shape = (None, 256, 4d) + c *= 2 + conv1d_layer2 = Conv1D(c*d, 25, strides=4, padding='same')(phaseshuffle_layer1) + LReLU_layer2 = LeakyReLU(alpha=0.2)(conv1d_layer2) + phaseshuffle_layer2 = Lambda(lambda x: _apply_phaseshuffle(x))(LReLU_layer2) + + # output shape = (None, 64, 8d) + c *= 2 + conv1d_layer3 = Conv1D(c*d, 25, strides=4, padding='same')(phaseshuffle_layer2) + LReLU_layer3 = LeakyReLU(alpha=0.2)(conv1d_layer3) + phaseshuffle_layer3 = Lambda(lambda x: _apply_phaseshuffle(x))(LReLU_layer3) + + # output shape = (None, 16, 16d) + c *= 2 + conv1d_layer4 = Conv1D(c*d, 25, strides=4, padding='same')(phaseshuffle_layer3) + LReLU_layer4 = LeakyReLU(alpha=0.2)(conv1d_layer4) + + #### The number of convolution operations should be modified + #### in accordance with num_samples. This current architecture expects + #### num_samples == 16384 + + # output shape = (None, 256d) + reshape_layer0 = Reshape((16*c*d,))(LReLU_layer4)# + + # Output a critic score + dense_layer1 = Dense(1)(reshape_layer0) + + model = Model(inputs=input_layer, outputs=dense_layer1) + + return model \ No newline at end of file diff --git a/scripts/WGAN-GP.py b/scripts/WGAN-GP.py new file mode 100644 index 0000000..e88cdde --- /dev/null +++ b/scripts/WGAN-GP.py @@ -0,0 +1,189 @@ +# Import modules + +import tensorflow as tf +from tensorflow.keras.optimizers import Adam, RMSprop +import numpy as np +import librosa +import random +import os +import sys +import time + +import GANModels + +# Setup GPU settings +gpus = tf.config.experimental.list_physical_devices('GPU') +tf.config.experimental.set_memory_growth(gpus[0], True) + +# Define hyperparameters +MODEL_DIMS = 64 +NUM_SAMPLES = 16384 +D_UPDATES_PER_G_UPDATE = 5 +GRADIENT_PENALTY_WEIGHT = 10.0 +NOISE_LEN = 100 +EPOCHS = 128 +EPOCHS_PER_SAMPLE = 2 +BATCH_SIZE = 16 +Fs = 16000 + +# Define class that contains GAN infrastructure +class GAN: + def __init__(self, model_dims=MODEL_DIMS, num_samples=NUM_SAMPLES, + gradient_penalty_weight=GRADIENT_PENALTY_WEIGHT, + noise_len=NOISE_LEN, batch_size=BATCH_SIZE, sr=Fs): + self.model_dims = model_dims + self.num_samples = num_samples + self.noise_dims = (noise_len,) + self.batch_size = batch_size + + self.G = GANModels.Generator(self.model_dims, num_samples) + print(self.G.summary()) + + self.D = GANModels.Critic(self.model_dims, num_samples) + print(self.D.summary()) + + self.G_optimizer = Adam(learning_rate=1e-4, beta_1=0.5, beta_2=0.9) + self.D_optimizer = Adam(learning_rate=1e-4, beta_1=0.5, beta_2=0.9) + + self.gradient_penalty_weight = gradient_penalty_weight + + self.sr = sr + + # Loss function for critic + def _d_loss_fn(self, r_logit, f_logit): + r_loss = - tf.reduce_mean(r_logit) + f_loss = tf.reduce_mean(f_logit) + return r_loss, f_loss + + # Loss function for generator + def _g_loss_fn(self, f_logit): + f_loss = - tf.reduce_mean(f_logit) + return f_loss + + # Calculates gradient penalty + def _gradient_penalty(self, real, fake): + def _interpolate(a, b): + shape = [tf.shape(a)[0]] + [1] * (a.shape.ndims - 1) + alpha = tf.random.uniform(shape=shape, minval=0., maxval=1.) + inter = a + alpha * (b - a) + inter.set_shape(a.shape) + return inter + + x = _interpolate(real, fake) + with tf.GradientTape() as t: + t.watch(x) + pred = self.D(x, training=True) + + grad = t.gradient(pred, x) + norm = tf.norm(tf.reshape(grad, [tf.shape(grad)[0], -1]), axis=1) + gp = tf.reduce_mean((norm - 1.)**2) + + return gp + + # Trains generator by keeping critic constant + @tf.function + def train_G(self): + with tf.GradientTape() as t: + z = tf.random.normal(shape=(self.batch_size,) + self.noise_dims) + x_fake = self.G(z, training=True) + x_fake_d_logit = self.D(x_fake, training=True) + G_loss = self._g_loss_fn(x_fake_d_logit) + + G_grad = t.gradient(G_loss, self.G.trainable_variables) + self.G_optimizer.apply_gradients(zip(G_grad, self.G.trainable_variables)) + + return {'g_loss': G_loss} + + # Trains critic by keeping generator constant + @tf.function + def train_D(self, x_real): + with tf.GradientTape() as t: + z = tf.random.normal(shape=(x_real.shape[0],) + self.noise_dims) + x_fake = self.G(z, training=True) + + x_real_d_logit = self.D(x_real, training=True) + x_fake_d_logit = self.D(x_fake, training=True) + + x_real_d_loss, x_fake_d_loss = self._d_loss_fn(x_real_d_logit, x_fake_d_logit) + gp = self._gradient_penalty(x_real, x_fake) + + D_loss = (x_real_d_loss + x_fake_d_loss) + gp * self.gradient_penalty_weight + + D_grad = t.gradient(D_loss, self.D.trainable_variables) + self.D_optimizer.apply_gradients(zip(D_grad, self.D.trainable_variables)) + + return {'d_loss': x_real_d_loss + x_fake_d_loss, 'gp': gp} + + # Creates music samples and saves current generator model + def sample(self, epoch, num_samples=10): + self.G.save(f"models/{epoch}.h5") + z = tf.random.normal(shape=(num_samples,) + self.noise_dims) + result = self.G(z, training=False) + for i in range(num_samples): + audio = result[i, :, :] + audio = np.reshape(audio, (self.num_samples,)) + librosa.output.write_wav(f"output/piano/{epoch}-{i}.wav", audio, sr=self.sr) + + +############################################################################################### + +# Instantiate model +gan = GAN() + +# Create training data +X_train = [] +for file in os.listdir(r"D:\ML_Datasets\mancini_piano\piano\train"): + with open(r"D:\ML_Datasets\mancini_piano\piano\train" + fr"\{file}", "rb") as f: + samples, _ = librosa.load(f, Fs) + # Pad short audio files to NUM_SAMPLES duration + if len(samples) < NUM_SAMPLES: + audio = np.array([np.array([sample]) for sample in samples]) + padding = np.zeros(shape=(NUM_SAMPLES - len(samples), 1), dtype='float32') + X_train.append(np.append(audio, padding, axis=0)) + # Create slices of length NUM_SAMPLES from long audio + else: + p = len(samples) // (NUM_SAMPLES) + for i in range(p - 1): + sample = np.expand_dims(samples[i*NUM_SAMPLES:(i+1)*NUM_SAMPLES], axis=1) + X_train.append(sample) + +print(f"X_train shape = {(len(X_train),) + X_train[0].shape}") + +# Save some random training data slices and create baseline generated data for comparison +for i in range(10): + librosa.output.write_wav(f"output/piano/real-{i}.wav", + X_train[random.randint(0, len(X_train) - 1)], sr=Fs) + +gan.sample("fake") + +train_summary_writer = tf.summary.create_file_writer("logs/train") + +# Train GAN +with train_summary_writer.as_default(): + steps_per_epoch = len(X_train) // BATCH_SIZE + + for e in range(EPOCHS): + for i in range(steps_per_epoch): + D_loss_sum = 0 + + # Update dcritic a set number of times for each update of the generator + for n in range(D_UPDATES_PER_G_UPDATE): + gan.D.reset_states() + D_loss_dict = gan.train_D(np.array(random.sample(X_train, BATCH_SIZE))) + D_loss_sum += D_loss_dict['d_loss'] + + # Calculate average loss of critic for current step + D_loss = D_loss_sum / D_UPDATES_PER_G_UPDATE + + G_loss_dict = gan.train_G() + G_loss = G_loss_dict['g_loss'] + + # Write logs + tf.summary.scalar('d_loss', D_loss, step=(e*steps_per_epoch)+i) + tf.summary.scalar('g_loss', G_loss, step=(e*steps_per_epoch)+i) + + print(f"step {(e*steps_per_epoch)+i}: d_loss = {D_loss} g_loss = {G_loss}") + + # Periodically sample generator + if e % EPOCHS_PER_SAMPLE == 0: + gan.sample(e) \ No newline at end of file diff --git a/scripts/__pycache__/GANModels.cpython-37.pyc b/scripts/__pycache__/GANModels.cpython-37.pyc new file mode 100644 index 0000000..d916e72 Binary files /dev/null and b/scripts/__pycache__/GANModels.cpython-37.pyc differ