Skip to content

Commit ed7b6e7

Browse files
committed
use rasterio instead of Pil
1 parent 3492bd0 commit ed7b6e7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

label_maker/package.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,21 @@ def package_directory(dest_folder, classes, imagery, ml_type, seed=False,
9090
for tile in tiles:
9191
image_file = op.join(dest_folder, 'tiles', '{}{}'.format(tile, image_format))
9292
try:
93-
img = Image.open(image_file)
93+
#img = Image.open(image_file)
94+
img = rasterio.open(image_file)
9495
except FileNotFoundError:
9596
# we often don't download images for each label (e.g. background tiles)
9697
continue
9798
except OSError:
9899
print('Couldn\'t open {}, skipping'.format(image_file))
99100
continue
100101

101-
np_image = np.array(img)
102+
i = np.array(img.read())
103+
print(i.shape)
104+
np_image = np.moveaxis(i, 0, 2)
102105
img.close()
103106

107+
104108
x_vals.append(np_image)
105109
if ml_type == 'classification':
106110
y_vals.append(labels[tile])

0 commit comments

Comments
 (0)