AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.65k stars 7.96k forks source link

BWN networks #1940

Open clydebailey opened 5 years ago

clydebailey commented 5 years ago

@AlexeyAB I have successfully trained the XNOR network for yolov2-tiny and reduced the weight file by more than 10x. The mAP is amazing too with a precision of 69.54 on a single class(person) from the pascal dataset. Thanks again!

Now I would like to train a network with only weight binarizations and no input binarizations, a BWN basically. How would I go about training that? Any help?

AlexeyAB commented 5 years ago

@clydebailey Hi,

Just try to set binary=1 instead of xnor=1 in the [convolutional] layers in cfg-file. But I didn't test it well.

clydebailey commented 5 years ago

@AlexeyAB Ok I will try that .

ghimiredhikura commented 5 years ago

@clydebailey Hi,

Can you share details on how you trained yolov2-tiny XNOR network for single class? I am also trying to train Tiny-Yolov2 XNOR net, but so far I got only ~27% mAP in VOC test set. Here is my mAP results.

image

AlexeyAB commented 5 years ago

@ghimiredhikura Do you use this cfg-file? https://github.com/AlexeyAB/darknet/blob/master/cfg/tiny-yolo_xnor.cfg

ghimiredhikura commented 5 years ago

Hello @AlexeyAB,

I am training in voc dataset, so I used tiny-yolo_xnor-train.txt My voc.data file: voc.data.txt

Training command

darknet.exe detector train XNOR/voc.data XNOR/tiny-yolo_xnor-train.cfg XNOR/yolov2-tiny-voc.conv.13 -map
AlexeyAB commented 5 years ago

@ghimiredhikura

ghimiredhikura commented 5 years ago

@AlexeyAB

  • How many iterations did you train?

I did train more then 200000 iterations.

This way, I think mAP will be improved, but I am trying to train network similar to this one for hardware implementations. A Lightweight YOLOv2: A Binarized CNN with A Parallel Support Vector Regression for an FPGA image Therefor I can't use only 3 layers as XNOR layers.

As I also trained darknet19 classifier in XNOR #2062 form, but still no luck yet!

Any suggestions please!

AlexeyAB commented 5 years ago

@ghimiredhikura

If I understand correctly, they try to use network like this: yolov2_xnor_fpga.cfg.txt - try to train this model.

This is hybrid of yolov2.cfg and yolov2-tiny.cfg. With only 1st and two last float layers, other XNOR layers.

image

Also check that you uncommented difficult in the voc.data file before doing ./darknet detector map...:

classes= 20
train  = data/train_voc.txt
valid  = data/2007_test.txt
difficult = data/difficult_2007_test.txt
names = data/voc.names
backup = backup/
ghimiredhikura commented 5 years ago

@AlexeyAB,

Thank you for your quick response. Now I am training network as you suggested. I used pretrained weights from darknet19 classifier.

image

Here is the training progress after ~50000 iterations! mAP is just 1%!

chart

AlexeyAB commented 5 years ago

@ghimiredhikura

Update your code from Github. And recompile.


Download this weights: http://pjreddie.com/media/files/yolov2-voc.weights

Do: ./darknet partial cfg/yolov2-voc.cfg yolov2-voc.weights yolov2.conv.23 23

And train using yolov2.conv.23 pre-trained weights file.

ghimiredhikura commented 5 years ago

@AlexeyAB,

Updated code from Github and run training over the weekend using yolov2.conv.23 extracted from http://pjreddie.com/media/files/yolov2-voc.weights.

Here is training result and mAP status: chart Although in training graph, the mAP seems to be wrong, I calculated mAP using light_yolo repo (ofcourse using latest weights), but unfortunately it is still very low! image

AlexeyAB commented 5 years ago

@ghimiredhikura There is a bug in mAP calculation during Training if is used CUDNN=1. I will solve it.

Also what GPU do you use? And did you set CUDNN_HALF=0 in the Makefile?

ghimiredhikura commented 5 years ago

My gpu is 1080 ti. And training in Win 10 with visual studio.

AlexeyAB commented 5 years ago

@ghimiredhikura

I added fix. I hope now mAP calculation during Training is fixed. Update your code from GitHub.


I calculated mAP using light_yolo repo (ofcourse using latest weights), but unfortunately it is still very low!

I do not know why this is so. Try to use this cfg-file, I modified it: yolov2_xnor_fpga.cfg.txt And try to train it until mAP stops.

image

ghimiredhikura commented 5 years ago

@AlexeyAB I was training with updated code and new cfg file you attached above, but mAP is still very low!

chart

AlexeyAB commented 5 years ago

@ghimiredhikura Hi,

./darknet detector train cfg/voc.data yolov2_xnor_fpga_new.cfg.cfg yolov2.conv.23

image

ghimiredhikura commented 5 years ago

@AlexeyAB, Hi,

Sorry for delay in getting back. The network you attached above have conv layers in first few layers. What I am looking is ConvX or ConvXB in all layers except first and last. So it will not be suitable for my problem.

Lets get back to my training progress. After training darknet19-xnor for two weeks (accuracy was 67%), I attached region layer and built the following network. capture Now training with voc dataset below is the training curve with mAP values. mAP improved as compared to tiny-yolov2-xnor network (25%), but still not that good! darknet19-xnor-chart

I will update progress.

In addition, as I am trying to implement this paper [A Lightweight YOLOv2: A Binarized CNN with A Parallel Support Vector Regression for an FPGA], I am struggling to prepare proper target values for SVR training. If we replace region layer with svr to predict 125 outputs in each cell, do you have any idea how we have to prepare training outputs (tx,ty,tw,th,conf,prob(20)) for SVRs training. Any suggestion will be greatly appreciated. Thank you.

AlexeyAB commented 5 years ago

@ghimiredhikura Hi,

Lets get back to my training progress. After training darknet19-xnor for two weeks (accuracy was 67%), I attached region layer and built the following network. Now training with voc dataset below is the training curve with mAP values. mAP improved as compared to tiny-yolov2-xnor network (25%), but still not that good!

I am struggling to prepare proper target values for SVR training. If we replace region layer with svr to predict 125 outputs in each cell, do you have any idea how we have to prepare training outputs (tx,ty,tw,th,conf,prob(20)) for SVRs training.

I will think how to do it in the best way.

ghimiredhikura commented 5 years ago

@AlexeyAB Hi,

Here is darknet19-xnor cfg file that I used. darknet19-XNOR.cfg.txt

I used ILSVRC2012 dataset for training.

Yes, please let me know how it will be the best way to replace REGION layer with SVR.

Best, Deepak

ghimiredhikura commented 5 years ago

@AlexeyAB Hello,

Have you given any thoughts on how to replace region layer with SVR to predict box position and object class using linear SVRs? Any suggestions will be greatly appreciated.

Thanks.

Sudhakar17 commented 5 years ago

@clydebailey @AlexeyAB https://github.com/AlexeyAB/yolo2_light/blob/master/bin/tiny-yolo-obj_xnor.cfg I used this config file to train two class model. dataset : 1000 images for each class XNOR model : 3% mAP BW : 24% FP: 27%

results after 2k iterations. all models are 61MB. How to reduce the weights file size of each model?

francis2tm commented 4 years ago

@ghimiredhikura

If I understand correctly, they try to use network like this: yolov2_xnor_fpga.cfg.txt - try to train this model.

This is hybrid of yolov2.cfg and yolov2-tiny.cfg. With only 1st and two last float layers, other XNOR layers.

image

Also check that you uncommented difficult in the voc.data file before doing ./darknet detector map...:

classes= 20
train  = data/train_voc.txt
valid  = data/2007_test.txt
difficult = data/difficult_2007_test.txt
names = data/voc.names
backup = backup/

Hey, @AlexeyAB Do you know any yolo xnor-net implementation in a FPGA? With open-source software

Thanks!