gseps_test_version
This commit is contained in:
parent
95d87f02fb
commit
a2f6eb97b6
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"slack_url": "https://hooks.slack.com/services/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",
|
"slack_url": "https://hooks.slack.com/services/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",
|
||||||
"slack_message": "Queue is Empty! Restart after 100 second",
|
"slack_message": "Queue is Empty! Restart after 250 second",
|
||||||
"amqp_url": "13.209.39.139",
|
"amqp_url": "13.209.39.139",
|
||||||
"amqp_port": 30747,
|
"amqp_port": 30747,
|
||||||
"amqp_vhost": "/",
|
"amqp_vhost": "/",
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
"amqp_TaskQ": "gseps-mq",
|
"amqp_TaskQ": "gseps-mq",
|
||||||
"amqp_ResultQ": "gseps-ResultQ",
|
"amqp_ResultQ": "gseps-ResultQ",
|
||||||
"amqp_message_expire_time": "300000",
|
"amqp_message_expire_time": "300000",
|
||||||
|
"amqp_Q_check_interval": 250,
|
||||||
"Minio_url": "http://13.209.39.139:31191",
|
"Minio_url": "http://13.209.39.139:31191",
|
||||||
"AccessKey":"VV2gooVNevRAIg7HrXQr",
|
"AccessKey":"VV2gooVNevRAIg7HrXQr",
|
||||||
"SecretKey":"epJmFWxwfzUUgYeyDqLa8ouitHZaWTwAvPfPNUBL",
|
"SecretKey":"epJmFWxwfzUUgYeyDqLa8ouitHZaWTwAvPfPNUBL",
|
||||||
|
@ -20,7 +21,7 @@
|
||||||
"points_per_side": 36,
|
"points_per_side": 36,
|
||||||
"pred_iou_thresh": 0.86,
|
"pred_iou_thresh": 0.86,
|
||||||
"stability_score_thresh": 0.9,
|
"stability_score_thresh": 0.9,
|
||||||
"crop_n_layers": 1,
|
"crop_n_layers": 2,
|
||||||
"crop_n_points_downscale_factor": 1,
|
"crop_n_points_downscale_factor": 1,
|
||||||
"box_nms_thresh": 0.8,
|
"box_nms_thresh": 0.8,
|
||||||
"min_mask_region_area": 10,
|
"min_mask_region_area": 10,
|
||||||
|
@ -32,5 +33,6 @@
|
||||||
"remote_server_id": "sdt",
|
"remote_server_id": "sdt",
|
||||||
"remote_server_pw": "251327",
|
"remote_server_pw": "251327",
|
||||||
"copied_image_path_from_remote_server": "/home/sdt/Workspace/gseps/inference/image_bucket",
|
"copied_image_path_from_remote_server": "/home/sdt/Workspace/gseps/inference/image_bucket",
|
||||||
"inference_result_path": "/home/sdt/Workspace/gseps/inference/result/"
|
"inference_result_path": "/home/sdt/Workspace/gseps/inference/result/",
|
||||||
|
"n_bins_for_histogram":20
|
||||||
}
|
}
|
||||||
|
|
49
inference.py
49
inference.py
|
@ -55,8 +55,8 @@ s3 = boto3.resource('s3',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def send_message_to_slack():
|
def send_message_to_slack(message):
|
||||||
data = {"text": info['slack_message']}
|
data = {"text": message}
|
||||||
req = requests.post(
|
req = requests.post(
|
||||||
url=info['slack_url'],
|
url=info['slack_url'],
|
||||||
data=json.dumps(data)
|
data=json.dumps(data)
|
||||||
|
@ -149,6 +149,7 @@ class Consumer:
|
||||||
box_nms_thresh=self.cfg['box_nms_thresh'],
|
box_nms_thresh=self.cfg['box_nms_thresh'],
|
||||||
min_mask_region_area=self.cfg['min_mask_region_area'])
|
min_mask_region_area=self.cfg['min_mask_region_area'])
|
||||||
end = time.time()
|
end = time.time()
|
||||||
|
logger.info(f"Initialize {str(info['model_config'])}")
|
||||||
print(f'Initialize time: {(end - start) // 60}m {(end - start) % 60:4f}s')
|
print(f'Initialize time: {(end - start) // 60}m {(end - start) % 60:4f}s')
|
||||||
|
|
||||||
def image_upload_to_ncp(self, path):
|
def image_upload_to_ncp(self, path):
|
||||||
|
@ -209,6 +210,7 @@ class Consumer:
|
||||||
save_path = info['inference_result_path']
|
save_path = info['inference_result_path']
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
method, properties, body = chan.basic_get(queue=self.__TaskQ,
|
method, properties, body = chan.basic_get(queue=self.__TaskQ,
|
||||||
auto_ack=True)
|
auto_ack=True)
|
||||||
|
|
||||||
|
@ -216,16 +218,16 @@ class Consumer:
|
||||||
|
|
||||||
# if Queue is empty
|
# if Queue is empty
|
||||||
if not method:
|
if not method:
|
||||||
send_message_to_slack()
|
send_message_to_slack("Empty Queue")
|
||||||
logger.info("Empty Queue sleep for 100s")
|
logger.info(f"Empty Queue sleep for {info['amqp_Q_check_interval']}")
|
||||||
time.sleep(100)
|
time.sleep(info['amqp_Q_check_interval'])
|
||||||
|
|
||||||
if method:
|
if method:
|
||||||
logger.info(f" [x] Received {body}")
|
logger.info(f" [x] Received {body}")
|
||||||
Task_data = json.loads(body)
|
Task_data = json.loads(body)
|
||||||
if(Task_data.get("to")):
|
if(Task_data.get("to")):
|
||||||
download_path = os.path.join(os.getcwd(),info['download_data_path'],Task_data['to']['filename'])
|
download_path = os.path.join(os.getcwd(),info['download_data_path'],Task_data['to']['filename'])
|
||||||
s3.Bucket(Task_data['to']['Bucket']).download_file(Task_data['to']['filename'],download_path)
|
s3.Bucket(Task_data['to']['bucket']).download_file(Task_data['to']['filename'],download_path)
|
||||||
else:
|
else:
|
||||||
logger.info("Check Message Data. key 'to' is missing")
|
logger.info("Check Message Data. key 'to' is missing")
|
||||||
continue
|
continue
|
||||||
|
@ -241,18 +243,41 @@ class Consumer:
|
||||||
|
|
||||||
# delete original file
|
# delete original file
|
||||||
os.remove(download_path)
|
os.remove(download_path)
|
||||||
|
logger.info(f" len(sizes) : {len(sizes)}")
|
||||||
|
|
||||||
|
if(len(sizes) < 30):
|
||||||
|
logger.info("PASS")
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
# save reulst image
|
# save reulst image
|
||||||
result_filename = f'result_{image_name}.jpg'
|
result_filename = f'result_{image_name}.jpg'
|
||||||
plt.imsave(os.path.join(save_path, result_filename), result_image)
|
plt.imsave(os.path.join(save_path, result_filename), result_image)
|
||||||
|
|
||||||
|
# calculation for histogram
|
||||||
|
fig, axs = plt.subplots(1,1)
|
||||||
|
n_bins = info['n_bins_for_histogram']
|
||||||
|
xy = axs.hist(sizes, bins=n_bins)
|
||||||
|
print(xy)
|
||||||
|
y = xy[0].astype(np.int32)
|
||||||
|
x = xy[1]
|
||||||
|
hist_y = y.tolist()
|
||||||
|
hist_x = x.tolist()
|
||||||
|
str_x = []
|
||||||
|
for single_x in hist_x:
|
||||||
|
str_x.append(str(single_x))
|
||||||
|
hist_x = str_x.copy()
|
||||||
# message contents set-up
|
# message contents set-up
|
||||||
Task_data['Type']="inference_result"
|
Task_data['type']="inference_result"
|
||||||
Task_data['result']={
|
Task_data['result']={
|
||||||
'timestamp':int(time.time()*1000),
|
'timestamp':int(time.time()*1000),
|
||||||
'count':count,
|
'count':count,
|
||||||
'sizes':sizes,
|
'sizes':sizes,
|
||||||
'filename':result_filename
|
'filename':result_filename,
|
||||||
|
'hist':{
|
||||||
|
'x':hist_x,
|
||||||
|
'y':hist_y
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Task_data['from']=Task_data['to']
|
Task_data['from']=Task_data['to']
|
||||||
Task_data.pop('to',None)
|
Task_data.pop('to',None)
|
||||||
|
@ -262,10 +287,18 @@ class Consumer:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
else:
|
else:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
except Exception as e:
|
||||||
|
print(traceback.format_exc())
|
||||||
|
send_message_to_slack(f"who : inference_server // error {str(e)}")
|
||||||
|
logger.error(str(e))
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
send_message_to_slack(f"who : inference_server // error {str(e)}")
|
||||||
|
logger.error(str(e))
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue