qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.67k stars 1.03k forks source link

Applying preprocess_input on numpy array changes input x and returns x #491

Open sherif-med opened 2 years ago

sherif-med commented 2 years ago

Check _preprocess_numpy_input(X) in imagenet_utils.py you will find that preprocessing is applied on X. This makes code below erroneous and 'test_img_input2' with no meaning because 'test_images' are already preprocessed.

`BACKBONE1 = 'vgg16' model1 = load_model(model1_path, compile=False) preprocess_input1 = sm.get_preprocessing(BACKBONE1) test_img_input1 = preprocess_input1(test_images)

BACKBONE2 = 'inceptionv3' model2 = load_model(model2_path, compile=False) preprocess_input2 = sm.get_preprocessing(BACKBONE2) test_img_input2 = preprocess_input2(test_images) pred2 = model2.predict(test_img_input2)`

I think _preprocess_numpy_input should copy and return a preprocessed array instead of applying changes directly