def test_pair_predict(pair_model_path, target_probe_path, target_gallery_path, pid_path, score_path): # todo print( "before load_model:----------------------------------------------------------------- " ) model = load_model("./market_pair_pretrain.h5", custom_objects={'triplet_hard_loss': triplet_hard_loss}) print( "model finished:----------------------------------------------------------------- " ) # model = ResNet50(weights='imagenet', include_top=False, input_tensor=Input(shape=(224, 224, 3))) #model = Model(inputs=[model.layers[0].get_input_at(0)], # outputs=[model.get_layer('ave_pooled_part').get_output_at(0)]) for layer in model.layers: print("!!!!:", layer) print("@@@@@", model.layers[-5]) #model = Model(inputs=[model.layers[0].get_input_at(0)], # outputs=[model.layers[-4].get_output_at(0)] ) global_feature = model.layers[-5].get_output_at(0) feature1 = GlobalAveragePooling2D(name='ave_pooled')(global_feature) model = Model(inputs=[model.input], outputs=[feature1]) # model = Model(inputs=[model.input], outputs=[model.get_layer('avg_pool').output]) print( "before test_predict:----------------------------------------------------------------- " ) test_predict(model, target_probe_path, target_gallery_path, pid_path, score_path)
def test_pair_predict(pair_model_path, target_probe_path, target_gallery_path, pid_path, score_path): # todo model = load_model(pair_model_path, custom_objects={'focal_loss_fixed': focal_loss_fixed}) # model = ResNet50(weights='imagenet', include_top=False, input_tensor=Input(shape=(224, 224, 3))) model = Model(inputs=[model.get_layer('resnet50').get_input_at(0)], outputs=[model.get_layer('resnet50').get_output_at(0)]) # model = Model(inputs=[model.input], outputs=[model.get_layer('avg_pool').output]) test_predict(model, target_probe_path, target_gallery_path, pid_path, score_path)
def test_rank_predict(rank_model_path, target_probe_path, target_gallery_path, pid_path, score_path): model = load_model( rank_model_path, custom_objects={'cross_entropy_loss': cross_entropy_loss}) model = Model(inputs=[model.get_layer('resnet50').get_input_at(0)], outputs=[model.get_layer('resnet50').get_output_at(0)]) test_predict(model, target_probe_path, target_gallery_path, pid_path, score_path)
def test_rank_predict(rank_model_path, target_probe_path, target_gallery_path, pid_path, score_path): model = load_model(rank_model_path, custom_objects={'cross_entropy_loss': cross_entropy_loss}) for layer in model.get_layer('resnet50').layers: if isinstance(layer, BatchNormalization): print(layer.get_weights()) break model = Model(inputs=[model.get_layer('resnet50').get_input_at(0)], outputs=[model.get_layer('resnet50').get_output_at(0)]) test_predict(model, target_probe_path, target_gallery_path, pid_path, score_path)
def test_pair_predict(pair_model_path, target_probe_path, target_gallery_path, pid_path, score_path): model = load_model(pair_model_path) model = Model(inputs=[model.get_layer('resnet50').get_input_at(0)], outputs=[model.get_layer('resnet50').get_output_at(0)]) # model = Model(inputs=[model.input], outputs=[model.get_layer('avg_pool').output]) return test_predict(model, target_probe_path, target_gallery_path, pid_path, score_path)