AlexeyAB / darknet

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

SlimYOLOv3: Narrower, Faster and Better for Real-Time UAV Application #3732

Open keko950 opened 5 years ago

keko950 commented 5 years ago

https://arxiv.org/abs/1907.11093

sctrueew commented 4 years ago

@WongKinYiu Hi,

Could you explain in more detail? and what is the command I have to use?

WongKinYiu commented 4 years ago

step 1. train sparse yolo 500k epochs step 2. prune the model step 3. train prune yolo 500k epochs step 4. go to step 2, or stop

sctrueew commented 4 years ago

step 1. train sparse yolo 500k epochs step 2. prune the model step 3. train prune yolo 500k epochs step 4. go to step 2, or stop

Thanks, I could do it.

sctrueew commented 4 years ago

@gmayday1997 Hi,

Thanks for sharing this code. I could add prune.cpp to this repo and I have created a model and I've tested it with OpenCV-dnn that already takes ~500ms and now takes ~220ms on my PC. I'm using v3-Tiny network.

varghesealex90 commented 4 years ago

step 1. train sparse yolo 500k epochs step 2. prune the model step 3. train prune yolo 500k epochs step 4. go to step 2, or stop

Can you explain what step 1: train sparse yolo means?

lq0104 commented 4 years ago

This paper suggests that a trained, pruned, fine-tuned model does not perform any better than a model using the same pruned cfg, random intitial weights and then trained from scratch. This doesn't mean that there is no value in pruning - it seems like it might be an effective way to automatically discover more efficient network architectures for a particular dataset? but it does imply that maybe pruning the same model on various datasets and comparing the results - what kind of thing tends to be preserved and what tends to be pruned away? Could be a nice way to discover a more efficient general-purpose architecture?

@LukeAI Although I didn't do slim train, but I think your words about train from prune and train from scratch is meaningful. I think the slimyolov3 paper has a logic mislead, he compared the results between yolov3-spp-prune and yolov3-tiny with nearly same FLOPs, but the reason of the results yolov3-spp-prune better than yolov3-tiny maybe because spp has deeper network architecture, rather than this slim strategy. so I think the meaningful compare is train from prune and train from scratch, but the paper doesn't supply.
On the other hand, if this paper gives a nice way to discover a more efficient general-purpose architecture, but why wouldn't I use NAS? I think the NAS technology is more mature to find efficient architecture, although this need more and more compute resource.

LukeAI commented 4 years ago

I got pretty good results training a slimyolo from scratch - I only lost a little bit of accuracy compared to the full-fat edition. I actually don't need the FPS and increasing image resolution doesn't help accuracy much in my use-case so I don't use it but I would use it rather than tiny-yolov3 if I needed that speed. I've If you have the GPU hours to do a NAS and discover a fantastic new efficient architecture for us then please go for it :)

MuhammadAsadJaved commented 4 years ago

@LukeAI the results is good using the pruned model provided by https://github.com/PengyiZhang/SlimYOLOv3

predictions

He did not provide the pruned model. Can you send me the link where is his trained pruned model? @WongKinYiu

WongKinYiu commented 4 years ago

@MuhammadAsadJaved

They removed all of models in 25 Oct 2019.

MuhammadAsadJaved commented 4 years ago

@WongKinYiu ohh I see. OK Thank you.

MuhammadAsadJaved commented 4 years ago

step 1. train sparse yolo 500k epochs step 2. prune the model step 3. train prune yolo 500k epochs step 4. go to step 2, or stop

Can you explain what step 1: train sparse yolo means?

@WongKinYiu @zpmmehrdad @varghesealex90
Can you please explain step 1 , what is Sparse training? I am confused. i trained original YOLOV3 on custom dataset, then pruned the model should i train it again normally ? or the sparse meaning something different?

WongKinYiu commented 4 years ago

@MuhammadAsadJaved

Sparse training means add sparse constraint of weights when training the model. so there are many value of weights are near to zero, prune those weights in step 2 would not decreases so much accuracy.

MuhammadAsadJaved commented 4 years ago

@WongKinYiu OK got it. How to do this procedure? i am using original YOLOV3, I already trained for 100K epoch. Is it convenient to add wechat? if so then please add me. 13263164767

WongKinYiu commented 4 years ago

@MuhammadAsadJaved

I do not use wechat, and the command for doing spare training is at: https://github.com/PengyiZhang/SlimYOLOv3#2-sparsity-training detail: https://github.com/PengyiZhang/SlimYOLOv3/tree/master/yolov3

MuhammadAsadJaved commented 4 years ago

@WongKinYiu OK. Thank you so much.

MuhammadAsadJaved commented 4 years ago

@gmayday1997 , The pipeline used is

1)Train full model

2) Prune

3) Fine-Tune pruned model

i see there the drop in accuracy is minimal when looking a the gain in FPS.

Can you please report the performance (mAP) after step 2 i.e. before fine-tuning. Using the code provided by the SLIM YOLOv3 authors, I get mAP of 0% with the prune.weights before fine-tuning. Is this normal?

@varghesealex90 Hi, You mean you did not use the sparsity training? (https://github.com/PengyiZhang/SlimYOLOv3#2-sparsity-training)

You only use 1-Train original YOLOV3 model, 2-Prune trained YOLOV3 model 3- Fine tune Pruned YOLOV3 model?

joel5638 commented 4 years ago

@gmayday1997 @AlexeyAB @varghesealex90 Can we skip the first step of normal training as we already have the Yolov3.weights?

joel5638 commented 4 years ago

@WongKinYiu When I run the pthon3 sparsity with required arguments. Nothing seems to happen. I dont see any error neither do i see any result. I just gets processed. Is that the correct way?

WongKinYiu commented 4 years ago

i think yes.