Skip to content

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

Description

@zjbit

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions