Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update
  • Loading branch information
TomatoAndCucumber committed May 14, 2022
commit aac4bd6ae5434bd0ee829d136bc33c4a110bb249
47 changes: 27 additions & 20 deletions model_data/voc_classes.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
aeroplane
bicycle
bird
boat
bottle
bus
car
cat
chair
cow
diningtable
dog
horse
motorbike
person
pottedplant
sheep
sofa
train
tvmonitor
Cherry leaf
Peach leaf
Corn leaf blight
Apple rust leaf
Potato leaf late blight
Strawberry leaf
Corn rust leaf
Tomato leaf late blight
Tomato mold leaf
Potato leaf early blight
Apple leaf
Tomato leaf yellow virus
Blueberry leaf
Tomato leaf mosaic virus
Raspberry leaf
Tomato leaf bacterial spot
Squash Powdery mildew leaf
grape leaf
Corn Gray leaf spot
Tomato Early blight leaf
Apple Scab Leaf
Tomato Septoria leaf spot
Tomato leaf
Soyabean leaf
Bell_pepper leaf spot
Bell_pepper leaf
grape leaf black rot
16 changes: 8 additions & 8 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
# 可以设置mosaic=True,直接随机初始化参数开始训练,但得到的效果仍然不如有预训练的情况。(像COCO这样的大数据集可以这样做)
# 2、了解imagenet数据集,首先训练分类模型,获得网络的主干部分权值,分类模型的 主干部分 和该模型通用,基于此进行训练。
#----------------------------------------------------------------------------------------------------------------------------#
model_path = 'model_data/yolov5_s.pth'
model_path = 'model_data/swin_tiny_patch4_window7.pth'
#------------------------------------------------------#
# input_shape 输入的shape大小,一定要是32的倍数
#------------------------------------------------------#
Expand All @@ -105,7 +105,7 @@
# convnext_small
# swin_transfomer_tiny
#------------------------------------------------------#
backbone = 'cspdarknet'
backbone = 'swin_transfomer_tiny'
#----------------------------------------------------------------------------------------------------------------------------#
# pretrained 是否使用主干网络的预训练权重,此处使用的是主干的权重,因此是在模型构建的时候进行加载的。
# 如果设置了model_path,则主干的权值无需加载,pretrained的值无意义。
Expand All @@ -117,7 +117,7 @@
# phi 所使用的YoloV5的版本。s、m、l、x
# 在除cspdarknet的其它主干中仅影响panet的大小
#------------------------------------------------------#
phi = 's'
phi = 'l'
#------------------------------------------------------------------#
# mosaic 马赛克数据增强
# 参考YoloX,由于Mosaic生成的训练图片,
Expand All @@ -127,7 +127,7 @@
# label_smoothing 标签平滑。一般0.01以下。如0.01、0.005
#------------------------------------------------------------------#
mosaic = True
label_smoothing = 0
label_smoothing = 0.005

#----------------------------------------------------------------------------------------------------------------------------#
# 训练分为两个阶段,分别是冻结阶段和解冻阶段。设置冻结阶段是为了满足机器性能不足的同学的训练需求。
Expand Down Expand Up @@ -164,7 +164,7 @@
# (当Freeze_Train=False时失效)
#------------------------------------------------------------------#
Init_Epoch = 0
Freeze_Epoch = 50
Freeze_Epoch = 200
Freeze_batch_size = 16
#------------------------------------------------------------------#
# 解冻阶段训练参数
Expand All @@ -175,7 +175,7 @@
# Adam可以使用相对较小的UnFreeze_Epoch
# Unfreeze_batch_size 模型在解冻后的batch_size
#------------------------------------------------------------------#
UnFreeze_Epoch = 300
UnFreeze_Epoch = 1000
Unfreeze_batch_size = 8
#------------------------------------------------------------------#
# Freeze_Train 是否进行冻结训练
Expand All @@ -202,7 +202,7 @@
#------------------------------------------------------------------#
optimizer_type = "sgd"
momentum = 0.937
weight_decay = 5e-4
weight_decay = 5e-3
#------------------------------------------------------------------#
# lr_decay_type 使用到的学习率下降方式,可选的有step、cos
#------------------------------------------------------------------#
Expand All @@ -225,7 +225,7 @@
# (二)此处设置评估参数较为保守,目的是加快评估速度。
#------------------------------------------------------------------#
eval_flag = True
eval_period = 10
eval_period = 20
#------------------------------------------------------------------#
# num_workers 用于设置是否使用多线程读取数据
# 开启后会加快数据读取速度,但是会占用更多内存
Expand Down
6 changes: 3 additions & 3 deletions voc_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# annotation_mode为1代表获得VOCdevkit/VOC2007/ImageSets里面的txt
# annotation_mode为2代表获得训练用的2007_train.txt、2007_val.txt
#--------------------------------------------------------------------------------------------------------------------------------#
annotation_mode = 0
annotation_mode = 2
#-------------------------------------------------------------------#
# 必须要修改,用于生成2007_train.txt、2007_val.txt的目标信息
# 与训练和预测所用的classes_path一致即可
Expand All @@ -26,8 +26,8 @@
# train_percent用于指定(训练集+验证集)中训练集与验证集的比例,默认情况下 训练集:验证集 = 9:1
# 仅在annotation_mode为0和1的时候有效
#--------------------------------------------------------------------------------------------------------------------------------#
trainval_percent = 0.9
train_percent = 0.9
trainval_percent = 0.8
train_percent = 0.75
#-------------------------------------------------------#
# 指向VOC数据集所在的文件夹
# 默认指向根目录下的VOC数据集
Expand Down