Food101という101クラスの料理画像がラベルとセットになっているデータセットがある。 こちらを触ってみる。
クラスごとに250枚のテスト画像と750枚の訓練画像があり、全部で101000枚画像が用意されている。 オリジナルだと画像の最大サイズは同じ(512pixel)にスケールされているものの、もう片方の辺はバラバラのようなので、 kaggleのここを参考にサイズが揃ったデータを取得し可視化だけしてみる。
def visualize_data(): base_path = "./dataset" train_h5_path = os.path.join(base_path, "food_c101_n10099_r64x64x3.h5") test_h5_path = os.path.join(base_path, "food_test_c101_n1000_r64x64x3.h5") print(os.path.exists(train_h5_path)) print(os.path.exists(test_h5_path)) with h5py.File(train_h5_path, 'r') as n_file: total_imgs = n_file['images'].shape[0] read_idxs = slice(0, total_imgs) img_data = n_file['images'][read_idxs] img_label = n_file['category'].value[read_idxs] label_names = [x.decode() for x in n_file['category_names'].value] fig, m_ax = plt.subplots(5, 5, figsize = (12, 12)) for c_ax, c_label, c_img in zip(m_ax.flatten(), img_label, img_data): c_ax.imshow(c_img) c_ax.axis('off') c_ax.set_title(label_names[np.argmax(c_label)])