|
a |
|
b/SegNet/SegNetCMR/helpers.py |
|
|
1 |
import tensorflow as tf |
|
|
2 |
|
|
|
3 |
def add_output_images(images, logits, labels): |
|
|
4 |
cast_labels = tf.cast(labels, tf.uint8) * 128 |
|
|
5 |
cast_labels = cast_labels[...,None] |
|
|
6 |
tf.summary.image('input_labels', cast_labels, max_outputs=3) |
|
|
7 |
|
|
|
8 |
classification1 = tf.nn.softmax(logits = logits, dim=-1)[...,1] |
|
|
9 |
output_image_gb = images[...,0] |
|
|
10 |
output_image_r = classification1 + tf.multiply(images[...,0], (1-classification1)) |
|
|
11 |
output_image = tf.stack([output_image_r, output_image_gb, output_image_gb], axis=3) |
|
|
12 |
tf.summary.image('output_mixed', output_image, max_outputs=3) |
|
|
13 |
|
|
|
14 |
output_image_binary = tf.argmax(logits, 3) |
|
|
15 |
output_image_binary = tf.cast(output_image_binary[...,None], tf.float32) * 128/255 |
|
|
16 |
tf.summary.image('output_labels', output_image_binary, max_outputs=3) |
|
|
17 |
|
|
|
18 |
output_labels_mixed_r = output_image_binary[...,0] + tf.multiply(images[...,0], (1-output_image_binary[...,0])) |
|
|
19 |
output_labels_mixed = tf.stack([output_labels_mixed_r, output_image_gb, output_image_gb], axis=3) |
|
|
20 |
tf.summary.image('output_labels_mixed', output_labels_mixed, max_outputs=3) |
|
|
21 |
|
|
|
22 |
return |
|
|
23 |
|
|
|
24 |
def add_test_output_images(images, logits): |
|
|
25 |
output_image_gb = images[..., 0] |
|
|
26 |
|
|
|
27 |
output_image_binary = tf.argmax(logits, 3) |
|
|
28 |
output_image_binary = tf.cast(output_image_binary[..., None], tf.float32) * 128 / 255 |
|
|
29 |
tf.summary.image('test_prediction_labels', output_image_binary, max_outputs=3) |
|
|
30 |
|
|
|
31 |
output_labels_mixed_r = output_image_binary[..., 0] + tf.multiply(images[..., 0], (1 - output_image_binary[..., 0])) |
|
|
32 |
output_labels_mixed = tf.stack([output_labels_mixed_r, output_image_gb, output_image_gb], axis=3) |
|
|
33 |
tf.summary.image('test_prediction_labels_mixed', output_labels_mixed, max_outputs=3) |
|
|
34 |
|
|
|
35 |
return |