写真の読み込みと処理
American Sign Language(米国手話)の画像を読み取り、テキストに変換する Machine Learning モデルを学習させるとします。最初のステップは大量の画像を読み込むことです。幸い、Dask を使えば、これらの画像を遅延的に読み込み・処理できます。
この演習はコースの一部です
Pythonで学ぶDaskによる並列プログラミング
演習の手順
dask.arrayのimageサブパッケージをインポートします。- ディレクトリ
data/asl内のすべての.jpeg画像を読み込みます。 - 配列から 0 番目の画像をスライスし、
.compute()メソッドでメモリに読み込みます。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Import the image subpackage from dask.array
from ____ import ____
# Lazily load in all jpegs inside all subdirectories inside data/asl
image_array = image.____(____)
# Load only the zeroth image into memory
zeroth_image = ____
# Plot the image
plt.imshow(zeroth_image)
plt.show()