keras-team / keras-applications

Reference implementations of popular deep learning models.
Other
2k stars 914 forks source link

Keras MobileNetv2 image normalization #209

Open xellDart opened 2 years ago

xellDart commented 2 years ago

Hi, I train my model using keras, and I load data using this function

Resize the images to a fixed input size, and rescale the input channels to a range of [-1,1]

IMG_SIZE = 320 # All images will be resized to 160x160

def format_example(pair):
  image, label = pair['image'], pair['label']
  image = tf.cast(image, tf.float32)
  image = (image/127.5) - 1
  image = tf.image.resize(image, (IMG_SIZE, IMG_SIZE))
  return image, label

But i cant understand what norm mean values apply when I transform my model to other framework, for example, ncnn, Pytorch use

But what value I need to apply in keras mobilenetv2 model?