AlexeyAB / darknet

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

Creating a teacher-student network. #2640

Open clydebailey opened 5 years ago

clydebailey commented 5 years ago

Hello @AlexeyAB. I have trained a heavy network (yolov3) and a tiny network (tiny_yolov3). How can I connect them to act as a teacher-student network.

Regards! Clyde

AlexeyAB commented 5 years ago

@clydebailey Hi,

Can you explain it with more details, what do you mean?


Currently, you can use Pseudo labeling concept from fast.ai: https://github.com/AlexeyAB/darknet/issues/717

For example, you have two models yolov3.cfg/weights & yolov3-tiny.cfg/weights.

(It will create labels (txt-files) for each image in the new_train.txt)

clydebailey commented 5 years ago

Hello @AlexeyAB, thanks for your prompt reply! Yes for the time being I am using the pseudo labelling concept to train my student (tiny-yolov3 ) network from my teacher (yolov3) network. But I was looking at a particular framework. Could you help me in implementing this:

  1. A big and a small network is implemented on a SoC (raspberry pi)
  2. The Small network will run all the time on this SoC
  3. The Big network should run periodically to train the small network. This would reduce the power consumption and inference time.
  4. The periodicity could be after every t days/hours

Thanks

AlexeyAB commented 5 years ago

@clydebailey Hi,

The Big network should run periodically to train the small network. This would reduce the power consumption and inference time.

Do you want to continue to train a small network on CPU (SoC (raspberry pi)) ?

clydebailey commented 5 years ago

Hello @AlexeyAB

  1. I want to use the small network to make inferences on the fly at all times on the CPU
  2. The big network needs to train periodically after say 3 days and use its output to train the small network which will restore its weights to the newly trained ones
AlexeyAB commented 5 years ago

@clydebailey Hi,

  1. So just try to train two model yolov3-tiny.cfg and yolov3.cfg

  2. Then run yolov3-tiny.cfg for detection from your video

  3. Use script, that periodically kills darknet-process with yolov3-tiny.cfg

  4. After that (or in parallel) you can run Yolo_mark that collects each 100 frame from Network-camera video-stream and saves it as jpg-image: ./yolo_mark data/img cap_video test.mp4 100

  5. then run Detection on these collected jpg-images by using big model yolov3.cfg with pseudo-labeling: ./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights -thresh 0.25 -dont_show -save_labels < data/new_train.txt

  6. then run continue of Training on these labeled images ./darknet detector train cfg/coco.data cfg/yolov3.cfg yolov3.weights

muck27 commented 5 years ago

Sorry for the late reply and thanks again for your help @AlexeyAB Respect from India :)