-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserving.py
42 lines (36 loc) · 1.04 KB
/
serving.py
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
from socket_util import *
from DL_model import Are_U_Beatutifut
import tensorflow as tf
from struct import pack
def main(argv=None):
#-------socket_init-------
s = socket_init()
#-------deep_learning_system_init-------
AI = Are_U_Beatutifut()
AI.build()
print('Start Serving')
#--------start_serving-------
while True:
conn, addr = s.accept()
print('Connected by', addr)
data = conn.recv(1024)
if not data:
break
else:
try:
image_name = receive_image(data=data,conn=conn)
result = AI.rating(image_name)
if result[0]==1:
score = result[2]
temp = float_to_str(score)
conn.send(temp)
else:
score = -1
temp = int_to_str(score)
conn.send(temp)
print(result)
except:
print('error')
conn.close()
if __name__ == '__main__':
main()