Skip to content

Commit 0dd0b78

Browse files
authored
Use resnet50 'preprocess_input' function before feeding them to model (#1185)
1 parent ea4f282 commit 0dd0b78

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

examples/vision/deeplabv3_plus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Title: Multiclass semantic segmentation using DeepLabV3+
33
Author: [Soumik Rakshit](http://github.com/soumik12345)
44
Date created: 2021/08/31
5-
Last modified: 2021/09/1
5+
Last modified: 2023/01/06
66
Description: Implement DeepLabV3+ architecture for Multi-class Semantic Segmentation.
77
Accelerator: GPU
88
"""
@@ -80,7 +80,7 @@ def read_image(image_path, mask=False):
8080
image = tf.image.decode_png(image, channels=3)
8181
image.set_shape([None, None, 3])
8282
image = tf.image.resize(images=image, size=[IMAGE_SIZE, IMAGE_SIZE])
83-
image = image / 127.5 - 1
83+
image = tf.keras.applications.resnet50.preprocess_input(image)
8484
return image
8585

8686

examples/vision/ipynb/deeplabv3_plus.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"\n",
1111
"**Author:** [Soumik Rakshit](http://github.com/soumik12345)<br>\n",
1212
"**Date created:** 2021/08/31<br>\n",
13-
"**Last modified:** 2021/09/1<br>\n",
13+
"**Last modified:** 2023/01/06<br>\n",
1414
"**Description:** Implement DeepLabV3+ architecture for Multi-class Semantic Segmentation."
1515
]
1616
},
@@ -127,7 +127,7 @@
127127
" image = tf.image.decode_png(image, channels=3)\n",
128128
" image.set_shape([None, None, 3])\n",
129129
" image = tf.image.resize(images=image, size=[IMAGE_SIZE, IMAGE_SIZE])\n",
130-
" image = image / 127.5 - 1\n",
130+
" image = tf.keras.applications.resnet50.preprocess_input(image)\n",
131131
" return image\n",
132132
"\n",
133133
"\n",

examples/vision/md/deeplabv3_plus.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
**Author:** [Soumik Rakshit](http://github.com/soumik12345)<br>
44
**Date created:** 2021/08/31<br>
5-
**Last modified:** 2021/09/1<br>
5+
**Last modified:** 2023/01/06<br>
66

77

88
<img class="k-inline-icon" src="https://colab.research.google.com/img/colab_favicon.ico"/> [**View in Colab**](https://colab.research.google.com/github/keras-team/keras-io/blob/master/examples/vision/ipynb/deeplabv3_plus.ipynb) <span class="k-dot">•</span><img class="k-inline-icon" src="https://github.com/favicon.ico"/> [**GitHub source**](https://github.com/keras-team/keras-io/blob/master/examples/vision/deeplabv3_plus.py)
@@ -96,7 +96,7 @@ def read_image(image_path, mask=False):
9696
image = tf.image.decode_png(image, channels=3)
9797
image.set_shape([None, None, 3])
9898
image = tf.image.resize(images=image, size=[IMAGE_SIZE, IMAGE_SIZE])
99-
image = image / 127.5 - 1
99+
image = tf.keras.applications.resnet50.preprocess_input(image)
100100
return image
101101

102102

0 commit comments

Comments
 (0)