Skip to content

Commit

Permalink
remove input func (PaddlePaddle#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilong12 authored Dec 23, 2019
1 parent fbb20a3 commit 5910453
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions plsc/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,16 +450,10 @@ def load_checkpoint(self,
checkpoint_dir = self.checkpoint_dir

if self.fs_name is not None:
ans = 'y'
if os.path.exists(checkpoint_dir):
ans = input("Downloading pretrained models, but the local "
"checkpoint directory ({}) exists, overwrite it "
"or not? [Y/N]".format(checkpoint_dir))

if ans.lower() == 'y':
if os.path.exists(checkpoint_dir):
logger.info("Using the local checkpoint directory.")
shutil.rmtree(checkpoint_dir)
logger.info("Local dir {} exists, we'll overwrite it.".format(
checkpoint_dir))
shutil.rmtree(checkpoint_dir)
os.makedirs(checkpoint_dir)

# sync all trainers to avoid loading checkpoints before
Expand Down Expand Up @@ -537,20 +531,16 @@ def convert_for_prediction(self):
assert self.model_save_dir, \
"Does not set model_save_dir for inference model converting."
if os.path.exists(self.model_save_dir):
ans = input("model_save_dir for inference model ({}) exists, "
"overwrite it or not? [Y/N]".format(model_save_dir))
if ans.lower() == 'n':
logger.error("model_save_dir for inference model exists, "
"and cannot overwrite it.")
exit()
logger.info("model_save_dir for inference model ({}) exists, "
"we will overwrite it.".format(self.model_save_dir))
shutil.rmtree(self.model_save_dir)
fluid.io.save_inference_model(self.model_save_dir,
feeded_var_names=[image.name],
target_vars=[emb],
executor=exe,
main_program=main_program)
if self.fs_name:
self.put_files_to_hdfs(model_save_dir)
self.put_files_to_hdfs(self.model_save_dir)

def predict(self):
model_name = self.model_name
Expand Down

0 comments on commit 5910453

Please sign in to comment.