|
128 | 128 | "from google.colab import drive\n",
|
129 | 129 | "import tensorflow as tf\n",
|
130 | 130 | "\n",
|
131 |
| - "!pip install ipyfilechooser \u0026\u003e /dev/null\n", |
| 131 | + "!pip install ipyfilechooser==0.6.0 \u0026\u003e /dev/null\n", |
132 | 132 | "from ipyfilechooser import FileChooser\n",
|
133 | 133 | "\n",
|
134 | 134 | "# ------------------------------------------------------------------------------\n",
|
|
227 | 227 | " print('(10 minutes of training audio -\u003e 20-30 minutes)')\n",
|
228 | 228 | "\n",
|
229 | 229 | " audio_filepattern = os.path.join(audio_dir, '*')\n",
|
| 230 | + " audio_fp_str = f'\"{audio_filepattern}\"' \n", |
| 231 | + " tfrecord_path_str = f'\"{data_dir}/train.tfrecord\"'\n", |
| 232 | + "\n", |
230 | 233 | " !ddsp_prepare_tfrecord \\\n",
|
231 |
| - " --input_audio_filepatterns=$audio_filepattern \\\n", |
232 |
| - " --output_tfrecord_path=$data_dir/train.tfrecord \\\n", |
| 234 | + " --input_audio_filepatterns=$audio_fp_str \\\n", |
| 235 | + " --output_tfrecord_path=$tfrecord_path_str \\\n", |
233 | 236 | " --num_shards=10 \\\n",
|
234 | 237 | " --sample_rate=$sample_rate \\\n",
|
235 | 238 | " --frame_rate=$frame_rate \\\n",
|
|
241 | 244 | "\n",
|
242 | 245 | "def train(model_dir, data_dir, steps=30000):\n",
|
243 | 246 | " file_pattern = os.path.join(data_dir, 'train.tfrecord*')\n",
|
| 247 | + " fp_str = f\"TFRecordProvider.file_pattern='{file_pattern}'\"\n", |
244 | 248 | " !ddsp_run \\\n",
|
245 | 249 | " --mode=train \\\n",
|
246 | 250 | " --save_dir=\"$model_dir\" \\\n",
|
247 | 251 | " --gin_file=models/vst/vst.gin \\\n",
|
248 | 252 | " --gin_file=datasets/tfrecord.gin \\\n",
|
249 |
| - " --gin_param=\"TFRecordProvider.file_pattern='$file_pattern'\" \\\n", |
| 253 | + " --gin_param=\"$fp_str\" \\\n", |
250 | 254 | " --gin_param=\"TFRecordProvider.centered=True\" \\\n",
|
251 | 255 | " --gin_param=\"TFRecordProvider.frame_rate=50\" \\\n",
|
252 | 256 | " --gin_param=\"batch_size=16\" \\\n",
|
|
261 | 265 | "\n",
|
262 | 266 | "\n",
|
263 | 267 | "def reset_state(data_dir, audio_dir, model_dir):\n",
|
| 268 | + " model_dir_str = f'\"{model_dir}\"'\n", |
264 | 269 | " if tf.io.gfile.exists(data_dir):\n",
|
265 | 270 | " !rm -r $data_dir\n",
|
266 | 271 | " !rm -r $audio_dir\n",
|
267 | 272 | " !mkdir -p $data_dir\n",
|
268 | 273 | " !mkdir -p $audio_dir\n",
|
269 |
| - " !mkdir -p $model_dir\n", |
| 274 | + " !mkdir -p $model_dir_str\n", |
270 | 275 | "\n",
|
271 | 276 | "\n",
|
272 | 277 | "def export_and_download(model_dir, model_name=Name):\n",
|
273 | 278 | " export_path = os.path.join(model_dir, model_name)\n",
|
274 | 279 | "\n",
|
| 280 | + " model_dir_str=f'\"{model_dir}\"'\n", |
| 281 | + " export_path_str=f'\"{export_path}\"'\n", |
| 282 | + " \n", |
275 | 283 | " !ddsp_export \\\n",
|
276 | 284 | " --name=$model_name \\\n",
|
277 |
| - " --model_path=$model_dir \\\n", |
278 |
| - " --save_dir=$export_path \\\n", |
| 285 | + " --model_path=$model_dir_str \\\n", |
| 286 | + " --save_dir=$export_path_str \\\n", |
279 | 287 | " --inference_model=vst_stateless_predict_controls \\\n",
|
280 | 288 | " --tflite \\\n",
|
281 | 289 | " --notfjs\n",
|
|
284 | 292 | " zip_fname = f'{model_name}.zip'\n",
|
285 | 293 | " zip_fp = os.path.join(model_dir, zip_fname)\n",
|
286 | 294 | " print(f'Export complete! Zipping {export_path} to {zip_fp}')\n",
|
287 |
| - " !cd $model_dir \u0026\u0026 zip -r $zip_fname ./$model_name\n", |
288 |
| - " # !zip -jr $zip_fp $export_path\n", |
| 295 | + " !cd $model_dir_str \u0026\u0026 zip -r $zip_fname ./$model_name\n", |
289 | 296 | "\n",
|
290 | 297 | " # Download.\n",
|
291 | 298 | " print(f'Zipping Complete! Downloading... {zip_fname}')\n",
|
|
0 commit comments