乱扔垃圾监控识别系统 YOLOX

乱扔垃圾监控识别系统利用人工智能技术,乱扔垃圾监控识别系统对城市垃圾站、小区、公共场所等区域的垃圾桶进行实时监控的智能系统。系统通过安装在各处的摄像头,对监控视频进行实时分析,能够侦测垃圾桶的异常情况,如有人乱扔垃圾或垃圾桶溢满等,并进行识别与告警。通过及时发现和处理乱扔垃圾行为,有助于维护城市的整洁和美观。系统的告警机制有助于促进居民进行垃圾分类,提高垃圾分类的准确性。

YOLOX在YOLO系列的基础上做了一系列的工作,其主要贡献在于:在YOLOv3的基础上,引入了Decoupled Head,Data Aug,Anchor Free和SimOTA样本匹配的方法,构建了一种anchor-free的端到端目标检测框架,并且达到了一流的检测水平。此外,本文提出的 YOLOX-L 模型在视频感知挑战赛(CVPR 2021年自动驾驶研讨会)上获得了第一名。作者还提供了支持ONNX、TensorRT、NCNN和Openvino的部署版本。

Yolox 将 Anchor free 的方式引入到Yolo系列中,使用anchor free方法有如下好处:

降低了计算量,不涉及IoU计算,另外产生的预测框数量较少。
        假设feature map的尺度为80x80,anchor based方法在Feature Map上,每个单元格一般设置三个不同尺寸大小的锚框,因此产生3x80x80=19200个预测框。而使用anchor free的方法,仅产生80x80=6400个预测框,降低了计算量。

缓解了正负样本不平衡问题
        anchor free方法的预测框只有anchor based方法的1/3,而预测框中大部分是负样本,因此anchor free方法可以减少负样本数,进一步缓解了正负样本不平衡问题。

避免了anchor的调参
        anchor based方法的anchor box的尺度是一个超参数,不同的超参数设置会影响模型性能。anchor free方法避免了这一点。

在现代社会,随着城市化进程的加快,城市环境卫生问题日益凸显。乱扔垃圾不仅影响市容市貌,还可能对生态环境造成严重破坏。为了解决这一问题,基于OpenCV-AI视觉算法的乱扔垃圾监控识别系统应运而生。本文将详细介绍这一系统的功能、技术基础以及它在城市环境卫生管理中的作用。OpenCV是一个开源的计算机视觉和机器学习软件库,广泛应用于图像处理和视频分析。系统基于OpenCV-AI视觉算法,通过深度学习模型对监控视频中的图像进行分析,识别出乱扔垃圾的行为和垃圾桶的状态。

class Detect(nn.Module):
    stride = None  # strides computed during build
    onnx_dynamic = False  # ONNX export parameter

    def __init__(self, nc=80, anchors=(), ch=(), inplace=True):  # detection layer
        super().__init__()
        self.nc = nc  # number of classes
        self.no = nc + 5  # number of outputs per anchor
        self.nl = len(anchors)  # number of detection layers
        self.na = len(anchors[0]) // 2  # number of anchors
        self.grid = [torch.zeros(1)] * self.nl  # init grid
        self.anchor_grid = [torch.zeros(1)] * self.nl  # init anchor grid
        self.register_buffer('anchors', torch.tensor(anchors).float().view(self.nl, -1, 2))  # shape(nl,na,2)
        self.m = nn.ModuleList(nn.Conv2d(x, self.no * self.na, 1) for x in ch)  # output conv
        self.inplace = inplace  # use in-place ops (e.g. slice assignment)

    def forward(self, x):
        z = []  # inference output
        for i in range(self.nl):
            x[i] = self.m[i](x[i])  # conv
            bs, _, ny, nx = x[i].shape  # x(bs,255,20,20) to x(bs,3,20,20,85)
            x[i] = x[i].view(bs, self.na, self.no, ny, nx).permute(0, 1, 3, 4, 2).contiguous()

            if not self.training:  # inference
                if self.onnx_dynamic or self.grid[i].shape[2:4] != x[i].shape[2:4]:
                    self.grid[i], self.anchor_grid[i] = self._make_grid(nx, ny, i)

                y = x[i].sigmoid()
                if self.inplace:
                    y[..., 0:2] = (y[..., 0:2] * 2 - 0.5 + self.grid[i]) * self.stride[i]  # xy
                    y[..., 2:4] = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i]  # wh
                else:  # for YOLOv5 on AWS Inferentia https://github.com/ultralytics/yolov5/pull/2953
                    xy = (y[..., 0:2] * 2 - 0.5 + self.grid[i]) * self.stride[i]  # xy
                    wh = (y[..., 2:4] * 2) ** 2 * self.anchor_grid[i]  # wh
                    y = torch.cat((xy, wh, y[..., 4:]), -1)
                z.append(y.view(bs, -1, self.no))

        return x if self.training else (torch.cat(z, 1), x)

    def _make_grid(self, nx=20, ny=20, i=0):
        d = self.anchors[i].device
        if check_version(torch.__version__, '1.10.0'):  # torch>=1.10.0 meshgrid workaround for torch>=0.7 compatibility
            yv, xv = torch.meshgrid([torch.arange(ny).to(d), torch.arange(nx).to(d)], indexing='ij')
        else:
            yv, xv = torch.meshgrid([torch.arange(ny).to(d), torch.arange(nx).to(d)])
        grid = torch.stack((xv, yv), 2).expand((1, self.na, ny, nx, 2)).float()
        anchor_grid = (self.anchors[i].clone() * self.stride[i]) \
            .view((1, self.na, 1, 1, 2)).expand((1, self.na, ny, nx, 2)).float()
        return grid, anchor_grid


乱扔垃圾监控识别系统是AI技术在城市环境卫生管理领域的创新应用。乱扔垃圾监控识别系统不仅提高了环卫工作的智能化水平,还为城市市容市貌的提升和居民生活环境的改善做出了贡献。乱扔垃圾监控识别系统作为这一技术应用的典范,展示了AI在现代城市管理中的重要作用和价值。乱扔垃圾监控识别系统的实施,使得环卫工作更加智能化,提高了环卫工作的效率。

猜你喜欢

转载自blog.csdn.net/SuiJiAi/article/details/143577764