当前位置:网站首页>ncnn 推理猫狗识别

ncnn 推理猫狗识别

2022-08-09 07:50:00 HySmiley

实现流程:

一、训练模型

准备数据集,编辑代码进行训练。下载内容在文章末尾。

import torch
import torch.nn as nn
import torchvision.models as models
from torchvision import datasets, transforms
from torch.autograd import Variable
import torch.optim as optim
import os
from trainlog import acc_lossHistory
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
 
class resnet18(nn.Module):
    def __init__(self, num_classes=2):
        super(resnet18, self).__init__()
        net = models.resnet18(pretrained=True)
        # net.classifier = nn.Sequential()
        net.fc=nn.Sequential()
        self.features = net
        self.fc = nn.Sequential(
            nn.Line
原网站

版权声明
本文为[HySmiley]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_37264397/article/details/123807040