YOLOV5 改进:替换backbone为MobileVIT

avatar
作者
猴君
阅读量:0

1. 介绍

yolov5替换主干网络的步骤如下,依旧和之前的一样

2. 更改common文件

将下面代码加入common最下面即可:

from einops import rearrange import torch import torch.nn as nn  # Transformer Attention模块定义 class TAttention(nn.Module):     def __init__(self, dim, heads=8, dim_head=64, dropout=0.):         super().__init__()          inner_dim = dim_head * heads         project_out = not (heads == 1 and dim_head == dim)          self.heads = heads         self.scale = dim_head ** -0.5          self.attend = nn.Softmax(dim=-1)         self.to_qkv = nn.Linear(dim, inner_dim * 3, bias=False)          self.to_out = nn.Sequential(             nn.Linear(inner_dim, dim),             nn.Dropout(dropout)         ) if project_out else nn.Identity()      def forward(

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!