MCPcopy
hub / github.com/PaddlePaddle/PaddleRec / run_web_client

Function run_web_client

tools/rec_client.py:78–97  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

76
77
78def run_web_client(args):
79 headers = {"Content-type": "application/json"}
80 url = "http://" + args.connect + "/rec/prediction"
81 place = paddle.set_device('gpu' if args.use_gpu else 'cpu')
82 args.place = place
83 test_dataloader = create_data_loader(args)
84 client = Client()
85 client.load_client_config(args.client_config)
86 feed_names = client.feed_names_
87 fetch_names = client.fetch_names_
88 start = time.time()
89 while True:
90 for batch_id, batch_data in enumerate(test_dataloader):
91 batch_data = [tensor.numpy().tolist() for tensor in batch_data]
92 feed_dict = dict(zip(feed_names, batch_data))
93 data = {"feed": [feed_dict], "fetch": fetch_names}
94 r = requests.post(url=url, headers=headers, data=json.dumps(data))
95 print(r.json())
96 if time.time() - start > 30:
97 break
98
99
100if __name__ == '__main__':

Callers 1

rec_client.pyFile · 0.85

Calls 2

numpyMethod · 0.80
create_data_loaderFunction · 0.70

Tested by

no test coverage detected