AlibabaResearch / AlibabaResearch/efficientteacher
Changing the yolo version from yolov5 to yolov7 facing issues while converting yolov7.pt to efficient.pt
- Lingua principale
- Python
- Stelle
- 813
- Fork
- 126
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
I tried efficient teacher ssod on my custom data it's giving some pretty results, so i decided to test efficient teacher based on yolov7 on my custom data.
For that i made the following changes
created a map file for yolov7 which is used while executing convert_pt_to_efficient.py to convert yolov7.pt to efficient-yolov7.pt based on yolov7 structure below is the map file content
### mapv7.txt
backbone.stage0.cv0 model.0
backbone.stage0.cv1 model.1
backbone.stage0.cv0 model.2
backbone.stage0.cv1 model.3
backbone.elan_0.cv0 model.4
backbone.elan_0.cv1 model.5
backbone.elan_0.cv2 model.6
backbone.elan_0.m0.0 model.7
backbone.elan_0.m0.1 model.8
backbone.elan_0.m1.0 model.9
backbone.concat model.10
backbone.elan_0.m1 model.11
backbone.mp model.12
backbone.elan_1.aug.cv0 model.13
backbone.elan_1.aug.cv1 model.14
backbone.elan_1.aug.cv2 model.15
backbone.concat model.16
backbone.elan_1.cv0 model.17
backbone.elan_1.cv1 model.18
backbone.elan_1.cv2 model.19
backbone.elan_1.m0.0 model.20
backbone.elan_1.m0.1 model.21
backbone.elan_1.m1.0 model.22
backbone.concat model.23
backbone.elan_1.m1.1 model.24
backbone.mp1 model.25
backbone.elan_2.aug.cv0 model.26
backbone.elan_2.aug.cv1 model.27
backbone.elan_2.aug.cv2 model.28
backbone.concat model.29
backbone.elan_2.cv0 model.30
backbone.elan_2.cv1 model.31
backbone.elan_2.cv2 model.32
backbone.elan_2.m0.0 model.33
backbone.elan_2.m0.1 model.34
backbone.elan_2.m1.0 model.35
backbone.concat model.36
backbone.elan_2.m1.1.conv model.37
backbone.mp1 model.38
backbone.elan_3.aug.cv0 model.39
backbone.elan_3.aug.cv1 model.40
backbone.elan_3.aug.cv2 model.41
backbone.concat model.42
backbone.elan_3.cv0 model.43
backbone.elan_3.cv1 model.44
backbone.elan_3.cv2 model.45
backbone.elan_3.m0.0 model.46
backbone.elan_3.m0.1 model.47
backbone.elan_3.m1.0 model.48
backbone.concat model.49
backbone.elan_3.m1.1 model.50
neck.sppcspc model.51
neck.conv1 model.52
neck.upsample1 model.53
neck.conv2 model.54
neck.concat model.55
neck.elan_0.cv0 model.56
neck.elan_0.cv1 model.57
neck.elan_0.cv2 model.58
neck.elan_0.cv3 model.59
neck.elan_0.m0 model.60
neck.elan_0.m1 model.61
neck.concat model.62
neck.elan_0.m2 model.63
neck.conv10 model.64
neck.upsample2 model.65
neck.conv11 model.66
neck.concat model.67
neck.elan_1.cv0 model.68
neck.elan_1.cv1 model.69
neck.elan_1.cv2 model.70
neck.elan_1.cv3 model.71
neck.elan_1.m0 model.72
neck.elan_1.m1 model.73
neck.concat model.74
neck.elan_1.m2 model.75
neck.mp1 model.76
neck.conv19 model.77
neck.conv20 model.78
neck.conv21 model.79
neck.concat model.80
neck.elan_2.cv0 model.81
neck.elan_2.cv1 model.82
neck.elan_2.cv2 model.83
neck.elan_2.cv3 model.84
neck.elan_2.m0 model.85
neck.elan_2.m1 model.86
neck.concat model.87
neck.elan_2.m2 model.88
neck.mp1 model.89
neck.conv29 model.90
neck.conv30 model.91
neck.conv31 model.92
neck.concat model.93
neck.elan_3.cv0 model.94
neck.elan_3.cv1 model.95
neck.elan_3.cv2 model.96
neck.elan_3.cv3 model.97
neck.elan_3.m0 model.98
neck.elan_3.m1 model.99
neck.concat model.100
neck.elan_3.m2 model.101
neck.repconv0 model.102
neck.repconv1 model.103
neck.repconv2 model.104
head model.105
And create a custom yaml file for yolov7
### Parameters
project: '/runs_yolov7'
adam: False
epochs: 300
weights: ''
prune_finetune: False
linear_lr: True
hyp:
lr0: 0.01
hsv_h: 0.015
hsv_s: 0.7
hsv_v: 0.4
lrf: 0.1
scale: 0.9
no_aug_epochs: 0
mixup: 0.1
warmup_epochs: 3
Model:
depth_multiple: 1.00 # model depth multiple
width_multiple: 1.00 # layer channel multiple
Backbone:
name: 'YoloV7'
activation: 'SiLU'
Neck:
name: 'YoloV7'
in_channels: [512, 1024, 1024]
out_channels: [256, 512, 1024]
activation: 'SiLU'
Head:
name: 'YoloV7'
activation: 'SiLU'
anchors: [[10,13, 16,30, 33,23],[30,61, 62,45, 59,119],[116,90, 156,198, 373,326]] # P5/32
Loss:
type: 'ComputeLoss'
cls: 0.3
obj: 0.7
anchor_t: 4.0
Dataset:
data_name: 'coco'
train: data/custom_train.txt # 118287 images
val: data/custom_val.txt # 5000 images
test: data/custom_val.txt # 20288 of 40670 images, submit to https://competitions.codalab.org/competitions/20794^
nc: 2 # number of classes
np: 0 #number of keypoints
names: [ 'rick', 'morty']
img_size: 640
batch_size: 128
By using the above conf file and map file while i trying to execute convert_efficient_to_yolov5 in convert_pt_to_efficient.py by giving
cfg='yolov7_custom.yaml' which is given above and pt_path as 'yolov7.pt' which i stored in another folder and map_path= file path which i given for the above map details. I'm encountering the following Error
####Error
**Model summary: 432 layers, 37622682 parameters, 37622682 gradients
load weights from u-yolov5...
Traceback (most recent call last):
File "/content/efficientteacher/scripts/mula_convertor/convert_pt_to_efficient.py", line 102, in
convert_yolov5_to_efficient( '/content/efficientteacher/yolov7.pt', '/content/efficientteacher/configs/sup/public/yolov7l_coco.yaml','efficient-yolov7.pt')
File "/content/efficientteacher/scripts/mula_convertor/convert_pt_to_efficient.py", line 43, in convert_yolov5_to_efficient
model.load_state_dict(new_yolov5s_weight,strict=False)
File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 2041, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for Model:
size mismatch for backbone.stage0.cv0.conv.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([32, 3, 3, 3]).
size mismatch for backbone.stage0.cv0.bn.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([32]).
size mismatch for backbone.stage0.cv0.bn.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([32]).
size mismatch for backbone.stage0.cv0.bn.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([32]).
size mismatch for backbone.stage0.cv0.bn.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([32]).
size mismatch for backbone.stage0.cv1.conv.weight: copying a param with shape torch.Size([128, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([64, 32, 3, 3]).
size mismatch for backbone.stage0.cv1.bn.weight: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.stage0.cv1.bn.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.stage0.cv1.bn.running_mean: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.stage0.cv1.bn.running_var: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for backbone.elan_0.cv2.conv.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 256, 1, 1]).
size mismatch for backbone.elan_0.cv2.bn.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for backbone.elan_0.cv2.bn.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for backbone.elan_0.cv2.bn.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for backbone.elan_0.cv2.bn.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for backbone.elan_1.cv2.conv.weight: copying a param with shape torch.Size([128, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 512, 1, 1]).
size mismatch for backbone.elan_1.cv2.bn.weight: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for backbone.elan_1.cv2.bn.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for backbone.elan_1.cv2.bn.running_mean: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for backbone.elan_1.cv2.bn.running_var: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for backbone.elan_1.m1.1.conv.weight: copying a param with shape torch.Size([512, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]).
size mismatch for backbone.elan_1.m1.1.bn.weight: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.elan_1.m1.1.bn.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.elan_1.m1.1.bn.running_mean: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.elan_1.m1.1.bn.running_var: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for backbone.elan_2.cv2.conv.weight: copying a param with shape torch.Size([256, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 1024, 1, 1]).
size mismatch for backbone.elan_2.cv2.bn.weight: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for backbone.elan_2.cv2.bn.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for backbone.elan_2.cv2.bn.running_mean: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for backbone.elan_2.cv2.bn.running_var: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for backbone.elan_3.cv2.conv.weight: copying a param with shape torch.Size([256, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([1024, 1024, 1, 1]).
size mismatch for backbone.elan_3.cv2.bn.weight: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for backbone.elan_3.cv2.bn.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for backbone.elan_3.cv2.bn.running_mean: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for backbone.elan_3.cv2.bn.running_var: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([1024]).
size mismatch for backbone.elan_3.m1.1.conv.weight: copying a param with shape torch.Size([1024, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 256, 3, 3]).
size mismatch for backbone.elan_3.m1.1.bn.weight: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for backbone.elan_3.m1.1.bn.bias: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for backbone.elan_3.m1.1.bn.running_mean: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for backbone.elan_3.m1.1.bn.running_var: copying a param with shape torch.Size([1024]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_0.cv3.conv.weight: copying a param with shape torch.Size([128, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 1024, 1, 1]).
size mismatch for neck.elan_0.cv3.bn.weight: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_0.cv3.bn.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_0.cv3.bn.running_mean: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_0.cv3.bn.running_var: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_0.m2.conv.weight: copying a param with shape torch.Size([256, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]).
size mismatch for neck.elan_0.m2.bn.weight: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_0.m2.bn.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_0.m2.bn.running_mean: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_0.m2.bn.running_var: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_1.cv3.conv.weight: copying a param with shape torch.Size([64, 64, 3, 3]) from checkpoint, the shape in current model is torch.Size([128, 512, 1, 1]).
size mismatch for neck.elan_1.cv3.bn.weight: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_1.cv3.bn.bias: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_1.cv3.bn.running_mean: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_1.cv3.bn.running_var: copying a param with shape torch.Size([64]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_1.m2.conv.weight: copying a param with shape torch.Size([128, 512, 1, 1]) from checkpoint, the shape in current model is torch.Size([64, 64, 3, 3]).
size mismatch for neck.elan_1.m2.bn.weight: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for neck.elan_1.m2.bn.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for neck.elan_1.m2.bn.running_mean: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for neck.elan_1.m2.bn.running_var: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for neck.elan_2.cv3.conv.weight: copying a param with shape torch.Size([128, 128, 3, 3]) from checkpoint, the shape in current model is torch.Size([256, 1024, 1, 1]).
size mismatch for neck.elan_2.cv3.bn.weight: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_2.cv3.bn.bias: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_2.cv3.bn.running_mean: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_2.cv3.bn.running_var: copying a param with shape torch.Size([128]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_2.m2.conv.weight: copying a param with shape torch.Size([256, 1024, 1, 1]) from checkpoint, the shape in current model is torch.Size([128, 128, 3, 3]).
size mismatch for neck.elan_2.m2.bn.weight: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_2.m2.bn.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_2.m2.bn.running_mean: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_2.m2.bn.running_var: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for neck.elan_3.cv3.conv.weight: copying a param with shape torch.Size([256, 256, 3, 3]) from checkpoint, the shape in current model is torch.Size([512, 2048, 1, 1]).
size mismatch for neck.elan_3.cv3.bn.weight: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for neck.elan_3.cv3.bn.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for neck.elan_3.cv3.bn.running_mean: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for neck.elan_3.cv3.bn.running_var: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([512]).
size mismatch for neck.elan_3.m2.conv.weight: copying a param with shape torch.Size([512, 2048, 1, 1]) from checkpoint, the shape in current model is torch.Size([256, 256, 3, 3]).
size mismatch for neck.elan_3.m2.bn.weight: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_3.m2.bn.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_3.m2.bn.running_mean: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for neck.elan_3.m2.bn.running_var: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).**
Is there any other changes i have to do or any changes done wrong in the above files in order to work with yolov7 based efficient teacher ssod?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.