mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-03-02 05:11:57 +01:00
Fix a bug by saving model weights in steps
This commit is contained in:
parent
d8667f46d7
commit
fed005abd7
1 changed files with 3 additions and 2 deletions
|
|
@ -58,6 +58,7 @@ class SaveWeightsAfterSteps(Callback):
|
||||||
self.save_path = save_path
|
self.save_path = save_path
|
||||||
self.step_count = 0
|
self.step_count = 0
|
||||||
self._config = _config
|
self._config = _config
|
||||||
|
self.characters_cnnrnn_ocr = characters_cnnrnn_ocr
|
||||||
|
|
||||||
def on_train_batch_end(self, batch, logs=None):
|
def on_train_batch_end(self, batch, logs=None):
|
||||||
self.step_count += 1
|
self.step_count += 1
|
||||||
|
|
@ -68,8 +69,8 @@ class SaveWeightsAfterSteps(Callback):
|
||||||
|
|
||||||
self.model.save(save_file)
|
self.model.save(save_file)
|
||||||
|
|
||||||
if characters_cnnrnn_ocr:
|
if self.characters_cnnrnn_ocr:
|
||||||
os.system("cp "+characters_cnnrnn_ocr+" "+os.path.join(os.path.join(self.save_path, f"model_step_{self.step_count}"),"characters_org.txt"))
|
os.system("cp "+self.characters_cnnrnn_ocr+" "+os.path.join(os.path.join(self.save_path, f"model_step_{self.step_count}"),"characters_org.txt"))
|
||||||
|
|
||||||
with open(os.path.join(os.path.join(self.save_path, f"model_step_{self.step_count}"),"config_eynollah.json"), "w") as fp:
|
with open(os.path.join(os.path.join(self.save_path, f"model_step_{self.step_count}"),"config_eynollah.json"), "w") as fp:
|
||||||
json.dump(self._config, fp) # encode dict into JSON
|
json.dump(self._config, fp) # encode dict into JSON
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue