YOLOv7目标检测-网络结构1-网络结构配置文件解读

models/yolo.py

打开models文件夹,
yolo.py文件夹中是核心的大组件,common.py中是小的组件。
结合cfg/training当中的yolov7.yaml配置文件看网络结构。

    def forward_once(self, x, profile=False):
        y, dt = [], []  # outputs
        for m in self.model:    # model是根据配置文件生成的,m就是走每一层
            if m.f != -1:  # if not from previous layer
                x = y[m.f] if isinstance(m.f, int) else [x if j == -1 else y[j] for j in m.f]  # from earlier layers

            if not hasattr(self, 'traced'):
                self.traced=False

            if self.traced:
                if isinstance(m, Detect) or isinstance(m, IDetect) or isinstance(m, IAuxDetect) or isinstance(m, IKeypoint):
                    break

            if profile:
                c = isinstance(m, (Detect, IDetect, IAuxDetect, IBin))
                o = thop.profile(m, inputs=(x.copy() if c else x,), verbose=False)[0] / 1E9 * 2 if thop else 0  # FLOPS
                for _ in range(10):
                    m(x.copy() if c else x)
                t = time_synchronized()
                for _ in range(10):
                    m(x.copy() if c else x)
                dt.append((time_synchronized() - t) * 100)
                print('%10.1f%10.0f%10.1fms %-40s' % (o, m.np, dt[-1], m.type))

            x = m(x)  # run,x得到的特征图
            
            y.append(x if m.i in self.save else None)  # save output

        if profile:
            print('%.1fms total' % sum(dt))
        return x

yolov7.yaml配置文件

结合cfg/training当中的yolov7.yaml配置文件看网络结构。
首先是backbone提取特征的模块,head是输出的模块。

from指的是前面接哪一层,这一层的输入是第多少层的输出,-1表示上一层,-2表示上两层。
number指这一层重复几次。
module该模块做什么。
args参数中是特征图的个数,卷积大小,stride步长。
p几相当于在下采样过程中特征图是原来的几分之一。
并且注释了层数。
在这里插入图片描述
在这里插入图片描述
第一列75、88、101指的是第75、88、101层。

concat拼接层
在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/ThreeS_tones/article/details/129811155