Skip to content

Commit 8df712e

Browse files
tztztztztzchsasank
authored andcommitted
fix image show error (pytorch#165)
* since it normalized the channel value to specific std and mean, when show the image and reverse its value to [0, 1], sometimes it got error of **Floating point image RGB values must be in the 0..1 range.** * use np.clip instead
1 parent 4098372 commit 8df712e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

beginner_source/transfer_learning_tutorial.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def imshow(inp, title=None):
111111
mean = np.array([0.485, 0.456, 0.406])
112112
std = np.array([0.229, 0.224, 0.225])
113113
inp = std * inp + mean
114+
inp = np.clip(inp, 0, 1)
114115
plt.imshow(inp)
115116
if title is not None:
116117
plt.title(title)

0 commit comments

Comments
 (0)