本文以肖佬项目为例,介绍如何用PaTTA提升效果。先解压数据集到data文件夹,生成数据列表并分割训练、验证集,安装PaddleSeg。编写配置文件后训练、验证、导出模型,再下载安装PaTTA,用其工具处理测试集,最后打包结果提交。PaTTA默认配置约涨1.几分,可解决验证集与提交结果差异问题。
☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜

以肖佬的项目为例,展示如何使用PaTTA增分。
如果您感觉不错的话,请watch、star、fork三联,别白嫖啦,谢谢您~
仓库地址:https://github.com/AgentMaker/PaTTA
使用PaTTA默认配置大约能涨1.几分,PaTTA能解决训练时候在验证集上miou非常高,但在提交后跌许多的问题。
这是在同一个模型情况下,仅仅使用了默认配置的PaTTA后的效果:
# 解压数据集# q [quiet]:无输出# d [directory]:指定解压目录!unzip -d data data/data68698/智能车数据集.zip
# 生成数据列表datas_list = [ 'data/image_4000/%d.png data/mask_4000/%d.png\n' % (x, x)
for x in range(4000)
]# 分割训练集,前 3900 张图像作为训练数据with open('train.txt', 'w') as f: for line in datas_list[:-100]:
f.write(line)# 分割验证集,后 100 张图像作为验证数据with open('dev.txt', 'w') as f: for line in datas_list[-100:]:
f.write(line)# 安装 PaddleSeg!pip install paddleseg
!unzip PaddleSeg-release-v2.0.zip!mv PaddleSeg-release-v2.0 paddleseg
# 设置数据批大小batch_size: 2# 设置训练步数iters: 1000# 训练集配置train_dataset:
type: Dataset
num_classes: 15
# 数据目录
dataset_root: ./
# 训练集列表
train_path: ./train.txt
# 数据预处理
transforms:
- type: Resize
target_size: [512, 512] - type: Normalize
mode: train# 验证集配置val_dataset:
type: Dataset
num_classes: 15
# 数据目录
dataset_root: ./
# 验证集列表
val_path: ./dev.txt
# 数据预处理
transforms:
- type: Resize
target_size: [512, 512] - type: Normalize
mode: val# 优化器配置optimizer:
type: sgd
momentum: 0.9
weight_decay: 4.0e-5# 学习率配置learning_rate:
value: 0.01
decay:
type: poly
power: 0.9
end_lr: 0# 损失函数配置loss:
types:
- type: CrossEntropyLoss
coef: [1.0, 0.4]# 模型配置model:
type: FastSCNN
num_classes: 15
enable_auxiliary_loss: True
pretrained: null# 模型训练# config:配置文件# save_dir:模型保存路径# do_eval:训练同时进行模型验证# 更多选项参数请参考源代码!python paddleseg/train.py \
--config Road_Line.yml \
--save_dir saved_models \
--do_eval# 模型验证# config:配置文件# model_path:模型文件# 更多选项参数请参考源代码!python paddleseg/val.py \
--config Road_Line.yml \
--model_path saved_models/best_model/model.pdparams!python paddleseg/export.py \
--config Road_Line.yml \
--model_path saved_models/best_model/model.pdparams!git clone https://github.com/AgentMaker/PaTTA.git
!unzip PaTTA.zip
import glob
path = glob.glob('data/infer/*')
f = open('test.txt', 'w')for i in path:
f.write(i+'\n')
f.close()!pip install PaTTA/
注意:请将seg.py里面的crop_size参数改成和训练一致!!!
!python PaTTA/tools/seg.py --model_path='output/model' \
--batch_size=16 \
--test_dataset='test.txt'# 打包结果文件!zip -r result.zip result
以上就是第十六届全国大学生智能车竞赛线上赛增分:PaTTA的使用的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号