thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

Detect more than one same object with tiny-YOLO #765

Open Zonsor opened 6 years ago

Zonsor commented 6 years ago

As title, I use yolov2-tiny to detect license plate. There are more than one plate in the images. But YOLO just detect one plate.

I set class=1 to only detect plate. And I only have few train data which have more than one plate. Is it the reason for that?

LDSt commented 6 years ago

The amount of classes you train on is not related to how many objects (of the same class) the classifier can detect in your image, neither is the amount of objects per training image. Try training on a larger dataset with a bigger variety in pose/size of the license plates and see if it improves on the detections. What you can also do is reduce the threshold when testing your model to increase the predicted bounding boxes.

Zonsor commented 6 years ago

@LDSt Thank you for your advice, I will try it. And I forgot that tfnet.return_predict(img) returns a list. I just use one index on result. So when I detect the images, It only shows one result.

kevin9kai commented 5 years ago

@Zonsor Were you able to get it working? I'm getting a similar error as seen below with sand boils. Render_Rural_Version_4_Miday_ 383 I trained on 948 images, do I need to train on more images? @LDSt I tried lowering my threshold and it does give me more boxes but most of them are incorrect, is there another option I can change?

Thanks

Zonsor commented 5 years ago

@kevin9kai Yeah! it works. And the reason is that I forgot that tfnet.return_predict(img) returns a list. So maybe you should notice the length of the list, or lower the threshold to get more results.

kevin9kai commented 5 years ago

@Zonsor Congrats on getting it working! what is the tfnet.return_predict(img) you are talking about? Is it a command, part of the code or something else? So I tried lowering the threshold but then I would get more labels/boxes but they would be all over the place, does that mean I don't have enough training data?

Thanks for the reply

skofot commented 5 years ago

@kevin9kai tfnet.return_predict(img) is a piece of the code used to run Darkflow from a separate python program. It returns a list of results containing at least confidence and coordinates. Below is the official example on how to use it.


from darkflow.net.build import TFNet
import cv2

options = {"model": "cfg/yolo.cfg", "load": "bin/yolo.weights", "threshold": 0.1}

tfnet = TFNet(options)

imgcv = cv2.imread("./sample_img/sample_dog.jpg")
result = tfnet.return_predict(imgcv)
print(result)