2017-11-17 5 views
0

TensorFlow's Dataset APIを使用して画像を読み込んで前処理しています。前処理した画像の概要をTensorboardに追加したいと思います。TensorFlowのデータセットAPIを使用した画像の要約

これを行うにはどのような方法が良いですか?

これまでのところ、私のコードは次のようになります。preprocess_for_train

def get_data(): 
    dataset = FixedLengthRecordDataset(...) 
    dataset = dataset.map(dataset_parser, ...) 
    if is_training: 
    dataset = dataset.map(preprocess_for_train, ...) 
    # Do shuffling, batching... 
    return dataset 

def preprocess_for_train(image, label): 
    # Do preprocessing... 
    image = tf.image.random_flip_left_right(image) 
    # Add summary 
    tf.summary.image('preprocessed_image', tf.expand_dims(image, 0)) 
    return image, label 

私のイメージはSUMMARIESコレクションに表示されていないが、外側の関数に戻ったとき、それはもはやグラフの一部です。 mapは別のスレッドを使用しているため、tf.Graphの別のインスタンスを参照しているため、これが発生すると思います。

これは機能しないため、Tensorboardに画像を表示するには他にどのようなオプションが必要ですか?

答えて

0

私は私のイテレータの出力を使用して、Tensorboardに前処理された画像を追加するためのハックを見つけました:

train_dataset = get_data() 
iterator = Iterator.from_structure(train_dataset.output_types, train_dataset.output_shapes) 
# Batch consists of [image, label] 
next_batch = iterator.get_next() 
tf.summary.image('preprocessed_image', next_batch[0]) 

summary_opを実行している場合しかし、これが二度目にnext_batch呼び出します。イメージの前処理をデバッグするのに役立ちますが、実際のトレーニングの解決策ではありません。さらに、前処理段階の中間ではなく、完全に前処理された画像のみを観察することができる。

関連する問題