Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
陈沧夜 7b9281a1c7 | 1 year ago | |
---|---|---|
.gitignore | 1 year ago | |
Coal271.jpg | 1 year ago | |
LICENSE | 1 year ago | |
README.md | 1 year ago | |
main.py | 1 year ago |
!pip install paddlex==2.1.0 -i https://mirror.baidu.com/pypi/simple
#在模型进行训练时,我们需要划分训练集,验证集和测试集
#因此需要对如上数据进行划分,直接使用paddlex命令即可将数据集随机划分成70%训练集,20%验证集和10%测试集
#划分好的数据集会额外生成labels.txt, train_list.txt, val_list.txt, test_list.txt四个文件,之后可直接进行训练。
!paddlex --split_dataset --format ImageNet --dataset_dir data/RockData --val_value 0.2 --test_value 0.1
接下来运行main.py
就可以啦!
https://aistudio.baidu.com/aistudio/datasetdetail/129645
这个数据集主要是集中基本的岩石类别,主要有“玄武岩”、“花岗岩”、“大理石”、“石英岩”、“煤”、“石灰石”、“砂岩” 共计7类。
每一个类别都是一个文件夹,推荐使用PaddleX来对这个数据集进行自动划分,贼方便有木有!
在这里我使用PaddleX套件,PaddleX套件在处理图像分类的问题上会大量节省开发效率,相关文档如下:
PaddleX项目官网:
https://www.paddlepaddle.org.cn/paddle/paddlex
PaddleX Github地址:
https://github.com/PaddlePaddle/PaddleX
PaddleX API开发模式快速上手:
https://github.com/PaddlePaddle/PaddleX/blob/develop/docs/quick_start_API.md
PaddleX指标及日志:
https://github.com/PaddlePaddle/PaddleX/blob/develop/docs/appendix/metrics.md
模型使用的是MobileNetV3-百度改,是百度基于蒸馏方法得到的MobileNetV3预训练模型,模型结构与MobileNetV3一致,但精度更高。
(1)PyTorch实现1:https://github.com/xiaolai-sqlai/mobilenetv3
(2)PyTorch实现2:https://github.com/kuan-wang/pytorch-mobilenet-v3
(3)PyTorch实现3:https://github.com/leaderj1001/MobileNetV3-Pytorch
(4)Caffe实现:https://github.com/jixing0415/caffe-mobilenet-v3
(5)TensorFLow实现:https://github.com/Bisonai/mobilenetv3-tensorflow
MobileNetV3综合了以下三种模型的思想:
MobileNetV1的深度可分离卷积(depthwise separable convolutions)
MobileNetV2的具有线性瓶颈的逆残差结构(the inverted residual with linear bottleneck)
MnasNet的基于squeeze and excitation结构的轻量级注意力模型
详细的论文请参考:《Searching for MobileNetV3》
以下字段会在输出时候显示,具体含义如下:
字段 | 示例 | 含义 |
---|---|---|
Epoch | Epoch=4/20 | [迭代轮数] 所有训练数据会被训练20轮,当前处于第4轮 |
Step | Step=62/66 | [迭代步数] 所有训练数据被训练一轮所需要的迭代步数为66,当前处于第62步 |
loss | loss=0.007226 | [损失函数值] 参与当前迭代步数的训练样本的平均损失函数值loss,loss值越低,表明模型在训练集上拟合的效果越好(如上日志中第1行表示第4个epoch的第62个Batch的loss值为0.007226) |
lr | lr=0.008215 | [学习率] 当前模型迭代过程中的学习率 |
time_each_step | time_each_step=0.41s | [每步迭代时间] 训练过程计算得到的每步迭代平均用时 |
eta | eta=0:9:44 | [剩余时间] 模型训练完成所需剩余时间预估为0小时9分钟44秒 |
分类任务的训练日志除了通用统计信息外,还包括acc1和acc5两个特有字段。
注: acck准确率是针对一张图片进行计算的:把模型在各个类别上的预测得分按从高往低进行排序,取出前k个预测类别,若这k个预测类别包含了真值类,则认为该图片分类正确。
acc1表示参与当前迭代步数的训练样本的平均top1准确率,值越高代表模型越优;
acc5表示参与当前迭代步数的训练样本的平均top5(若类别数n少于5,则为topn)准确率,值越高代表模型越优。
例如:
[TRAIN] Epoch=1/10, Step=20/22, loss=1.064334, acc1=0.671875, acc5=0.968750, lr=0.025000, time_each_step=0.15s, eta=0:0:31
代表:
Epoch=1/10
[迭代轮数] 所有训练数据会被训练10轮,当前处于第1轮;
Step=20/22
[迭代步数] 所有训练数据被训练一轮所需要的迭代步数为22,当前处于第20步;
loss=1.064334
[损失函数值] loss值为1.064334;
acc1=0.671875
acc1 表示整个验证集的平均top1准确率为0.671875;
acc5=0.968750
acc5 表示整个验证集的平均top5准确率为0.968750;
lr=0.025000
[学习率] 当前模型迭代过程中的学习率;
time_each_step=0.15s
[每步迭代时间] 训练过程计算得到的每步迭代平均用时;
eta=0:0:31
[剩余时间] 模型训练完成所需剩余时间预估为0小时0分钟31秒;
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》