Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why should the network be initialized with the input img during the procedure of inference #5

Open
zjbit opened this issue Mar 6, 2019 · 0 comments

Comments

@zjbit
Copy link

zjbit commented Mar 6, 2019

hello, I have read part of the source code of these project, and I find the content in the inference.py module from line 54 to line 63, and I pasts it at here as following:

Prepare image.

img_orig = tf.image.decode_jpeg(tf.read_file(args.img_path), channels=3)
# Convert RGB to BGR.
img_r, img_g, img_b = tf.split(axis=2, num_or_size_splits=3, value=img_orig)
img = tf.cast(tf.concat(axis=2, values=[img_b, img_g, img_r]), dtype=tf.float32)
# Extract mean.
img -= IMG_MEAN 

# Create network.
net = DeepLabResNetModel({'data': tf.expand_dims(img, dim=0)}, is_training=False)

However, as far as my concern, to utilize a trained model to do inference, the most common way should be like that:
(1) build the network and load the network weight param got from the previous trainning
(2)input the image for inference
anyway, according to the source code like above, the input image for inferencing was utilized as the parameter for the network initialization.
My question is, why did the input image should be utilized as a parameter for the networkinitialization, can I init the network alone without it, so as to executing the inference of this model more
efficiently(I means, initializinig the model at beginning only once, and to do the inference of several images one by one next)

Thank for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant