“其实一开始并没有想学深度学习”
! pip install --upgrade pip
! pip install paddlex
! pip install --user --upgrade pyarrow==11.0.0
# 配置环境
train_list格式(test同理):图片路径+\t+标签
newLabels格式:标签文章来源:https://www.toymoban.com/news/detail-852382.html
文章来源地址https://www.toymoban.com/news/detail-852382.html
训练代码
import paddlex as pdx
from paddlex import transforms as T
train_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()
])
# 定义数据集的transform
train_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,# 训练batch
eval_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)
# 开始训练
到了这里,关于基于飞浆paddle的Mv3驾驶员行为识别的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!