This commit is contained in:
huangtao
2022-07-27 17:55:52 +08:00
parent 7edddd1378
commit 4a15c93caf
5 changed files with 10 additions and 10 deletions

View File

@ -143,7 +143,7 @@ def detect(opt, save_img=False):
s = f"\n{len(list(save_dir.glob('labels/*.txt')))} labels saved to {save_dir / 'labels'}" if save_txt else ''
print(f"Results saved to {save_dir}{s}")
print(f'Done. ({time.time() - t0:.3f}s)')
# print(f'Done. ({time.time() - t0:.3f}s)')
names = ["6925303773908", "6924743915848", "6920152471616", "6920005772716", "6902227018162",
"6920459905012", "6972194461407", "6935284412918", "6921489033706", "6904012526494",
@ -153,7 +153,6 @@ def detect(opt, save_img=False):
targets.append({"Class": names[int(target[5].item())], "precision": target[4].item(), "xy1": [target[0].item(), target[1].item()],
"xy2": [target[2].item(), target[3].item()]})
resu = {"TargetDetect": targets}
print(resu)
return resu

View File

@ -65,7 +65,7 @@ parser.add_argument('--conf-thres', type=float, default=0.70, help='object confi
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('--view-img', type=bool, default=True, help='display results')
parser.add_argument('--save-txt', type=bool, default=True, help='save results to *.txt')
parser.add_argument('--save-txt', type=bool, default=False, help='save results to *.txt')
parser.add_argument('--save-conf', type=bool, default=True, help='save confidences in --save-txt labels')
parser.add_argument('--nosave', type=bool, default=True, help='do not save images/videos')
parser.add_argument('--classes', nargs='+', type=int, help='filter by class: --class 0, or --class 0 2 3')
@ -80,10 +80,10 @@ parser.add_argument('--exist-ok', type=bool, default=True, help='existing projec
opt, unknown = parser.parse_known_args()
@app.route("/zhanting", methods=['POST'])
def get_isempty():
#start = time.time()
start = time.time()
data = request.get_data()
ip = request.remote_addr
print('------ ip = %s ------' % ip)
logger.info(f"client ip:{ip}")
json_data = json.loads(data.decode("utf-8"))
# getdateend = time.time()
@ -95,7 +95,7 @@ def get_isempty():
}
try:
imgdata = base64.b64decode(pic)
#image_path = 'data/images/1.jpg'
#image_path = 'imgs/1.jpg'
image_path = '../module/ieemoo-ai-zhanting/imgs/1.jpg'
file = open(image_path, 'wb')
file.write(imgdata)
@ -112,6 +112,7 @@ def get_isempty():
pred = detect.detect(opt)
logger.info(pred)
Obs(image_path)
logger.info("all time:%.3fs" % (time.time() - start))
#print('pred', pred)
#getdateend = time.time()
#now_time = datetime.datetime.now()
@ -126,6 +127,6 @@ def get_isempty():
if __name__ == "__main__":
app.run(host='192.168.1.142', port=8000)
app.run(host='192.168.1.142', port=8009)
#http_server = WSGIServer(('0.0.0.0', 8000), app)
#http_server.serve_forever()

View File

@ -24,7 +24,7 @@ def caculate_label_numble(file_path):
if __name__=="__main__":
file_path = "paper_data/Annotations"
file_path = r"D:\PycharmProjects\ieemoo-ai-pack\paper_data\Annotations"
label_numble_info = caculate_label_numble(file_path)
for key, value in label_numble_info.items():
print('{}:{}'.format(key, value))

View File

@ -165,7 +165,7 @@ class Model(nn.Module):
# print('%10.3g' % (m.w.detach().sigmoid() * 2)) # shortcut weights
def fuse(self): # fuse model Conv2d() + BatchNorm2d() layers
print('Fusing layers... ')
# print('Fusing layers... ')
for m in self.model.modules():
if type(m) is Conv and hasattr(m, 'bn'):
m.conv = fuse_conv_and_bn(m.conv, m.bn) # update conv

View File

@ -191,7 +191,7 @@ class LoadImages: # for inference
# cv2.imshow("mask", img0)
# cv2.waitKey(0)
assert img0 is not None, 'Image Not Found ' + path
print(f'image {self.count}/{self.nf} {path}: ', end='')
# print(f'image {self.count}/{self.nf} {path}: ', end='')
# Padded resize
img = letterbox(img0, self.img_size, stride=self.stride)[0]