I'm trying to run ResNet152V2 in TensorFlowJS in Browser, but I've got problem with input processing. In Tensorflow (python), to get correct predictions, all I need to do is call tf.keras.applications.resnet_v2.preprocess_input on inputs before passing them to the model. It scales input pixels between -1 and 1 (according to https://keras.io/api/applications/resnet/).
url = 'my_image.png'
img = image.load_img(url, target_size=(224, 224))
img_array = image.img_to_array(img)
img_batch = np.expand_dims(img_array, axis=0)
img_preprocessed = tf.keras.applications.resnet_v2.preprocess_input(img_batch)
prediction = model.predict(img_preprocessed)
print(prediction.argmax(axis=-1))
Im trying to find out, how to do it in browser in JavaScript.
Thanks for help