update
This commit is contained in:
@ -40,7 +40,7 @@ parser = argparse.ArgumentParser()
|
|||||||
parser.add_argument('--weights', nargs='+', type=str, default='../module/ieemoo-ai-zhanting/model/now/best.pt', help='model.pt path(s)')
|
parser.add_argument('--weights', nargs='+', type=str, default='../module/ieemoo-ai-zhanting/model/now/best.pt', help='model.pt path(s)')
|
||||||
parser.add_argument('--source', type=str, default='../module/ieemoo-ai-zhanting/imgs/1.jpg', help='source') # file/folder, 0 for webcam
|
parser.add_argument('--source', type=str, default='../module/ieemoo-ai-zhanting/imgs/1.jpg', help='source') # file/folder, 0 for webcam
|
||||||
parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
|
parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
|
||||||
parser.add_argument('--conf-thres', type=float, default=0.50, help='object confidence threshold')
|
parser.add_argument('--conf-thres', type=float, default=0.60, help='object confidence threshold')
|
||||||
parser.add_argument('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS')
|
parser.add_argument('--iou-thres', type=float, default=0.45, help='IOU threshold for NMS')
|
||||||
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
|
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
|
||||||
parser.add_argument('--view-img', type=bool, default=True, help='display results')
|
parser.add_argument('--view-img', type=bool, default=True, help='display results')
|
||||||
@ -59,41 +59,34 @@ parser.add_argument('--exist-ok', type=bool, default=True, help='existing projec
|
|||||||
opt, unknown = parser.parse_known_args()
|
opt, unknown = parser.parse_known_args()
|
||||||
@app.route("/zhanting", methods=['POST'])
|
@app.route("/zhanting", methods=['POST'])
|
||||||
def get_isempty():
|
def get_isempty():
|
||||||
#start = time.time()
|
|
||||||
data = request.get_data()
|
data = request.get_data()
|
||||||
ip = request.remote_addr
|
ip = request.remote_addr
|
||||||
print('------ ip = %s ------' % ip)
|
print('------ ip = %s ------' % ip)
|
||||||
|
|
||||||
json_data = json.loads(data.decode("utf-8"))
|
json_data = json.loads(data.decode("utf-8"))
|
||||||
# getdateend = time.time()
|
|
||||||
# print('get date use time: {0:.2f}s'.format(getdateend - start))
|
|
||||||
|
|
||||||
pic = json_data.get("pic")
|
pic = json_data.get("pic")
|
||||||
result = {"success": "false",
|
result = {"success": "false",
|
||||||
"rst_cls": '-1',
|
"rst_cls": '-1',
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
imgdata = base64.b64decode(pic)
|
imgdata = base64.b64decode(pic)
|
||||||
#image_path = 'data/images/1.jpg'
|
|
||||||
image_path = '../module/ieemoo-ai-zhanting/imgs/1.jpg'
|
image_path = '../module/ieemoo-ai-zhanting/imgs/1.jpg'
|
||||||
file = open(image_path, 'wb')
|
file = open(image_path, 'wb')
|
||||||
file.write(imgdata)
|
file.write(imgdata)
|
||||||
|
img = cv2.imread(image_path)
|
||||||
|
site = np.array([[[0, 1024], [0, 571], [313, 365], [949, 367], [1277, 596], [1280, 1024]]], dtype=np.int32)
|
||||||
|
im = np.zeros(img.shape[:2], dtype="uint8")
|
||||||
|
cv2.polylines(im, site, 1, 255)
|
||||||
|
cv2.fillPoly(im, site, 255)
|
||||||
|
mask = im
|
||||||
|
masked = cv2.bitwise_or(img, img, mask=mask)
|
||||||
|
img0 = masked
|
||||||
|
cv2.imwrite("../module/ieemoo-ai-zhanting/imgs/1.jpg",img0)
|
||||||
pred = detect.detect(opt)
|
pred = detect.detect(opt)
|
||||||
logger.info(pred)
|
logger.info(pred)
|
||||||
#print('pred', pred)
|
|
||||||
#getdateend = time.time()
|
|
||||||
#now_time = datetime.datetime.now()
|
|
||||||
#print('now_time', now_time)
|
|
||||||
#print('get date use time: {0:.2f}s'.format(getdateend - start))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(e)
|
logger.warning(e)
|
||||||
return pred
|
return pred
|
||||||
|
|
||||||
return pred
|
return pred
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host='192.168.1.142', port=8000)
|
app.run(host='192.168.1.142', port=8000)
|
||||||
#http_server = WSGIServer(('0.0.0.0', 8000), app)
|
|
||||||
#http_server.serve_forever()
|
|
||||||
|
Reference in New Issue
Block a user