Closed husnejahan closed 4 years ago
I modify the line self.offset = 16 in the ./darkflow/utils/loader.py file and replace with self.offset = 20. But can not solve the issue.
FileNotFoundError Traceback (most recent call last)
looks like the weight file is broken, can you download and try one more shot?
hi, have same problem. Just downloaded weights from link that u gave (working with your instructions https://towardsdatascience.com/yolov2-to-detect-your-own-objects-soccer-ball-using-darkflow-a4f98d5ce5bf), but nothing changed. What different can be wrong?
looks like the weight file is broken, can you download and try one more shot?
i have try to download and try to train again, but stiill error.
I modify the line self.offset = 16 in the ./darkflow/utils/loader.py file and replace with self.offset = 20. But can not solve the issue.
i have the same problem.. did you find some solutions?
Yes I also have same problem.
@deep-diver I am using yolov2-tiny-voc_10000.weights and yolov2-tiny-voc.cfg in combination.
Both of them I have downloaded from official darkflow site.
The deafult yolov2-tiny-voc.cfg file has filters=35 But for my custom dataset classes=1 so filters should be 30. Making it 30 straightaway gives error: AssertionError: expect 63082060 bytes, found 63102560
Here is my repo link: https://github.com/pdhruv93/RoadCrackDetector
Good day! I had the same problem
Мanaged to solve it by adjusting the values in the file ./darkflow/utils/loader.py necessary
Hi, I also encountered the same error while studying this code.
And after searching a little bit, I was finally able to solve it.
first, problem is that the number of parameters in the weight file is different from the number of parameters in the cfg file.
See this link for information about why changing the parameters in the weight file
Link: https://github.com/thtrieu/darkflow/issues/107
Perhaps this code would have created a cfg file based on an older version of the weight file.
Therefore, we need to receive the previous version of the weight file.
Link: https://pjreddie.com/darknet/yolo/
Change the load section of the main ipynb file by getting the file "yolov2.weight" from here.
It can be solved with that.
Hi, where did you get the previous version of the weight file?
I tried "https://pjreddie.com/media/files/yolov2.weights" but it still not working.
Hi, I think I wrote the same weight file with you.
Please check if the error message also shows the same error message.
If you get the same error message, you should try the cfg file with the file provided in the link.
After try , If still raise same error Please Show me your options code and error message
Hi, thanks for helping. I used the same cfg file in this repo. Nothing changed. my network is
options = {"model": "cfg/yolo_custom.cfg",
"load": "bin/yolov2.weights",
"batch": 8,
"epoch": 100,
"gpu": 1.0,
"train": True,
"annotation": "./annotations/",
"dataset": "./images/"}
tfnet = TFNet(options)
Here is the error msg.
Parsing cfg/yolo_custom.cfg
Loading bin/yolov2.weights ...
/home/chenmh/workspace/darkflow/darkflow/dark/darknet.py:54: UserWarning: ./cfg/yolov2.cfg not found, use cfg/yolo_custom.cfg instead
cfg_path, FLAGS.model))
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-3-200f77f1939f> in <module>
----> 1 tfnet = TFNet(options)
~/workspace/darkflow/darkflow/net/build.py in __init__(self, FLAGS, darknet)
56
57 if darknet is None:
---> 58 darknet = Darknet(FLAGS)
59 self.ntrain = len(darknet.layers)
60
~/workspace/darkflow/darkflow/dark/darknet.py in __init__(self, FLAGS)
25 self.meta, self.layers = des_parsed
26
---> 27 self.load_weights()
28
29 def get_weight_src(self, FLAGS):
~/workspace/darkflow/darkflow/dark/darknet.py in load_weights(self)
80
81 args = [self.src_bin, self.src_layers]
---> 82 wgts_loader = loader.create_loader(*args)
83 for layer in self.layers: layer.load(wgts_loader)
84
~/workspace/darkflow/darkflow/utils/loader.py in create_loader(path, cfg)
103 load_type = checkpoint_loader
104
--> 105 return load_type(path, cfg)
106
107 class weights_walker(object):
~/workspace/darkflow/darkflow/utils/loader.py in __init__(self, *args)
17 self.src_key = list()
18 self.vals = list()
---> 19 self.load(*args)
20
21 def __call__(self, key):
~/workspace/darkflow/darkflow/utils/loader.py in load(self, path, src_layers)
75 assert walker.offset == walker.size, \
76 'expect {} bytes, found {}'.format(
---> 77 walker.offset, walker.size)
78 print('Successfully identified {} bytes'.format(
79 walker.offset))
AssertionError: expect 202335260 bytes, found 203934260
Then, I try the cfg file "https://github.com/pjreddie/darknet/blob/master/cfg/yolov2.cfg" and change the region part. In this time, I can build the network, but training is still not working.
Would you like to share your cfg file with me?
I used this cfg file.
If it does not work with this cfg file, we recommend customizing it in the existing yolo v2 file.
You do not have to change a lot.
Perhaps it only changed the number of classes and labels.
Please note that this cfg has 2 classes, so you can change it by referring to the original link.
It works! Appreciate your help ^_^
Good day! I had the same problem
Мanaged to solve it by adjusting the values in the file ./darkflow/utils/loader.py necessary
can you tell me, what did you adjust
In darkflow/utils/loader.py
class weights_walker(object):
"""incremental reader of float32 binary files"""
def __init__(self, path):
self.eof = False # end of file
self.path = path # current pos
if path is None:
self.eof = True
return
else:
self.size = os.path.getsize(path)# save the path
major, minor, revision, seen = np.memmap(path,
shape = (), mode = 'r', offset = 0,
dtype = '({})i4,'.format(4))
self.transpose = major > 1000 or minor > 1000
self.offset = 16 + 203934260 - 202335260
Make the adjustment according to the error that you have faced.
if you found the answer useful, help me on stackoverflow. So that those who have the same problem will immediately find the solution.
Thanks everyone for your help solving this ! The solution for me was to
self.offset = 16 + 203934260 - 202335260
mkdir ckpt
touch ckpt/checkpoint
However... Were you able to get to the ~0.5 mov avg loss the author claims? I will restart my training, but I am done with the 100 epochs and the avg loss is at 100 :(
In darkflow/utils/loader.py
class weights_walker(object): """incremental reader of float32 binary files""" def __init__(self, path): self.eof = False # end of file self.path = path # current pos if path is None: self.eof = True return else: self.size = os.path.getsize(path)# save the path major, minor, revision, seen = np.memmap(path, shape = (), mode = 'r', offset = 0, dtype = '({})i4,'.format(4)) self.transpose = major > 1000 or minor > 1000 self.offset = 16 + 203934260 - 202335260
Make the adjustment according to the error that you have faced.
Thank you, this really solves my issue.
Open ./darkflow/darkflow/utils/loader.py
and in line 75 remove:
assert walker.offset == walker.size, \
'expect {} bytes, found {}'.format(
walker.offset, walker.size)
It worked for me. Finally, it will look like:
if walker.path is not None:
print('Successfully identified {} bytes'.format(
walker.offset))
Parsing cfg/yolo_custom.cfg Loading bin/yolo.weights ...
AssertionError Traceback (most recent call last)