faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

Unexpected process termination = corrupted model

Open frosty3907 opened this issue 8 years ago • 11 comments

I thought that since the weights are saved fairly regularly an unexpected power loss wouldn't be catastrophic however I lost power the other day and open reopening the training the model was completely messed up, had to start from scratch.

I don't know if I was just extremely unlucky with the timing of the power loss or if this is regular behavior but either way it'd be nice if the model file was more secure.

frosty3907 avatar Apr 04 '18 13:04 frosty3907

The files written are very large (hundreds of megabytes) and depending on your storage speed can take anywhere from 2-40 seconds to write out, power loss any time during this will cause corruption. It's a very large amount of time for a power failure to happen,. especially with fast cards, which may save every couple minutes. This is not something that we can fix in the app as it's a simple matter of not enough time to write it out to disk.

I've run into damaged outputs quite often (due to writing to a file across the network), so I wrote a script that saves a backup of the file every hour. I recommend doing something similar if you're having a very bad time of it.

bryanlyon avatar Apr 04 '18 21:04 bryanlyon

We could implement a rolling backup, as I've had several models corrupt too.

copy model > model_backup save current to model.

I don't know how much this would slow things down though

torzdf avatar Apr 04 '18 22:04 torzdf

Not exactly a rolling backup, but that should work just fine. Just so long as we make sure all files are written before being moved, since partial weight changes would be just as corrupting the whole model.

bryanlyon avatar Apr 04 '18 22:04 bryanlyon

To be honest, I'm just throwing it out there. I tend to leave that part of the code well alone ;)

torzdf avatar Apr 04 '18 22:04 torzdf

it shouldn't slow things down too much if it isn't updated too often - there's no need to save every 15 seconds or whatever, every 15 minutes would be fine.

frosty3907 avatar Apr 04 '18 23:04 frosty3907

I recommend using the Ramdisk.

room3dev avatar Apr 06 '18 08:04 room3dev

Ramdisk will definitely fail during a power outage, it's not really an appropriate solution for the issue here.

bryanlyon avatar Apr 06 '18 15:04 bryanlyon

thanks bryan i thought that was an odd suggestion...

frosty3907 avatar Apr 06 '18 16:04 frosty3907

@torzdf I did implement just that (only locally so far). I can send a pull request if wanted.

fakinated avatar Apr 13 '18 19:04 fakinated

Yeah, you should raise a PR. Bit concerned that all of the collaborators may have gone awol though

torzdf avatar Apr 13 '18 21:04 torzdf

This should be fixed in PR #349. If your model is corrupted then you can pull the last saved version out of the model_bk folder

torzdf avatar Apr 15 '18 16:04 torzdf