当前位置:   article > 正文

YOLOV8对于classify分类任务更换resnet18主干网络

YOLOV8对于classify分类任务更换resnet18主干网络

1. 先定义残差18模块的网络

  1. class Resnet18(nn.Module):
  2. def __init__(self):
  3. super().__init__()
  4. model = models.resnet18(pretrained=True)
  5. self.layer=nn.Sequential(
  6. model.conv1,
  7. model.bn1,
  8. model.relu,
  9. model.maxpool,
  10. model.layer1,
  11. model.layer2,
  12. model.layer3,
  13. model.layer4,
  14. model.avgpool
  15. )
  16. def forward(self, x):
  17. x=self.layer(x)
  18. return x

添加到conv.py末尾

注册模块

 2.task.py更改

3.更改Yaml文件 

  1. # Ultralytics YOLO
    声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小桥流水78/article/detail/992208
    推荐阅读
    相关标签