-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest_client.py
More file actions
59 lines (30 loc) · 1.05 KB
/
Test_client.py
File metadata and controls
59 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from __future__ import print_function
import grpc
import Test_pb2_grpc
import Test_pb2
import Facenet
import time
import numpy as np
import cv2
import os
Path = '/home/ubuntu/image/'
allFileList = os.listdir(Path)
def generaterequest(stub):
#channel = grpc.insecure_channel('0.0.0.0:8080')
#stub = Test_pb2_grpc.ImageSrvStub(channel)
print("--------------Call Image Analyzing Begin--------------")
def stream():
for file in allFileList:
img=cv2.imread(Path+file)
img_str = cv2.imencode('.jpg', img)[1].tostring()
print('Start Transmition')
request= Test_pb2.Image(data=img_str,name=file,elapsed_time=0)
yield request
response = stub.analyze(stream())
print(response.result)
def run():
with grpc.insecure_channel('127.0.0.1:8080') as channel:
stub = Test_pb2_grpc.ImageSrvStub(channel)
generaterequest(stub)
if __name__ == '__main__':
run()