Capturing output of Softmax into an image in Tensorflow

99 Views Asked by At

Need some help on Tensorflow image processing.

I am working with exploring one of the open source project on kovid - https://github.com/lindawangg/COVID-Net

I was able to successfully download the model and run the predictions successfully. So when I run inference.py provided in the example, it generates perfect output.

Howeverm what I am trying to implememnt is, generating a heatmap out of the match done, as shown in this image. In spite of trying many possibilities, I am left clueless in impleemnting that.

These are my understanding, They are using Softmax with logit function to find out the probibility of the match. With this assumption, I wrote a code like

 x = process_image_file(img, 0.08, 480)
    x = x.astype('float32') / 255.0

    pred = sess.run(pred_tensor, feed_dict={
        image_tensor: np.expand_dims(x, axis=0)
    })

    g1 = tf.gradients(pred_tensor, image_tensor)
    sess.run(g1)

where

 g1 = tf.gradients(pred_tensor, image_tensor)
    sess.run(g1)

This is the code I added for generating gradient output, However this fails with an error like

[2020-05-24 00:06:39,922] ERROR in app: Exception on /predict/ [POST]
Traceback (most recent call last):
  File "/mnt/g/TS/covid/COVID-Net/venv/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1365, in _do_call
    return fn(*args)
  File "/mnt/g/TS/covid/COVID-Net/venv/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1350, in _run_fn
    target_list, run_metadata)
  File "/mnt/g/TS/covid/COVID-Net/venv/lib/python3.7/site-packages/tensorflow_core/python/client/session.py", line 1443, in _call_tf_sessionrun
    run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'input_1' with dtype float and shape [?,480,480,3]
     [[{{node input_1}}]]

Please help.. I am completely new to ML, Tensorflow and python, so please forgive me if this question looks absolutely stupid!

0

There are 0 best solutions below