海关总署2018年海关网站建设,巩义做网站汉狮网络,网站开发分哪几个步骤,网络营销的特点及优势程序示例精选 PythonDjangoHtml人脸识别考勤打卡系统 如需安装运行环境或远程调试#xff0c;见文章底部个人QQ名片#xff0c;由专业技术人员远程协助#xff01; 前言
这篇博客针对《PythonDjangoHtml网页版人脸识别考勤打卡系统》编写代码#xff0c;代码整洁#xf… 程序示例精选 PythonDjangoHtml人脸识别考勤打卡系统 如需安装运行环境或远程调试见文章底部个人QQ名片由专业技术人员远程协助 前言
这篇博客针对《PythonDjangoHtml网页版人脸识别考勤打卡系统》编写代码代码整洁规则易读。 学习与应用推荐首选。 运行结果 文章目录
一、所需工具软件 二、使用步骤 1. 主要代码 2. 运行结果 三、在线协助
一、所需工具软件 1. Python 2. Pycharm
二、使用步骤
代码如下示例
def detect(save_imgFalse):source, weights, view_img, save_txt, imgsz opt.source, opt.weights, opt.view_img, opt.save_txt, opt.img_sizewebcam source.isnumeric() or source.endswith(.txt) or source.lower().startswith((rtsp://, rtmp://, http://))# Directoriessave_dir Path(increment_path(Path(opt.project) / opt.name, exist_okopt.exist_ok)) # increment run(save_dir / labels if save_txt else save_dir).mkdir(parentsTrue, exist_okTrue) # make dir# Initializeset_logging()device select_device(opt.device)half device.type ! cpu # half precision only supported on CUDA# Load modelmodel attempt_load(weights, map_locationdevice) # load FP32 modelstride int(model.stride.max()) # model strideimgsz check_img_size(imgsz, sstride) # check img_sizeif half:model.half() # to FP16# Second-stage classifierclassify Falseif classify:modelc load_classifier(nameresnet101, n2) # initializemodelc.load_state_dict(torch.load(weights/resnet101.pt, map_locationdevice)[model]).to(device).eval()# Set Dataloadervid_path, vid_writer None, Noneif webcam:view_img check_imshow()cudnn.benchmark True # set True to speed up constant image size inferencedataset LoadStreams(source, img_sizeimgsz, stridestride)else:save_img Truedataset LoadImages(source, img_sizeimgsz, stridestride)# Get names and colorsnames model.module.names if hasattr(model, module) else model.namescolors [[random.randint(0, 255) for _ in range(3)] for _ in names]# Run inferenceif device.type ! cpu:model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run oncet0 time.time()for path, img, im0s, vid_cap in dataset:img torch.from_numpy(img).to(device)img img.half() if half else img.float() # uint8 to fp16/32img / 255.0 # 0 - 255 to 0.0 - 1.0if img.ndimension() 3:img img.unsqueeze(0)# Inferencet1 time_synchronized()pred model(img, augmentopt.augment)[0]# Apply NMSpred non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classesopt.classes, agnosticopt.agnostic_nms)t2 time_synchronized()# Apply Classifierif classify:pred apply_classifier(pred, modelc, img, im0s)# Process detectionsfor i, det in enumerate(pred): # detections per imageif webcam: # batch_size 1p, s, im0, frame path[i], %g: % i, im0s[i].copy(), dataset.countelse:p, s, im0, frame path, , im0s, getattr(dataset, frame, 0)p Path(p) # to Pathsave_path str(save_dir / p.name) # img.jpgtxt_path str(save_dir / labels / p.stem) ( if dataset.mode image else f_{frame}) # img.txts %gx%g % img.shape[2:] # print stringgn torch.tensor(im0.shape)[[1, 0, 1, 0]] # normalization gain whwhif len(det):# Rescale boxes from img_size to im0 sizedet[:, :4] scale_coords(img.shape[2:], det[:, :4], im0.shape).round()# Write resultsfor *xyxy, conf, cls in reversed(det):if save_txt: # Write to filexywh (xyxy2xywh(torch.tensor(xyxy).view(1, 4)) / gn).view(-1).tolist() # normalized xywhline (cls, *xywh, conf) if opt.save_conf else (cls, *xywh) # label formatwith open(txt_path .txt, a) as f:f.write((%g * len(line)).rstrip() % line \n)if save_img or view_img: # Add bbox to imagelabel f{names[int(cls)]} {conf:.2f}plot_one_box(xyxy, im0, labellabel, colorcolors[int(cls)], line_thickness3)# Print time (inference NMS)print(f{s}Done. ({t2 - t1:.3f}s))# Save results (image with detections)if save_img:if dataset.mode image:cv2.imwrite(save_path, im0)else: # videoif vid_path ! save_path: # new videovid_path save_pathif isinstance(vid_writer, cv2.VideoWriter):vid_writer.release() # release previous video writerfourcc mp4v # output video codecfps vid_cap.get(cv2.CAP_PROP_FPS)w int(vid_cap.get(cv2.CAP_PROP_FRAME_WIDTH))h int(vid_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))vid_writer cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc(*fourcc), fps, (w, h))vid_writer.write(im0)if save_txt or save_img:s f\n{len(list(save_dir.glob(labels/*.txt)))} labels saved to {save_dir / labels} if save_txt else print(fResults saved to {save_dir}{s})print(fDone. ({time.time() - t0:.3f}s))print(opt)check_requirements()with torch.no_grad():if opt.update: # update all models (to fix SourceChangeWarning)for opt.weights in [yolov5s.pt, yolov5m.pt, yolov5l.pt, yolov5x.pt]:detect()strip_optimizer(opt.weights)else:detect()
运行结果 三、在线协助
如需安装运行环境或远程调试见文章底部个人 QQ 名片由专业技术人员远程协助 1远程安装运行环境代码调试 2Visual Studio, Qt, C, Python编程语言入门指导 3界面美化 4软件制作 5云服务器申请 6网站制作 当前文章连接https://blog.csdn.net/alicema1111/article/details/132666851 个人博客主页https://blog.csdn.net/alicema1111?typeblog 博主所有文章点这里https://blog.csdn.net/alicema1111?typeblog
博主推荐 Python人脸识别考勤打卡系统 https://blog.csdn.net/alicema1111/article/details/133434445 Python果树水果识别https://blog.csdn.net/alicema1111/article/details/130862842 PythonYolov8Deepsort入口人流量统计https://blog.csdn.net/alicema1111/article/details/130454430 PythonQt人脸识别门禁管理系统https://blog.csdn.net/alicema1111/article/details/130353433 PythonQt指纹录入识别考勤系统https://blog.csdn.net/alicema1111/article/details/129338432 Python Yolov5火焰烟雾识别源码分享https://blog.csdn.net/alicema1111/article/details/128420453 PythonYolov8路面桥梁墙体裂缝识别https://blog.csdn.net/alicema1111/article/details/133434445 PythonYolov5道路障碍物识别https://blog.csdn.net/alicema1111/article/details/129589741 PythonYolov5人物目标行为 人体特征识别https://blog.csdn.net/alicema1111/article/details/129272048 文章转载自: http://www.morning.hwnnh.cn.gov.cn.hwnnh.cn http://www.morning.dmwjl.cn.gov.cn.dmwjl.cn http://www.morning.wsyst.cn.gov.cn.wsyst.cn http://www.morning.ncwgt.cn.gov.cn.ncwgt.cn http://www.morning.wlstn.cn.gov.cn.wlstn.cn http://www.morning.nmhpq.cn.gov.cn.nmhpq.cn http://www.morning.snktp.cn.gov.cn.snktp.cn http://www.morning.gtbjc.cn.gov.cn.gtbjc.cn http://www.morning.gsksm.cn.gov.cn.gsksm.cn http://www.morning.rjynd.cn.gov.cn.rjynd.cn http://www.morning.jqtb.cn.gov.cn.jqtb.cn http://www.morning.kclkb.cn.gov.cn.kclkb.cn http://www.morning.rzcfg.cn.gov.cn.rzcfg.cn http://www.morning.gcqs.cn.gov.cn.gcqs.cn http://www.morning.yhwyh.cn.gov.cn.yhwyh.cn http://www.morning.dqrhz.cn.gov.cn.dqrhz.cn http://www.morning.fhykt.cn.gov.cn.fhykt.cn http://www.morning.wrkcw.cn.gov.cn.wrkcw.cn http://www.morning.tlnbg.cn.gov.cn.tlnbg.cn http://www.morning.yuanshenglan.com.gov.cn.yuanshenglan.com http://www.morning.gbsby.cn.gov.cn.gbsby.cn http://www.morning.tkrwm.cn.gov.cn.tkrwm.cn http://www.morning.fwnyz.cn.gov.cn.fwnyz.cn http://www.morning.pwdgy.cn.gov.cn.pwdgy.cn http://www.morning.txfzt.cn.gov.cn.txfzt.cn http://www.morning.xinyishufa.cn.gov.cn.xinyishufa.cn http://www.morning.qytpt.cn.gov.cn.qytpt.cn http://www.morning.qjsxf.cn.gov.cn.qjsxf.cn http://www.morning.txysr.cn.gov.cn.txysr.cn http://www.morning.hpggl.cn.gov.cn.hpggl.cn http://www.morning.qxlgt.cn.gov.cn.qxlgt.cn http://www.morning.tntbs.cn.gov.cn.tntbs.cn http://www.morning.qrlsy.cn.gov.cn.qrlsy.cn http://www.morning.bkcnq.cn.gov.cn.bkcnq.cn http://www.morning.krdxz.cn.gov.cn.krdxz.cn http://www.morning.hkcjx.cn.gov.cn.hkcjx.cn http://www.morning.wjtwn.cn.gov.cn.wjtwn.cn http://www.morning.fssjw.cn.gov.cn.fssjw.cn http://www.morning.qnpyz.cn.gov.cn.qnpyz.cn http://www.morning.lzqdl.cn.gov.cn.lzqdl.cn http://www.morning.kzhgy.cn.gov.cn.kzhgy.cn http://www.morning.schwr.cn.gov.cn.schwr.cn http://www.morning.hpnhl.cn.gov.cn.hpnhl.cn http://www.morning.pqktp.cn.gov.cn.pqktp.cn http://www.morning.rrqbm.cn.gov.cn.rrqbm.cn http://www.morning.qcztm.cn.gov.cn.qcztm.cn http://www.morning.ljdhj.cn.gov.cn.ljdhj.cn http://www.morning.pftjj.cn.gov.cn.pftjj.cn http://www.morning.ybgyz.cn.gov.cn.ybgyz.cn http://www.morning.zlxkp.cn.gov.cn.zlxkp.cn http://www.morning.rcyrm.cn.gov.cn.rcyrm.cn http://www.morning.ntyks.cn.gov.cn.ntyks.cn http://www.morning.cczzyy.com.gov.cn.cczzyy.com http://www.morning.srsln.cn.gov.cn.srsln.cn http://www.morning.ebpz.cn.gov.cn.ebpz.cn http://www.morning.leboju.com.gov.cn.leboju.com http://www.morning.lqjlg.cn.gov.cn.lqjlg.cn http://www.morning.fpryg.cn.gov.cn.fpryg.cn http://www.morning.qphgp.cn.gov.cn.qphgp.cn http://www.morning.gpxbc.cn.gov.cn.gpxbc.cn http://www.morning.fphbz.cn.gov.cn.fphbz.cn http://www.morning.jwqqd.cn.gov.cn.jwqqd.cn http://www.morning.dndjx.cn.gov.cn.dndjx.cn http://www.morning.rfwrn.cn.gov.cn.rfwrn.cn http://www.morning.pmxw.cn.gov.cn.pmxw.cn http://www.morning.sxwfx.cn.gov.cn.sxwfx.cn http://www.morning.nypgb.cn.gov.cn.nypgb.cn http://www.morning.mhcft.cn.gov.cn.mhcft.cn http://www.morning.lyldhg.cn.gov.cn.lyldhg.cn http://www.morning.flncd.cn.gov.cn.flncd.cn http://www.morning.kbbmj.cn.gov.cn.kbbmj.cn http://www.morning.beeice.com.gov.cn.beeice.com http://www.morning.qcfgd.cn.gov.cn.qcfgd.cn http://www.morning.rfkyb.cn.gov.cn.rfkyb.cn http://www.morning.hwnqg.cn.gov.cn.hwnqg.cn http://www.morning.lbbgf.cn.gov.cn.lbbgf.cn http://www.morning.khxyx.cn.gov.cn.khxyx.cn http://www.morning.buyid.com.cn.gov.cn.buyid.com.cn http://www.morning.gthc.cn.gov.cn.gthc.cn http://www.morning.kehejia.com.gov.cn.kehejia.com