forked from fpaupier/tensorflow-serving_sidecar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwechat_bot.py
More file actions
38 lines (26 loc) · 1.17 KB
/
wechat_bot.py
File metadata and controls
38 lines (26 loc) · 1.17 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
import itchat
from itchat.content import *
import uuid
import os
rec_tmp_dir = 'cache/'
# process face image, predict emotion and return result to the user
@itchat.msg_register([itchat.content.PICTURE], isGroupChat=True)
def face_reply(msg):
group_name = msg.User['NickName']
user = msg.FromUserName
print(group_name)
print(user)
if 'Tensorflow' not in group_name:
print('Photo not in correct group')
return
itchat.send(msg='Processing Image', toUserName=user)
original_file_name_stripped = rec_tmp_dir + msg['FileName'].split('.')[0]
original_file_name = original_file_name_stripped + '.jpg'
# print(msg['FileName'])
msg.download(original_file_name)
cmd = 'python3 client.py --server_url "http://localhost:8501/v1/models/faster_rcnn_resnet:predict" --image_path "$(pwd)/'+ original_file_name + '" --output_json "$(pwd)/'+original_file_name_stripped+'.json" --save_output_image "True" --label_map "$(pwd)/data/labels.pbtxt"'
os.system(cmd)
itchat.send_image(original_file_name_stripped+'.jpeg', toUserName=user)
return #'@img@%s' % original_file_name_stripped+'.jpeg'
itchat.auto_login(enableCmdQR=2)
itchat.run()