Intro
Dealing with video datasets, especially with regard to detection of AI-based phony items, is really tough due to appropriate frame choice and face detection. To approach this difficulty from R, one can utilize abilities provided by OpenCV, magick
, and keras
Our method includes the following ensuing actions:
- checked out all the videos
- capture and extract images from the videos
- spot faces from the drawn out images
- crop the faces
- develop an image category design with Keras
Let’s rapidly present the non-deep-learning libraries we’re utilizing. OpenCV is a computer system vision library that consists of:
On the other hand, magick
is the open-source image-processing library that will assist to check out and draw out helpful functions from video datasets:
- Check out video files
- Extract images per second from the video
- Crop the faces from the images
Prior to we enter into a comprehensive description, readers need to understand that there is no requirement to copy-paste code portions. Since at the end of the post one can discover a link to Google Colab with GPU velocity. This kernel enables everybody to run and replicate the exact same outcomes.
Information expedition
The dataset that we are going to examine is supplied by AWS, Facebook, Microsoft, the Collaboration on AI’s Media Stability Steering Committee, and different academics.
It includes both genuine and AI-generated phony videos. The overall size is over 470 GB. Nevertheless, the sample 4 GB dataset is individually offered.
The videos in the folders remain in the format of mp4 and have different lengths. Our job is to identify the variety of images to record per second of a video. We typically took 1-3 fps for each video.
Note: Set fps to NULL if you wish to draw out all frames.
video = magick:: image_read_video(" aagfhgtpmv.mp4", fps = 2)
vid_1 = video[[1]]
vid_1 = magick:: image_read( vid_1) %>>% image_resize(' 1000x1000')
We saw simply the very first frame. What about the rest of them?
Taking a look at the gif one can observe that some phonies are really simple to distinguish, however a little portion looks quite practical. This is another difficulty throughout information preparation.
Face detection
In the beginning, face areas require to be identified through bounding boxes, utilizing OpenCV. Then, magick is utilized to instantly extract them from all images.