tensorflow-yolov4-tflite
tensorflow-yolov4-tflite copied to clipboard
ValueError: cannot reshape array of size 5370 into shape (30,256,1,1)
I am facing the following error:
ValueError: cannot reshape array of size 5370 into shape (30,256,1,1)
What I did -Changed config.py as follows.
# YOLO options
__C.YOLO = edict()
__C.YOLO.CLASSES = "./data/classes/obj.names"
__C.YOLO.ANCHORS = [12,16, 19,36, 40,28, 36,75, 76,55, 72,146, 142,110, 192,243, 459,401]
__C.YOLO.ANCHORS_V3 = [10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326]
__C.YOLO.ANCHORS_TINY = [23,27, 37,58, 81,82, 81,82, 135,169, 344,319]
__C.YOLO.STRIDES = [8, 16, 32]
__C.YOLO.STRIDES_TINY = [16, 32]
__C.YOLO.XYSCALE = [1.2, 1.1, 1.05]
__C.YOLO.XYSCALE_TINY = [1.05, 1.05]
__C.YOLO.ANCHOR_PER_SCALE = 3
__C.YOLO.IOU_LOSS_THRESH = 0.5
-The execution code is as follows.
!python save_model.py --weights ./data/yolov4_final.weights --output ./checkpoints/yolov4-512 --input_size 512 --model yolov4
!python save_model.py --weights ./data/yolov4-tiny_custom_final.weights --output ./checkpoints/yolov4-tiny-416 --input_size 416 --model yolov4 --tiny true
-obj.names is as follows.
Can
Person
Bottle
Box
Would you please solve this problem? Thank you.
any update?
No、same condition.
I have used this repo for converting my custom YOLO v4 tiny model to TensorFlow. I too faced the same error. When I dug deeper into code, by default the code in "./core/utils.py" is taking "./data/classes/coco.names" in line no. 78. I gave the path to my own "obj.names" and it worked. Please give the path of your "obj.names" or "*.names" in line no. 78 of "./core/utils.py".
Sample:
with open("path/to/your/obj.names", 'r') as data:
Or edit __C.YOLO.CLASSES = "path/to/your/obj.names" in config.py in line no. 14
To nagi1995 I made the correction as you pointed out. Then, I was able to execute it without any error! Thank you for your advice! !! !!
I have used this repo for converting my custom YOLO v4 tiny model to TensorFlow. I too faced the same error. When I dug deeper into code, by default the code in "./core/utils.py" is taking "./data/classes/coco.names" in line no. 78. I gave the path to my own "obj.names" and it worked. Please give the path of your "obj.names" or "*.names" in line no. 78 of "./core/utils.py".
Sample:
with open("path/to/your/obj.names", 'r') as data:
Or edit __C.YOLO.CLASSES = "path/to/your/obj.names" in config.py in line no. 14
@nagi1995 Thank you so much bro. It fixed that. you did me so much favor. @hunglc007 and please fix this bug.
Check that there is no empty lines in your obj.names. That helps me.
I have same issue when I run save_model.py.
!python save_model.py \ --weights yolov4-tiny_ver3_final.weights \ --output ./checkpoints/yolov4-tiny_ver3 \ --input_size 416 \ --model yolov4 \ --tiny true \ --framework tflite
error belows:
Please help me.
Thank you. However, I am still getting the same error with this repo. Please let me know if there is another solution. Thank you in advance.
Sorry,the reason for the error was probably because the model was trained on my original cfg. (different number of convs). So, I need to rewrite YOLOv4_tiny in /core/yolov4.py.