Skip to content

Commit d1e5a0e

Browse files
menglutaonilsleh
authored andcommitted
Fix for Blank Images in plot due to Float Tensor Ranges (#1712)
* fix: blank image when using plot * black check
1 parent 57b028c commit d1e5a0e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

torchgeo/datasets/ucmerced.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ def plot(
214214
.. versionadded:: 0.2
215215
"""
216216
image = np.rollaxis(sample["image"].numpy(), 0, 3)
217+
218+
# Normalize the image if the max value is greater than 1
219+
if image.max() > 1:
220+
image = image.astype(np.float32) / 255.0 # Scale to [0, 1]
221+
217222
label = cast(int, sample["label"].item())
218223
label_class = self.classes[label]
219224

0 commit comments

Comments
 (0)