1

私はこのチュートリアルに取り組んでいます:

https://github.com/Microsoft/CNTK/blob/master/Tutorials/CNTK_201B_CIFAR-10_ImageHandsOn.ipynb

テスト/トレーニング データ ファイルは、次のような画像ファイル名と正しいラベルを含む単純なタブ区切りのテキスト ファイルです。

...\data\CIFAR-10\test\00000.png    3
...\data\CIFAR-10\test\00001.png    8
...\data\CIFAR-10\test\00002.png    8

次のようなミニバッチを作成するとします。

test_minibatch = reader_test.next_minibatch(10)

テスト データ ファイルの最初の列にあった画像のファイル名を取得するにはどうすればよいですか?

私はこのコードで試しました:

orig_features = np.asarray(test_minibatch[features_stream_info].m_data)
print(orig_features)

ただし、その結果、画像自体のバイトが印刷されます。

4

1 に答える 1

3

イメージ リーダーを使用してイメージをロードすると、ファイル名が失われます。

考えられる解決策の 1 つは、複合リーダーを使用してマップ ファイルをテキスト形式で同時に読み込むことです。ここには、BrainScript を使用した複合リーダーの例があります: https://github.com/Microsoft/CNTK/tree/master/Examples/Image/Regression

Python では、次のようなことができます。

# read images
image_source = ImageDeserializer(map_file)
image_source.ignore_labels()
image_source.map_features(features_stream_name,
    [ImageDeserializer.scale(width=image_width, height=image_height, channels=num_channels,
                             scale_mode="pad", pad_value=114, interpolations='linear')])

# read rois and labels
roi_source = CTFDeserializer(roi_file)
roi_source.map_input(rois_stream_name, dim=rois_dim, format="dense")
label_source = CTFDeserializer(label_file)
label_source.map_input(labels_stream_name, dim=label_dim, format="dense")

# define a composite reader
rc = ReaderConfig([image_source, roi_source, label_source], epoch_size=sys.maxsize)
return rc.minibatch_source()
于 2017-01-05T21:37:17.673 に答える