YOLO_v3_tutorial_from_scratch icon indicating copy to clipboard operation
YOLO_v3_tutorial_from_scratch copied to clipboard

error occur when load network

Open xiaosuzhang opened this issue 6 years ago • 19 comments

I train my yolov3 model using my own datasets and get the .weight file. When i use the darnet.py to load my .weights, some error is occur as followed:

RuntimeError: invalid argument 2: size '[18 x 256 x 1 x 1]' is invalid for input with 4607 elements at ..\src\TH\THStorage.c:41

my pytorch verson is 0.4.0 on windows. how should i do to solve the problem? Tnanks?

xiaosuzhang avatar Apr 27 '18 09:04 xiaosuzhang

The config file is for COCO, which is why the prediction feature map has 255 entries. The number of entries in depth for feature map is (3 x ( 5 + C)). C = 80 for COCO. It might be different for your case, hence the code is not working. Let me know how many

  1. Classes
  2. Anchors boxes per cell

And I'll help you adapt the code.

You'll have to change values of the variable num_classes in detect.py accordingly in detect.py from 80 too.

This code is mean't for work for tutorial and won't be updated as it serves the tutorial series only. Code to train custom datasets will be made available on my other repo here. It may take some time to get the training code working since I am very busy with my college stuff in May.

ayooshkathuria avatar Apr 27 '18 10:04 ayooshkathuria

My classes=1 and the anchors boxs per cell is 3. And I also change the values of variable variable num_classes,and set the num_classes=1.

xiaosuzhang avatar Apr 27 '18 10:04 xiaosuzhang

Are you using the same config file cfg/yolov3.cfg?

ayooshkathuria avatar Apr 27 '18 10:04 ayooshkathuria

Yes! I use the yolov3.cfg based on the the model from https://pjreddie.com/darknet/yolo/, only change the num_classes=1 and filters=18 to train on my own dataset.

xiaosuzhang avatar Apr 27 '18 10:04 xiaosuzhang

That is strange indeed. Something is not quite right with the code. Can you fork the code, apply your changes and host it as a repo on your account. I could then pull your code, and look what's up with the implementation later today. or over the weekend. It would be nice if you uploaded your weights file somewhere too, so i can have the code exactly as same as you.

ayooshkathuria avatar Apr 27 '18 10:04 ayooshkathuria

Also, what are you trying to detect? You need to provide namesfile instead of coco.names, containing the name of the class you want to detect.

ayooshkathuria avatar Apr 27 '18 10:04 ayooshkathuria

can i send the mail to you??

xiaosuzhang avatar Apr 27 '18 10:04 xiaosuzhang

Mail would be all right, but if you fork and host a repo on your account, I can simply issue the fix as a pull request which you can merge.

Do you have any issues with the process of forking, and committing changes, like if you're new to git, I can help. It's better you learn to embrace it coz these skills are very handy. I highly recommend making your own repo so i can pull it.

Otherwise, [email protected] is where you wanna send it. :)

ayooshkathuria avatar Apr 27 '18 11:04 ayooshkathuria

Yes i am a newer to git, and i will learn how to make my own repo. Thank you very much!!

xiaosuzhang avatar Apr 27 '18 11:04 xiaosuzhang

First you go to this repo, and hit the "Fork" button at the top left. This will create a copy of this repo on your own account.

Then, copy the url of your repo (called your fork on my repo), and clone it on your computer. make the changes. Then, do something like this.

git add . 
git commit -m "Changes for custom dataset"
git push origin master

Then the changes would be uploaded to your repo and I can then pull them. I'd highly recommend you to invest a day or two learning about git, as it makes life much easier when you have to adapt other's work for our own purposes. Ping here when you have pushed all the changes.

ayooshkathuria avatar Apr 27 '18 11:04 ayooshkathuria

Here's a link: https://tutorialzine.com/2016/06/learn-git-in-30-minutes

ayooshkathuria avatar Apr 27 '18 11:04 ayooshkathuria

Thank you very much.

xiaosuzhang avatar Apr 27 '18 14:04 xiaosuzhang

I have created the new respository and upload the cfg file and the .name file. The i will send the weights file to your email address because the weights file is very big.

xiaosuzhang avatar Apr 27 '18 14:04 xiaosuzhang

Don't mail me the weights file since mail attachments have size limit. Upload it on Google drive maybe and gimme the link.

ayooshkathuria avatar Apr 27 '18 14:04 ayooshkathuria

OK

xiaosuzhang avatar Apr 27 '18 14:04 xiaosuzhang

the Google drive link of my files: https://drive.google.com/open?id=1EFz-BuPdvyNm0RzIDgOkxlfp4hQhhHqN Thank you again

xiaosuzhang avatar Apr 27 '18 14:04 xiaosuzhang

All right. Gimme a few days to look at it. I'll try to make it work.

ayooshkathuria avatar Apr 27 '18 15:04 ayooshkathuria

I meet the same question ,did you solve it ?

LittleSunH avatar Aug 01 '18 01:08 LittleSunH

https://github.com/ayooshkathuria/pytorch-yolo-v3/issues/19

TiongSun avatar May 30 '20 15:05 TiongSun