miércoles, 9 de septiembre de 2020

Project 3 part 1 Mask / No mask, train a Yolov3 cnn with Darknet

 Project 3 part 1 "Mask / No mask", trained with Darknet and Yolov3.cfg


Video output from test-video1 with standard darknet rectangles:


Video output from test-video1.mp4:




Video output from test-video2 with standard darknet rectangles:


Video output from test-video1.mp4: 





Task 1: Train the object detector using Yolo v3 [70 Marks]

We had shared a notebook for training a custom object detector in the last section. You can use that as a reference and make relevant changes to the files and code to train the network.

HINT: You will have to make a few changes to the different files before training as given in Step 7 in the Notebook. You might also need to change some code in Step 4.

You also need to run the model on the videos given above. 

HINT: You can use the following command to run the model on the video

!./darknet detector demo yolo_mask.data yolo_mask.cfg backup/yolo_mask_best.weights test-video1.mp4 -thresh .6 -out_filename out-vid1.avi -dont_show 

I wrote a notebook with the basic pipeline for train a yolov3 cnn with Darknet in Google colab, this are the steps:

1.- I created a folder "/yolov3" in Google drive to upload the test and output files.

2.- Mount a google drive and check its files.

3.- Clone, configure and compile darknet.




4.- Configure yolov3.cfg file.


5.- Create names and data files and save to Google drive.



6.- Create a folder where unzip the image dataset.


7.- Create a train.txt file.


8.- Download pre-trained weights for the convolutional layers file.


9.- Start training.


10.- Object detection with the test images.


Look at the right, the man wearing a black mask, the mask is not detected with Yolov3



Look at the girl in black, is not detected with yolov3.



11.- Object detection with the test videos.



Youtube link: https://youtu.be/xGH5R71luBc 



Youtube link: https://youtu.be/YaLWdxp-xOw 

I wished to run all the yolov4 using "activation: mist" in one notebook at colab, I couldn’t do  that because the OpenCV version in colab was 4.1.2, so I left this project aside for several days, when I went back I understood from the hint in the specifications that darknet is a polymorph program, it can do train and test on images, videos and camera stream, it draws the standard rectangles over the images and don’t need OpenCV to do that. I trained yolov3 and yolov4 again; here are some screenshots from the notebook. I changed the file image.c from darknet source files, so the rectangle on people with facemask is green and magenta(danger) with No mask.

Here are the images from yolov3 and the standard darknet rectangles:
predictions-image1.jpg

predictions-image2.jpg

predictions-image3.jpg

predictions-image4.jpg

The videos with the Darknet standard rectangle:

The prediction for test-video1:

The prediction for test-video2:


No hay comentarios:

Publicar un comentario