def exit_handler(run): """Function that is called before the script exits. Arguments: run: The run that needs exit handling. """ force_drop_run = True # remove run if no image was saved output_files = os.listdir(run.output_path) if len(output_files) > 0: force_drop_run = False if force_drop_run and os.path.exists(run.base_path): shutil.rmtree(run.base_path) # skip if run does not exist if not os.path.exists(run.base_path): return # ask user to keep the run should_keep_run = query_yes_no("Should the run '{}' be kept?".format( os.path.basename(run.base_path)), default="yes") if not should_keep_run: shutil.rmtree(run.base_path)
def exit_handler(run): """Function that is called before the script exits. Arguments: run: The run that needs exit handling. """ force_drop_run = True # remove run if no checkpoint was saved for file in os.listdir(run.checkpoints_path): if file.startswith("model") or file == "checkpoint": force_drop_run = False break if force_drop_run and os.path.exists(run.base_path): shutil.rmtree(run.base_path) # skip if run does not exist if not os.path.exists(run.base_path): return # ask user to keep the run should_keep_run = query_yes_no("Should the run '{}' be kept?".format( os.path.basename(run.base_path)), default="yes") if not should_keep_run: shutil.rmtree(run.base_path)
"Tensorflow minimum log level.", default=3) arguments = argument_list.parse() # print some information logging_info("Image filename: {}".format( arguments.image_filename)) logging_info("Model: {}".format(arguments.model)) logging_info("Model name: {}".format( arguments.model_name)) logging_info("Dataset: {}".format(arguments.dataset)) logging_info("Tensorflow verbosity: {}".format( arguments.tf_verbosity)) logging_info("Tensorflow minimum log level: {}".format( arguments.tf_min_log_level)) should_continue = query_yes_no("Continue?", default="yes") if not should_continue: exit() # set verbosity of tensorflow tfu_set_logging(arguments.tf_verbosity, min_log_level=arguments.tf_min_log_level) # load the graph graph_filename = arguments.model_name if not graph_filename.endswith(".pb"): graph_filename = "{}.pb".format(graph_filename) graph_path = get_full_path("models", graph_filename) graph = tfu_load_graph(graph_path) # load the dataset