tympanix / subsync

Synchronize your subtitles using machine learning
Apache License 2.0
148 stars 16 forks source link

How to train the network? #11

Closed snusy123 closed 5 years ago

snusy123 commented 5 years ago

Hey! I was wondring how i would be able to train the network?

tympanix commented 5 years ago

Hi. Although the scripts used to train the network is not as clean as I would like them to be, they should still be able to do the job. Firstly make sure to clone the repo and install the dependencies with pip. Basically you want to look in the subsync/model directory. Lets assume this your working directory from now on. Here you will find:

train_data.py: Used to plot the MFCC spectrograms of your training data train_ann.py: Used to train the neural network on the training data eval_ann.py: Used to plot the training history eval_logloss.py: Used to plot the logloss values of your training data eval_train.py: Used to plot the predictions of your training data (VAD predictions) convert.py: Used to convert the final model from .hdf5 to .pb format

All the scripts above can be run as a module with python3. The scripts with prefix eval_* must be run after the model has been trained. First you will need some training data and put it in the training folder. Your training data must consist of video material and the corresponding (matching!) subtitle. The files must be named correctly, e.g.:

training/my_media_1.mp4 training/my_media_1.srt

Refrain from using spaces in filenames. Your video files will be automatically converted with ffmpeg which should support a decent amount of video codecs and containers. After you have found some training data run the train_ann.py file. Your model should now be training. Afterwards you may run any of the eval_* files to inspect the results. If you want to use your new model in production you can convert your model with convert.py and copy the .pb file to the subsync directory. I hope this helps you out.

Cheers!