当前位置: 首页 > news >正文

Python+Django+Yolov5路面墙体桥梁裂缝特征检测识别html网页前后端

程序示例精选
Python+Django+Yolov5路面墙体桥梁裂缝特征检测识别html网页前后端
如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助!

前言

这篇博客针对《Python+Django+Yolov5路面墙体桥梁裂缝特征检测识别html网页前后端》编写代码,代码整洁,规则,易读。 学习与应用推荐首选。


运行结果


文章目录

一、所需工具软件
二、使用步骤
       1. 主要代码
       2. 运行结果
三、在线协助

一、所需工具软件

       1. Python
       2. Django, Yolov5, Pycharm

二、使用步骤

代码如下(示例):

def detect(save_img=False):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_ok=opt.exist_ok))  # increment run(save_dir / 'labels' if save_txt else save_dir).mkdir(parents=True, exist_ok=True)  # 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_location=device)  # load FP32 modelstride = int(model.stride.max())  # model strideimgsz = check_img_size(imgsz, s=stride)  # check img_sizeif half:model.half()  # to FP16# Second-stage classifierclassify = Falseif classify:modelc = load_classifier(name='resnet101', n=2)  # initializemodelc.load_state_dict(torch.load('weights/resnet101.pt', map_location=device)['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_size=imgsz, stride=stride)else:save_img = Truedataset = LoadImages(source, img_size=imgsz, stride=stride)# 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, augment=opt.augment)[0]# Apply NMSpred = non_max_suppression(pred, opt.conf_thres, opt.iou_thres, classes=opt.classes, agnostic=opt.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, label=label, color=colors[int(cls)], line_thickness=3)# 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:  # 'video'if 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(f"Results saved to {save_dir}{s}")print(f'Done. ({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)远程安装运行环境,代码调试
2)Visual Studio, Qt, C++, Python编程语言入门指导
3)界面美化
4)软件制作
5)云服务器申请
6)网站制作

当前文章连接:https://blog.csdn.net/alicema1111/article/details/132666851
个人博客主页:https://blog.csdn.net/alicema1111?type=blog
博主所有文章点这里:https://blog.csdn.net/alicema1111?type=blog

博主推荐:
Python人脸识别考勤打卡系统:
https://blog.csdn.net/alicema1111/article/details/133434445
Python果树水果识别:https://blog.csdn.net/alicema1111/article/details/130862842
Python+Yolov8+Deepsort入口人流量统计:https://blog.csdn.net/alicema1111/article/details/130454430
Python+Qt人脸识别门禁管理系统:https://blog.csdn.net/alicema1111/article/details/130353433
Python+Qt指纹录入识别考勤系统:https://blog.csdn.net/alicema1111/article/details/129338432
Python Yolov5火焰烟雾识别源码分享:https://blog.csdn.net/alicema1111/article/details/128420453
Python+Yolov8路面桥梁墙体裂缝识别:https://blog.csdn.net/alicema1111/article/details/133434445

相关文章:

  • Java设计模式—备忘录模式(快照模式)
  • 【问题分析】InputDispatcher无焦点窗口ANR问题【Android 14】
  • 探索SOCKS5代理、代理IP、HTTP与网络安全
  • C++:sizeof关键字(7)
  • 【论文阅读】ELA: Efficient Local Attention for Deep Convolutional Neural Networks
  • Linux基础篇:解析Linux命令执行的基本原理
  • 淘宝商品采集API商品详情数据接口商品搜索列表API接口
  • 括号生成(回溯+剪枝)
  • ip地址改变导致nacos无法登录的解决方法
  • 查询优化-提升子查询-UNION类型
  • 国内IP切换软件:解锁网络世界的新钥匙
  • 【八大排序】一篇文章搞定所有排序
  • 企业系统对接必知事项-请您查收
  • vmware,linux,centos7,NAT模式下的网络配置
  • 定义类强化——移动的圆
  • IE9 : DOM Exception: INVALID_CHARACTER_ERR (5)
  • 《Java编程思想》读书笔记-对象导论
  • 《深入 React 技术栈》
  • Asm.js的简单介绍
  • ECS应用管理最佳实践
  • el-input获取焦点 input输入框为空时高亮 el-input值非法时
  • iOS编译提示和导航提示
  • JavaScript/HTML5图表开发工具JavaScript Charts v3.19.6发布【附下载】
  • JavaScript新鲜事·第5期
  • ucore操作系统实验笔记 - 重新理解中断
  • 基于Javascript, Springboot的管理系统报表查询页面代码设计
  • 容器服务kubernetes弹性伸缩高级用法
  • 如何抓住下一波零售风口?看RPA玩转零售自动化
  • 深入浏览器事件循环的本质
  • 携程小程序初体验
  • 翻译 | The Principles of OOD 面向对象设计原则
  • 继 XDL 之后,阿里妈妈开源大规模分布式图表征学习框架 Euler ...
  • #Linux(make工具和makefile文件以及makefile语法)
  • (2)STM32单片机上位机
  • (超详细)2-YOLOV5改进-添加SimAM注意力机制
  • (二)Eureka服务搭建,服务注册,服务发现
  • (附源码)springboot车辆管理系统 毕业设计 031034
  • (附源码)基于ssm的模具配件账单管理系统 毕业设计 081848
  • (力扣题库)跳跃游戏II(c++)
  • (五) 一起学 Unix 环境高级编程 (APUE) 之 进程环境
  • (学习日记)2024.03.12:UCOSIII第十四节:时基列表
  • (一)Neo4j下载安装以及初次使用
  • (原創) 如何讓IE7按第二次Ctrl + Tab時,回到原來的索引標籤? (Web) (IE) (OS) (Windows)...
  • (转)scrum常见工具列表
  • .[hudsonL@cock.li].mkp勒索病毒数据怎么处理|数据解密恢复
  • .NET Core Web APi类库如何内嵌运行?
  • .NET Core引入性能分析引导优化
  • .Net各种迷惑命名解释
  • .net专家(张羿专栏)
  • /usr/local/nginx/logs/nginx.pid failed (2: No such file or directory)
  • @Autowired多个相同类型bean装配问题
  • @Import注解详解
  • @RestController注解的使用
  • [2019.3.20]BZOJ4573 [Zjoi2016]大森林
  • [AIGC codze] Kafka 的 rebalance 机制