“其实一开始并没有想学深度学习”
! pip install --upgrade pip
! pip install paddlex
! pip install --user --upgrade pyarrow==11.0.0
# 配置环境
train_list格式(test同理):图片路径+\t+标签
newLabels格式:标签
训练代码
import paddlex as pdxfrom paddlex import transforms as Ttrain_transforms = T.Compose([T.RandomCrop(crop_size=224), T.RandomHorizontalFlip(), T.Normalize()])eval_transforms = T.Compose([T.ResizeByShort(short_size=256), T.CenterCrop(crop_size=224), T.Normalize()
])
# 定义数据集的transformtrain_dataset = pdx.datasets.ImageNet(data_dir='train',file_list='train_list.txt',label_list='newLabels.txt',transforms=train_transforms,shuffle=True)eval_dataset = pdx.datasets.ImageNet(data_dir='train',file_list='val_list.txt',label_list='newLabels.txt',transforms=eval_transforms)
# 定义数据集num_classes = len(train_dataset.labels)
model = pdx.cls.MobileNetV3_large_ssld(num_classes=num_classes)
model.train(num_epochs=6, # 训练轮次train_dataset=train_dataset, #训练集train_batch_size=32,# 训练batcheval_dataset=eval_dataset, #测试集lr_decay_epochs=[2, 4],# 学习率变化轮次save_interval_epochs=2, # 保存模型轮次learning_rate=0.00125,# 起始学习率save_dir='output/mobilenetv3_large_ssld3',# 保存模型目录use_vdl=True)
# 开始训练