Two bugs need to be fixed for training.
zhaowt61 opened this issue ยท 4 comments
1 change the " ptr = 0" in the function "load_weights(self, weights_path):" to "ptr=5". Because they added header_info into the weights file, which makes the loading mismatched by 5 bits. This bug is hidden so deep!
2 remove "model.eval()" in "detect.py"
The above solutions worked perfectly for me.
I do not think these two changes will make difference.
-
The original code is correct. The five bits are read in "header = np.fromfile(fp, dtype=np.int32, count=5)" line.
-
"detect.py" does not affect training. So, removing "model.eval()" would not affect the training result either. Moreover, "model.eval()" is strongly advised for testing.
I do not think these two changes will make difference.
1. The original code is correct. The five bits are read in "header = np.fromfile(fp, dtype=np.int32, count=5)" line. 2. "detect.py" does not affect training. So, removing "model.eval()" would not affect the training result either. Moreover, "model.eval()" is strongly advised for testing.
The first change is necessary, because I found that the loading and saving of weights are mis-matched.
1 change the " ptr = 0" in the function "load_weights(self, weights_path):" to "ptr=5". Because they added header_info into the weights file, which makes the loading mismatched by 5 bits. This bug is hidden so deep!
2 remove "model.eval()" in "detect.py"The above solutions worked perfectly for me.
I think ptr=0
is right, but definition of self.header_info
is wrong:
modify the
self.header_info = np.array([0, 0, 0, self.seen, 0])
to
self.header_info = np.array([0, 0, 0, self.seen, 0],dtype=np.int32)
,default np.int is np.int64. This is why these are 5bit offset.
I do not think these two changes will make difference.
1. The original code is correct. The five bits are read in "header = np.fromfile(fp, dtype=np.int32, count=5)" line. 2. "detect.py" does not affect training. So, removing "model.eval()" would not affect the training result either. Moreover, "model.eval()" is strongly advised for testing.
The first change is necessary, because I found that the loading and saving of weights are mis-matched.
when loading yolov3 official yolov3.weights, need to use ptr = 0, when loading the model from saving trained, need to modify ptr = 0 to ptr = 5