Skip to content

Commit

Permalink
add return_numpy back (#10892)
Browse files Browse the repository at this point in the history
  • Loading branch information
daming-lu authored May 24, 2018
1 parent 8653cf3 commit cc7b4b9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
10 changes: 6 additions & 4 deletions python/paddle/fluid/inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, infer_func, param_path, place=None, parallel=False):
else:
self.exe = executor.Executor(self.place)

def infer(self, inputs):
def infer(self, inputs, return_numpy=True):
"""
:param inputs: a map of {"input_name": input_var} that will be feed into the inference program
to get the predict value
Expand All @@ -66,9 +66,11 @@ def infer(self, inputs):
raise ValueError(
"inputs should be a map of {'input_name': input_var}")

with self._prog_and_scope_guard():
results = self.exe.run(feed=inputs,
fetch_list=[self.predict_var.name])
with executor.scope_guard(self.scope):
results = self.exe.run(self.inference_program,
feed=inputs,
fetch_list=[self.predict_var],
return_numpy=return_numpy)

return results

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def infer(use_cuda, inference_program, save_dirname=None):
tensor_x = numpy.random.uniform(0, 10, [batch_size, 13]).astype("float32")

results = inferencer.infer({'x': tensor_x})
print("infer results: ", numpy.array(results[0]))
print("infer results: ", results[0])


def main(use_cuda):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def infer(use_cuda, inference_program, save_dirname=None):

results = inferencer.infer({'img': tensor_img})

print("infer results: ", numpy.array(results[0]))
print("infer results: ", results[0])


def main(use_cuda):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def infer(use_cuda, inference_program, save_dirname=None):

results = inferencer.infer({'img': tensor_img})

print("infer results: ", numpy.array(results[0]))
print("infer results: ", results[0])


def main(use_cuda):
Expand Down

0 comments on commit cc7b4b9

Please sign in to comment.