テンソルフローのtf.train.shuffle_batch関数を使用しようとしていますが、最初にtf.image.decode_jpeg(またはpngとjpgをロードするための他の同様の関数)を使用してイメージをロードする必要があります。しかし、私は、画像が確率マップとしてロードされていることを知りました。これは、ピクセル値の最大値が1で、ピクセル値の最小値が0であることを意味します。以下は、githubリポジトリから更新されたコードです。ピクセルの値が[0,1]に正規化されている理由はわかりませんが、テンソルフローに関する関連ドキュメントは見つかりません。誰か助けてくれますか?ありがとう。イメージピクセル値はtf.image.decode_jpegとtf.train.shuffle_batchで正規化されていますか?
def load_examples(self, input_dir, flip, scale_size, batch_size, min_queue_examples):
input_paths = get_image_paths(input_dir)
with tf.name_scope("load_images"):
path_queue = tf.train.string_input_producer(input_paths)
reader = tf.WholeFileReader()
paths, contents = reader.read(path_queue)
# note this is important for truncated images
raw_input = tf.image.decode_jpeg(contents,try_recover_truncated = True, acceptable_fraction=0.5)
raw_input = tf.image.convert_image_dtype(raw_input, dtype=tf.float32)
raw_input.set_shape([None, None, 3])
# break apart image pair and move to range [-1, 1]
width = tf.shape(raw_input)[1] # [height, width, channels]
a_images = preprocess(raw_input[:, :width // 2, :])
b_images = raw_input[:, width // 2:, :]
inputs, targets = [a_images, b_images]
def transform(image):
r = image
r = tf.image.resize_images(r, [self.image_height, self.image_width], method=tf.image.ResizeMethod.AREA)
return r
def transform_gaze(image):
r = image
r = tf.image.resize_images(r, [self.gaze_height, self.gaze_width], method=tf.image.ResizeMethod.AREA)
return r
with tf.name_scope("input_images"):
input_images = transform(inputs)
with tf.name_scope("target_images"):
target_images = transform(targets)
total_image_count = len(input_paths)
# target_images = tf.image.per_image_standardization(target_images)
target_images = target_images[:,:,0]
target_images = tf.expand_dims(target_images, 2)
inputs_batch, targets_batch = tf.train.shuffle_batch([input_images, target_images],
batch_size=batch_size,
num_threads=1,
capacity=min_queue_examples + 3 * batch_size,
min_after_dequeue=min_queue_examples)
# inputs_batch, targets_batch = tf.train.batch([input_images, target_images],batch_size=batch_size)
return inputs_batch, targets_batch, total_image_count
こんにちは私は、このように入力データの画像サマリーを追加しました:tf.summary.image( 'training_truth'、self.targets、4)テンソルボードでは、画像は[0,255]の範囲で表示されます。つまり、私のモデルの画像バッチは正規化されていますが、テンソルボードの視覚化はまだ[0,255]ですか?ありがとうございました –
はい、画像の概要が入力の種類を確認します。浮動小数点の場合、視覚化目的のために0.255の範囲に値を拡大します – nessuno
素晴らしい、答えてくれてありがとう! –