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

Extremely inaccurate reading. #2843

Closed
Soccer9001 opened this issue Apr 4, 2019 · 55 comments
Closed

Extremely inaccurate reading. #2843

Soccer9001 opened this issue Apr 4, 2019 · 55 comments
Labels

Comments

@Soccer9001
Copy link

I been trying to train YOLO to read image of fast food trash, but YOLO constantly makes prediction in places that doesn't really make any sense whatsoever. And the more I train, the more crazier YOLO becomes.
Overload
OverPie
This is with an avg loss of 0.09 and over 4000+ iteration.

I do have to mention I used 128 x 128 image to train, but this issue still pops up when I used high resolution image.

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 4, 2019

Check your dataset by using Yolo_mark.

@Soccer9001
Copy link
Author

My dataset seems to be fine and mostly accurate, though is item overlapping a problem?
marker

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 4, 2019

  1. What mAP can you get on Training dataset?
  2. What mAP can you get on Validation dataset?
  3. Can you rename cfg-file to txt and attach it?
  4. If you use Linux, then what parameters did you use in the Makefile?

@Soccer9001
Copy link
Author

I am using Windows.
Can I ask how to get mAP for the dataset?
And I do not understand Question 3.

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 4, 2019

https://github.com/AlexeyAB/darknet#when-should-i-stop-training
darknet.exe detector map data/obj.data yolo-obj.cfg backup\yolo-obj_7000.weights

  1. set valid=train.txt in obj.data file and do this command
  2. set valid=valid.txt in obj.data file and do this command
  3. show your cfg-file

@Soccer9001
Copy link
Author

IoU threshold = 50 %
mean average precision (mAP@0.50) = 0.323183, or 32.32 %
IoU threshold = 50 %
mean average precision (mAP@0.50) = 0.323183, or 32.32 %

cfg1
cfg2

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 4, 2019

IoU threshold = 50 %
mean average precision (mAP@0.50) = 0.323183, or 32.32 %

This is not very bad accuracy for Yolo v2.

  1. What command did you use for training?
  2. What command do you use for detection?
  3. Can you show several images with results of detection on Training images?

@Soccer9001
Copy link
Author

darknet.exe detector train cfg/obj.data cfg/yolo-obj.cfg yolo-obj_last.weights
2.
darknet.exe detector test cfg/obj.data cfg/yolo-obj.cfg yolo-obj_last.weights data/i/20.jpg
3.
B1
B2
B3
B4

@Soccer9001
Copy link
Author

Hello? Are you still there? I don't want to be pushy, but I really need to do this right.

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 5, 2019

Can you share your dataset (images, labels, train.txt, obj.data, obj.names) and your cfg-file? For example, by using Google disk?

@Soccer9001
Copy link
Author

@Soccer9001
Copy link
Author

Is there anything wrong with the data I have, or do I just need to train ever longer (though I feel Yolo gets crazier when I train it for a long time)

@Soccer9001
Copy link
Author

@AlexeyAB are you available now?

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 6, 2019

@Soccer9001 Hi,

Yes, your Yolo v2 model trained very bad.

Also I didn't find test.txt with Test/Valid images. And your train.txt contains much more images than you send me in the zip-archive. So i created my own mixset_train.txt

To avoid overfitting you should use 2x-4x more images, with higher resolution and use separate validation dataset to check the mAP.


I just trained yolov3.cfg Yolo v3 model with width=192 height=192, with recalculated anchors and pre-trained weights darknet53.conv.74 for only 1300 iterations and get mAP = 98.32% that is very high.

cfg-file, commands and mixset_train.txt: YoloStuff.zip

chart

cloud

Detection results are pretty good:

predictions
predictions
predictions
predictions
predictions
predictions
predictions
predictions
predictions

image
image

@Soccer9001
Copy link
Author

Soccer9001 commented Apr 6, 2019

I am trying to re-train my data with better image quality, but I will check out the data you gave me. I will let you know if things work out.

Thank you for your help btw, I was super confused about everything and felt very useless.

@Soccer9001
Copy link
Author

Actually, I am trying out your stuff with a 640 x 640 image now. Should I consider increasing width and height of the cfg file to something higher?

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 6, 2019

@Soccer9001

Yes, set batch=64 subdivisions=32 width=416 height=416 in yolov3-obj.cfg

@Soccer9001
Copy link
Author

When I tried to run with a higher width and height, my computer ran out of memory despite setting it to subdiv 64 already, so I kept it at 192 x 192. Still, here is my result.
chart
AlexBetter
AlexBetter2
There are still some misread burger boxes, but overall much more stable. What should I do at this point to further improve? Should I try increasing subdiv even more so that I can increase width and height? Or do I just run Yolo for longer?

Thank you for your help as always.

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 7, 2019

Start training from the begining with batch=64 subdivisions=64 width=320 height=320 in yolov3-obj.cfg

And train at least 6000 iterations.

@Soccer9001
Copy link
Author

Okay, I will do that when I get the chance.

@Soccer9001
Copy link
Author

It is possible for me to run your yolo on a Jupyter notebook? My computer isn't the best but I have access to a good Jupyter notebook.

If so, can you teach me how to run it there? I am very new to Jupyter.

@Soccer9001
Copy link
Author

Hey @AlexeyAB , I am trying to integrate Yolo into a html to run, so I am wondering if it is possible to run yolo detector via a python script instead of having to run it from commard prompt everytime.

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 8, 2019

@Soccer9001
Copy link
Author

Hi @AlexeyAB , sorry for the long wait, I hope you are still getting this. Here is my results. I couldn't run the training program even at 320 x 320, so I went to 256 x 256 instead. The results are somewhat mixed. It is better than v2 training, but it is still making a lot of mistakes and missing a lot of objects.
chart
P4
P5
P6
P8
P9
P10
P121
P1
P2
P3

@Soccer9001
Copy link
Author

What should I do now to further improve the model?

@Soccer9001
Copy link
Author

Here is the sample data I used to train.

https://drive.google.com/file/d/1K3Ry86WUabhH9gRsXxiyFhAf-xhmULHN/view?usp=sharing

@Soccer9001
Copy link
Author

Hello @AlexeyAB? Are you still there?

@Soccer9001
Copy link
Author

@AlexeyAB Hello? Maybe I should close this thread and create a new one?

@AlexeyAB
Copy link
Owner

@Soccer9001 Hi,

  • Can you attach cfg-file that you used?

  • Did you use random=1 for training?

  • Did you use default anchors, your calculated anchors, or anchors from cfg-file from archive YoloStuff.zip Extremely inaccurate reading. #2843 (comment) ?

  • What command did you use for training?

  • What params did you use in Makefile?

@Soccer9001
Copy link
Author

Hello @AlexeyAB

  1. Here.
    ABzip.zip

  2. I believe I did. But to be specific, which random are you talking about?

  3. The only thing I touched from the cfg was subdiv, height and width.

  4. darknet detector train obj.data yolov3-obj.cfg darknet53.conv.74 -map

  5. What is a Makefile?

@AlexeyAB
Copy link
Owner

  • What GPU do you use?

  • Try to train with default anchors

    anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326

@Soccer9001
Copy link
Author

MyRig

So all I have to do is replace line 782 with the line you provided me then run the training program again?

@AlexeyAB
Copy link
Owner

Do you have GTX 1050 with only 3GB GPU-RAM?

Change all 3 lines:

  1. anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326

  2. anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326

  3. anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326

@Soccer9001
Copy link
Author

GPUram
So only those three lines need to change, anything else?

@AlexeyAB
Copy link
Owner

Only these 3 lines

@Soccer9001
Copy link
Author

Okay, should I continue with the 6000 int weight or start from the beginning

@AlexeyAB
Copy link
Owner

Start from the begining

@Soccer9001
Copy link
Author

Soccer9001 commented Apr 22, 2019

@AlexeyAB Hello again. The result is slightly better, but still have some error. Anything else I can do to improve? My mAP seems to be capped at 60% to 78%, how can I improve it?.
chart
predictions
predictions
predictions
predictions
predictions
predictions
predictions
predictions

@AlexeyAB
Copy link
Owner

AlexeyAB commented Apr 22, 2019

@Soccer9001 Hi,

  • You can add images with slightly randomly rotated an empty tray (and empty txt label files)

  • You can set:

max_batches = 12000
policy=steps
steps=10000,11000

  • What soft did you use to get cropped objects (like cv::grabCut())?
    N8C019v2

  • Latter I will add features: rotation and bluring for Training Yolo, so it will help too:

angles=
blur=

@Soccer9001
Copy link
Author

Soccer9001 commented Apr 23, 2019

I used "medibang paint pro" to crop the pictures. I will try to take pictures of an empty tray later.

Those data is meant to be in the cfg file right?

You are adding new features? Will I have to re download everything to take advantage of it? When will it be out? I have a deadline within about 2 weeks.

What should I do now? Should I restart training again or wait for your new features?

@AlexeyAB
Copy link
Owner

@Soccer9001

Those data is meant to be in the cfg file right?

Yes.

You are adding new features? Will I have to re download everything to take advantage of it? When will it be out? I have a deadline within about 2 weeks.

What should I do now? Should I restart training again or wait for your new features?

If I add this feature this week, I will tell you.

Now you can try to train by using yolov3-spp.cfg with default anchors instead of yolov3.cfg.

  • Just change filters= and classes= for your number of objects in all 3 [yolo]-layers in cfg
  • And set in cfg in [net] section
max_batches = 12000
policy=steps
steps=10000,11000

@Soccer9001
Copy link
Author

Is there anything I need to change in the yolov3-spp.cfg file?
Just three class and filter, then max_batch + step?
Anything about anchor needs change?

@AlexeyAB
Copy link
Owner

Is there anything I need to change in the yolov3-spp.cfg file?
Just three class and filter, then max_batch + step?

Yes

Anything about anchor needs change?

Use default

@Soccer9001
Copy link
Author

The train process is taking a while (it is gonna take about two days to run the entire thing), but I want to make a quick update. Still has a mAp ceiling, but I haven't used the weight yet.
chart

@Soccer9001
Copy link
Author

Here is a link to the data set I am using.
https://drive.google.com/file/d/1xupf7i-In_PSnJjMMRqp4eiJYdNSsafq/view?usp=sharing

@Soccer9001
Copy link
Author

Hi @AlexeyAB , bad news. I tried out the new weight, and this is overall a steo backwards. The result is similar to the one before, but now missing french fries and circling more non existent burger boxes.
chart
predictions
predictions

@Soccer9001
Copy link
Author

Hello @AlexeyAB, are you there? Any update on your new feature as well as what I should do from here?

@AlexeyAB
Copy link
Owner

AlexeyAB commented May 3, 2019

@Soccer9001 Did you train yolov3-spp.cfg width=608 height=608 with default anchors?

@Soccer9001
Copy link
Author

I didn't try 608x608 because I ran out of memeory with the other one. I only set to 256x256. I could try it later.

I didn't touch the anchors, do you want me to replace the anchors in the file with the one you gave me previously?

@Soccer9001
Copy link
Author

@AlexeyAB Hello. I have tried to train with 608 x 608, unfortunately, it says Cuda is out of memory and recommend me to set subdivision to 64 even though I have already set it to 64.

@Soccer9001
Copy link
Author

@AlexeyAB Hello? Is there anything else I can do?

@Soccer9001
Copy link
Author

@AlexeyAB Hello? Please respond.

@AlexeyAB
Copy link
Owner

@Soccer9001 Hi,

Download the latest version of Darknet, compile it with GPU, cuDNN and OpenCV.
Take the best cfg-file that you got previously, add blur=1 parameter in the [net] section and train it from the begining.

@Soccer9001
Copy link
Author

Hi, I am done with Yolo right now for the most part. The accuracy wasn't the best but it was acceptable at the end. If I ever need your help again, I will contact you again. Thank you for your help and I will be closing this thread now.

@AlexeyAB
Copy link
Owner

AlexeyAB commented Jun 2, 2019

Hi, What mAP did you get at the end?

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

No branches or pull requests

2 participants