Skip to content

TypeError: buffer is too small for requested array #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Mukulareddy opened this issue May 26, 2020 · 19 comments
Open

TypeError: buffer is too small for requested array #21

Mukulareddy opened this issue May 26, 2020 · 19 comments

Comments

@Mukulareddy
Copy link

Traceback (most recent call last):
File "convert.py", line 173, in
yolo4_model = Yolo4(score, iou, anchors_path, classes_path, model_path, weights_path)
File "convert.py", line 157, in init
self.load_yolo()
File "convert.py", line 130, in load_yolo
buffer=weights_file.read(weights_size * 4))

@Runist
Copy link

Runist commented May 27, 2020

I meet the problem too.I search in Google,somebody say that it maybe your keras model isn't match yolov4.weights.So I try to figure out.

@Runist
Copy link

Runist commented May 29, 2020

Traceback (most recent call last):
File "convert.py", line 173, in
yolo4_model = Yolo4(score, iou, anchors_path, classes_path, model_path, weights_path)
File "convert.py", line 157, in init
self.load_yolo()
File "convert.py", line 130, in load_yolo
buffer=weights_file.read(weights_size * 4))

I solve the problem,but I use my code.Here is link.Besides, my keras model is mismatch the AlexeyAB-version.So I just load csp-darknet.

@ybloch
Copy link

ybloch commented Jul 8, 2020

Got the same issue when I tried to convert my tiny-yolov4, trained with AlexeyAB darknet version

@JoshieLim
Copy link

I've got this error as well. Did anyone manage to solve it?

@Melkeydev
Copy link

any updates?

@JoshieLim
Copy link

@Amokstakov I've retrained my data by setting image size to (608,608) in yolov4-custom config file and it works.

@Melkeydev
Copy link

@JoshieLim I am struggling converting the downloaded yolo_4.weights file to the yolo4.h5 file using the conver.py
Any insight into this? I am lookign and the convert.py never actually references the .cfg file for yolo4?

@JoshieLim
Copy link

@Amokstakov Hmm that's odd. I'm able to convert to .h5 on my end. Did you set the anchors path to a yolo4_anchors? It should look something like this for yolov4 anchors 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401.

@Melkeydev
Copy link

Melkeydev commented Aug 12, 2020

Still no luck here.
Would it be too much trouble to ask for a direct step-by-step of what you did @JoshieLim

like from GitClone... what are the next steps into running the detect then test.py code?

@xellDart
Copy link

Any update?

@JoshieLim
Copy link

@Amokstakov Can you try to convert this yolov4.weights from this link. See if it works.

#get yolov4 pre-trained weights
!wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights

@MuhammadAsadJaved
Copy link

@ybloch Hi, Have you managed to convert tiny_yolov4.weights to .h5? It's pre-trained tiny_yolov4, not custom tiny_yolov4 model.

@ybloch
Copy link

ybloch commented Aug 27, 2020

@MuhammadAsadJaved Hi,
I could not convert it to H5 so I converted it to a TensorFlow model and with it, I use for production.
Here's how I did it:
Using repo: [https://github.com/hunglc007/tensorflow-yolov4-tflite]

  • git clone https://github.com/hunglc007/tensorflow-yolov4-tflite

  • cd tensorflow-yolov4-tflite

  • sudo python3 save_model.py --weights yolov4-tiny-custom_final.weights --output ./checkpoints/yolov4_v1_darknet-416 --input_size 416 --model yolov4 --framework tflite

  • sudo python3 convert_tflite.py --weights ./checkpoints/yolov4_v1_darknet-416 --quantize_mode fp16 --output ./checkpoints/yolov4_v1_darknet-416_fp16.tflite

You will find in this project an example of using the converted model

@MuhammadAsadJaved
Copy link

@ybloch OK. Thanks for sharing dear. Actually I need keras model for some other project (tiny_yolov4+deep_sort). It's a project for detection and then applying tracker on detections.

@Shridharpawar77
Copy link

did anyone manage to convert the model? If yes, please help

@Halkyon64
Copy link

Same problem here. Tried all possible mirrors for yolov4 weights.
But I've made only one change to convert.py: replaced from keras import backend as K to import tensorflow.python.keras.backend as K, because original import caused another problem:
AttributeError: module 'keras.backend' has no attribute 'get_session'

@maazullah96
Copy link

Thank @Runist for you comment I have converted yolov4.weights file to .h5 file using Runist YOLOV4 Repository "

@Mahmood-Hussain
Copy link

YOLOV4 Repository

@maazullah96 this shows 404

@Saqueeb
Copy link

Saqueeb commented Jan 24, 2022

Having same issue.
Did anyone convert custom trained yolov4 to .h5 model? If yes, then can you please share the steps here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests