# Kerasdefload_model(): model = keras.models.load_model(modelLoader.path) modelLoader.update_model(model)# update model# Pytorchdefload_model(): model =Model() model.load_state_dict(torch.load(modelLoader.path)) device = torch.device("cuda:0"if torch.cuda.is_available() else"cpu") model.to(device) model.eval() modelLoader.update_model(model)# update model# Commondefpredict(data): model = modelLoader.get_model()# get model config = modelLoader.get_config()# get config ...# Commondefon_train_completed(metric,config,new_model_path): ... modelLoader.save_model()# Save model modelLoader.save_config(config)# Save config ...
defon_train_completed(metric,config,new_model_path):if metric > pipelineHelper.last_metric:# if new metirc better last pipelineHelper.update_metric(metric)# update now metricprint(pipelineHelper.metric)# show all metric e.g. [0.1, 0.2]print(pipelineHelper.last_metric)# show last metric e.g. 0.2