Skip to content

Commit c654b2a

Browse files
committed
export a model at end of training if export folder is empty (fixes #43)
1 parent 1ece497 commit c654b2a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

train.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,9 @@ def get_dirs_or_files(input_data):
124124

125125
exporter.export(estimator, saved_model_dir, checkpoint_path=None, eval_result=eval_result,
126126
is_the_final_export=False)
127+
128+
# If export directory is empty, export a model anyway
129+
if not os.listdir(saved_model_dir):
130+
final_exporter = tf.estimator.FinalExporter(name='FinalExporter', serving_input_receiver_fn=serving_input_fn)
131+
final_exporter.export(estimator, saved_model_dir, checkpoint_path=None, eval_result=eval_result,
132+
is_the_final_export=True)

0 commit comments

Comments
 (0)