python - How to Plot and save a tensor as an image in Tensorflow -


i inferencing convolutional network in tensorflow using python output of network tensor has dimensions (375, 1242, 1). output image holds probability of every pixel belonging in specific class or not (in example road class - kitty ). tensor has format tensor("slice:0", shape=(375, 1242, 1), dtype=float32). question how can plot , save tensor image , how can convert binary doing thres=0.5, image = image > thres?

this question has been answered multiple times (see example my answer).

you first need evaluate tensor numpy array using open session. once have rid of dimension doing np_array=np_array[:,:,0].

then can use matplotlib , imshow(np_array) default aply colormap , normalize it.

if want binary can said binary_array=(np_array>0.5).astype("int") can dow final imshow(binary_array).


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -