Skip to content
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

Converting a custom yolov3 model #373

Open
Hatem-Jr opened this issue Jul 20, 2021 · 0 comments
Open

Converting a custom yolov3 model #373

Hatem-Jr opened this issue Jul 20, 2021 · 0 comments

Comments

@Hatem-Jr
Copy link

Hatem-Jr commented Jul 20, 2021

I am trying to convert this yolov3 custom model: https://drive.google.com/drive/folders/17jysPykGMkNw66lDMd0kryybCvGOesKi?usp=sharing
with this .cfg file: https://github.com/heltonmaia/ECT-proj-cnn-mice/blob/master/cfg/yolov3.cfg

into tensorflow format that already worked on the model that was linked in the video (for checking purposes and it worked 😄) however I tried to take the same approach to a custom trained model that detects "mice" (for test analysis purposes) and I get this error:

in load_darknet_weights
conv_shape).transpose([2, 3, 1, 0])
ValueError: cannot reshape array of size 4607 into shape (18,256,1,1)

so is there a way to solve this issue?

So then I added these lines in utils.py:
conv_shape = (math.floor(filters), math.floor(in_dim), size, size)
conv_weights = np.fromfile(wf, dtype=np.float32, count=np.product(conv_shape))
if conv_weights.shape[0]<filters*in_dim:
conv_weights = np.append(conv_weights,[0])

before: conv_weights = conv_weights.reshape(conv_shape).transpose([2, 3, 1, 0])

and it worked but when it came time to run object_tracker.py (yes a file from another repo but has the same convert.py and utils.py) I had this error:

tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: Input to reshape is a tensor with 3042 values, but the requested shape requires a multiple of 43095
[[{{node yolo_output_0/lambda/Reshape}}]]
[[yolo_nms/Reshape_9/_1477]]
(1) Invalid argument: Input to reshape is a tensor with 3042 values, but the requested shape requires a multiple of 43095
[[{{node yolo_output_0/lambda/Reshape}}]]

@Hatem-Jr Hatem-Jr changed the title Converting a custom yolov3 dataset Converting a custom yolov3 model Jul 21, 2021
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

1 participant