MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / OfflinePredictor

Class OfflinePredictor

tensorpack/predict/base.py:139–175  ·  view source on GitHub ↗

A predictor built from a given config. A single-tower model will be built without any prefix. Example: .. code-block:: python config = PredictConfig(model=my_model, inputs_names=['image'], #

Source from the content-addressed store, hash-verified

137
138
139class OfflinePredictor(OnlinePredictor):
140 """ A predictor built from a given config.
141 A single-tower model will be built without any prefix.
142
143 Example:
144
145 .. code-block:: python
146
147 config = PredictConfig(model=my_model,
148 inputs_names=['image'],
149 # use names of tensors defined in the model
150 output_names=['linear/output', 'prediction'])
151 predictor = OfflinePredictor(config)
152 image = np.random.rand(1, 100, 100, 3) # the shape of "image" defined in the model
153 linear_output, prediction = predictor(image)
154 """
155
156 def __init__(self, config):
157 """
158 Args:
159 config (PredictConfig): the config to use.
160 """
161 self.graph = config._maybe_create_graph()
162 with self.graph.as_default():
163 input = PlaceholderInput()
164 input.setup(config.input_signature)
165 with PredictTowerContext(''):
166 config.tower_func(*input.get_input_tensors())
167
168 input_tensors = get_tensors_by_names(config.input_names)
169 output_tensors = get_tensors_by_names(config.output_names)
170
171 config.session_init._setup_graph()
172 sess = config.session_creator.create_session()
173 config.session_init._run_init(sess)
174 super(OfflinePredictor, self).__init__(
175 input_tensors, output_tensors, config.return_input, sess)

Callers 15

evaluate_rcnnFunction · 0.90
do_visualizeFunction · 0.90
predict.pyFile · 0.90
__init__Method · 0.85
_init_runtimeMethod · 0.85
sampleFunction · 0.85
runFunction · 0.85
run_testFunction · 0.85
run_testFunction · 0.85
run_testFunction · 0.85
run_testFunction · 0.85
run_testFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected