tensorflow-yolo-v3
tensorflow-yolo-v3 copied to clipboard
cannot reshape array of size 4607 into shape (18,256,1,1)
I convert yolov3.weights to a pb file. It is OK. When I tried to convert a pre-training model, the following errors occurred. The structure of pre-training model is the same as that of yolov3.weight. The only difference is that it has only one class.
Traceback (most recent call last):
File "convert_weights_pb.py", line 53, in
Got the Same ISSUE!
./convert_weights_pb.py --class_name coco.names --data_format NHWC --weight_file yolov3.weights
Traceback (most recent call last):
File "./convert_weights_pb.py", line 52, in
Well I got this issue as well
Traceback (most recent call last):
File "convert_weights_pb.py", line 52, in
Is there anybody who have solved the problem?
Change your labels.txt to appropriate length.
--class_names
Change your labels.txt to appropriate length.
what's that mean? the process when run convert_weights_pb.py does not require any txt file
I got the same reason, and here's how I solve it.
First,check is your environment right.
I trained my weights file on Win 10 at first, after debug, I find the weight size is not equal to the network actually needed, in my case, the size of my one-class weights is 8676243 while the network needs 8676244.
After changing into Ubuntu, I use Ubuntu 18.04(Ubuntu 16.04 should be the same), and retrained my one-class yolov3-tinny model, I use this weights to convert into pb format, it finally works
So check your environment, I advice you train your model on Ubuntu and use tensorflow-gpu V1.12.
Finally, I'd like anyone to tell me why it's different in Windows and Ubuntu, in my guess, it's probably the reason of the value's precision is different in Ubuntu and Windows.
So some of us have the weights missing 1 float32.
Is this related? https://github.com/pjreddie/darknet/issues/497#issuecomment-369269855 The seen may be 32bit or 64bit long.
Could you try reading 32 bits fewer by changing count to 4 in _ = np.fromfile(fp, dtype=np.int32, count=5) in utils?
~I am still having some problem with the set of weights I have, so I would love to see a confirmation that this is a valid fix.~ Just checked, this works for me.
I find the error is because the class_names file, the last line is blank line, delete the blank line , the problom solving
Could you try reading 32 bits fewer by changing
countto4in_ = np.fromfile(fp, dtype=np.int32, count=5)in utils?
It didn't work for me..
Changing the count to 4 may fix the issue only if the number is off by one.
E.g. 4067 = 18 * 256 - 1 in the title.
I am not sure why the comment of @wangluolaowu has been down voted. It's actually the solution that worked for me.
Has anyone that had a correct .names file solved this problem yet? @firstxx @NightFury10497 @Yogita98 I am having the same problem.
I have the correct .names and still have the problem. Any idea?
ValueError: cannot reshape array of size 3072 into shape (18,256,1,1) anyone can help me?
This happens for problem in (.names) file. You should check tow things to solve this.
- If you are training on all classes please check if there is extra new line at the last of class names.
- If you are training on specific some classes please remove the extra class from (.names) file either you used all class names during training.
I had the same issue, turned out I was giving .data file as --names_path - instead of .names file. Giving correct arguments fixed it for me, so make sure that you're giving the right ones.
This happens for problem in (.names) file. You should check tow things to solve this.
- If you are training on all classes please check if there is extra new line at the last of class names.
- If you are training on specific some classes please remove the extra class from (.names) file either you used all class names during training.
I've tried both. no extra line, all classes present ( 36 ) and still have exception :(
Convert
_ = np.fromfile(fp, dtype=np.int32, count=5)
to
_ = np.fromfile(fp, dtype=np.int32, count=4)
in utils.py (line 70). It works to me.