MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / image_preprocess

Method image_preprocess

examples/Saliency/imagenet_utils.py:386–398  ·  view source on GitHub ↗
(self, image)

Source from the content-addressed store, hash-verified

384 return opt
385
386 def image_preprocess(self, image):
387 with tf.name_scope('image_preprocess'):
388 if image.dtype.base_dtype != tf.float32:
389 image = tf.cast(image, tf.float32)
390 mean = [0.485, 0.456, 0.406] # rgb
391 std = [0.229, 0.224, 0.225]
392 if self.image_bgr:
393 mean = mean[::-1]
394 std = std[::-1]
395 image_mean = tf.constant(mean, dtype=tf.float32) * 255.
396 image_std = tf.constant(std, dtype=tf.float32) * 255.
397 image = (image - image_mean) / image_std
398 return image
399
400 @staticmethod
401 def compute_loss_and_error(logits, label, label_smoothing=0.):

Callers 1

build_graphMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected