scieee AI-readable full text Open interactive document viewer

Integrating low-level motion cues in deep video saliency

Caselles Rico, Pol

Abstract

This thesis investigates the importance of motion when predicting saliency in videos. Naturally, humans observe both dynamic and static objects. When we are focused on watching a video, we tend to keep our eyes on the objects that are moving in the scene, items that we quickly recognize, as well as to those that attract our attention. In this work, different experiments are presented to corroborate this implication. Various approaches will be shown implementing an adaptation of the SalBCE neural network by using only motion. A simple implementation is proposed for the generation of saliency maps using previously extracted static and dynamic information from the images. The DHF1K dataset has been used for the experiment's realization.

Full text

Integrating low-level motion cues in deep video saliency Pol Caselles Rico Department of Signal Theory and Communications, Engineering of Technologies and Services of Telecommunication (ETSETB) Polytechnic University of Catalonia Supervisor Kevin McGuinness and Xavier Gir´o-i-Nieto In partial fulfillment of the requirements for the degree of Bachelor of Science in Engineering in Electrical Engineering June 24, 2019 Acknowledgements I would like to thank my supervisors, Xavi Gir´o-i-Nieto and Kevin McGuinness, for all the guidance and help provided during the realization of the thesis. Also, I would like to thank Enric Moreus, and Juanjos help because while I was learning deep learning they helped me having a well-organized project using the newest tools. Abstract This thesis investigates the importance of motion when predicting saliency in videos. Naturally, humans observe both dynamic and static objects. When we are focused on watching a video, we tend to keep our eyes on the objects that are moving in the scene, items that we quickly recognize, as well as to those that attract our attention. In this work, different experiments are presented to corroborate this implication. Various approaches will be shown implementing an adaptation of the SalBCE neural network by using only motion. A simple implementation is proposed for the generation of saliency maps using previously extracted static and dynamic information from the images. The DHF1K dataset has been used for the experiment’s realization. Abstract Esta tesis investiga la importancia del movimiento al predecir el saliency en los videos. Naturalmente, los humanos observan objetos tanto dinmicos como est´aticos. Cuando nos enfocamos en mirar un video, tendemos a mantener la vista en los objetos que se mueven en la escena, los elementos que reconocemos r´apidamente, as´ı como aquellos que atraen nuestra atenci´on. En este trabajo, se presentan diferentes experimentos para corroborar esta implicaci´on. Se mostrar´an varios enfoques implementando una adaptaci´on de la red neuronal SalBCE utilizando solo movimiento. Se propone una implementaci´on simple para la generaci´on de mapas de saliency utilizando informaci´on est´atica y din´amica extra´ıda previamente de las im´agenes. El conjunto de datos DHF1K ha sido utilizado para la realizaci´on del experimento. Abstract Aquesta tesi investiga la import`ancia del moviment en predir el saliency en els v´ıdeos. Naturalment, els humans observen objectes tant din`amics com est`atics. Quan ens enfoquem en mirar un v´ıdeo, tendim a mantenir la vista en els objectes que es mouen en l’escena, els elements que reconeixem r`apidament, aix´ı com aquells que atreuen la nostra atenci´o. En aquest treball, es presenten diferents experiments per corroborar aquesta implicaci´o. Es mostraran diversos enfocaments implementant una adaptaci´o de la xarxa neuronal SalBCE utilitzant sol moviment. Es proposa una implementaci´o simple per a la generaci´o de mapes de saliency utilitzant informaci´o est`atica i din`amica extreta pr`eviament de les imatges. El conjunt de dades DHF1K ha estat utilitzat per a la realitzaci´o de l’experiment. Contents 1 Introduction 1 1.1 Project overview and goals . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 WorkPlan.................................... 3 1.3 Work Breakdown Structure . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4 Milestonelist .................................. 5 1.5 Time Plan (Gantt diagram) . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 State of the art 7 2.1 Technical Background, Architecture used . . . . . . . . . . . . . . . . . . . 8 2.1.1 SalGAN ................................. 8 2.1.2 SalBCE ................................. 9 2.1.3 ACLNet................................. 10 2.1.4 SalBCE motion approach . . . . . . . . . . . . . . . . . . . . . . . 11 2.1.4.1 One stream approach . . . . . . . . . . . . . . . . . . . . . 12 2.2 WorkingDataset ................................ 13 2.3 Metricsused................................... 14 3 Techniques studied 19 3.1 Frame Differencing (FD) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.2 OpticalFlow(OF) ............................... 22 3.3 Exponential Moving Average . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.4 ShotDetection ................................. 28 3.5 StatisticalParameters ............................. 33 v CONTENTS 4 Experiments 35 4.1 Obtainingthemovement............................ 36 4.2 Motion integration with static objects . . . . . . . . . . . . . . . . . . . . . 40 4.3 Optical Flow implementation . . . . . . . . . . . . . . . . . . . . . . . . . 45 4.4 Motion with neural networks approach . . . . . . . . . . . . . . . . . . . . 50 5 Environment 54 6 Budget 56 7 Ethics 57 8 Conclusion and Future Developement 59 References 63 vi List of Figures 1.1 Work Breakdown Structure of the project . . . . . . . . . . . . . . . . . . 4 1.2 Gantt Diagram of the project . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1 SalBCE model architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2 ACLNet architecture composed of VGG-16, Attention module and ConvL- STM........................................ 10 2.3 The full architecture used. Two SalBCE in parallel, and a custom CNN head........................................ 12 2.4 ROC curve and its density function representation . . . . . . . . . . . . . . 15 2.5 Variation of metrics selected for saliency prediction evaluation . . . . . . . 18 3.1 Left image is the video 007 of the DHF1K dataset, frame 99. Right image is the FD saliency map between frames 99 and 100 . . . . . . . . . . . . . 21 3.2 Optical Flow interpretation. Left image is the frame at time t. Middle image is the frame at time t+ 1. Right image is the Optical Flow output. . 22 3.3 Optical Flow Color axis map . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.4 Left image is an example of two consecutives frames. Right image is the Optical Flow output between those images. . . . . . . . . . . . . . . . . . . 26 3.5 Steps of edge change ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.6 Steps of edge change ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 4.1 examples of the frame differential heatmap . . . . . . . . . . . . . . . . . . 36 4.2 Comparison of results in the dataset validation . . . . . . . . . . . . . . . . 37 4.3 Comparison of results in the dataset validation . . . . . . . . . . . . . . . . 38 4.4 Comparison of the results of a given video of the validation dataset . . . . 39 4.5 Comparison of kurtosis with the good results . . . . . . . . . . . . . . . . 42 vii 1.4 Milestone list 1.4 Milestone list Tasks Description Date State of the art Realization of the module in Machine Learning to begin to obtain concepts about Computer Vision. Read and study the work that Juanjo did. Study the appropriate papers to understand the basis of the project. 14.02 - 28.02 Become familiar with the environment Work with Juanjo to understand his code and how to execute it in the work environment of the Insight Center. Become familiar with Machine Learning concepts. 27.02 - 01.03 Code, test, verify the Optical Flow Read the documentation to learn the Optical Flow concept. Compute the Optical Flow of the entire dataset. 04.03 - 11.03 Compute frame differencing Implement the difference of frames as another method to measure the movement. Apply the EMA taking into account the change of scene. 4.03 - 8.03 Generation of datasets Generate images where the three channels corresponding to the RGB, the magnitude of the difference of frames are stored, in the other two channels the position x and y of the Optical Flow. 11.03 - 28.04 Comparison Train the Juanjos model with the images as inputs where only the movement between frames is taken into account. Frame differencing and Optical Flow 08.04 - 01.05 A fusion of the two models Implement a simple structure that has as inputs the saliency maps generated with the static information of the images and the Optical Flow obtained with SalBCE. 01.05 - 20.05 One stream approach Implement SalBCE that has as inputs the saliency maps generated with the static information of the images and the dynamic information 30.05 - 15.06 Table 1.1: Milestone list 5 1.5 Time Plan (Gantt diagram) 1.5 Time Plan (Gantt diagram) Figure 1.2: Gantt Diagram of the project 6 Chapter 2 State of the art Summary The background concepts will be described as well as the necessary information to understand why the initial hypothesis and how to start developing the idea. The architectures used will also be presented, the dataset from which the whole study has been developed as well as the breakdown of the metrics used with their respective mathematical development. The aim is to introduce the initial concepts that led to the beginning of the basic idea of the importance of motion in the prediction of saliency. 7 2.1 Technical Background, Architecture used 2.1 Technical Background, Architecture used 2.1.1 SalGAN Visual Saliency Prediction with Generative Adversarial Networks (SalGAN[4]) model was proposed as an adversarial training for visual salience prediction (GAN) instead of onadversarial training (BCE) and even combine them to obtain better results in stability and convergence rate. In this study, they proposed the SalGAN model for visual saliency prediction. They concluded that the proposed GAN training approach is generic and that using its structure they could apply to improve the performance of other saliency models. SalGAN is composed of two parts; the generator that has a convolutional encoder-decoder (the encoder consists of a fully convolutional architecture based on the popular VGG-16[5] and the decoder with the inverse layers of the encoder, replacing max-pooling with upsampling layers) and the discriminator that is in charge of distinguishing between ground truth saliency maps and generated saliency maps from the generator. During adversarial training, the loss function of the saliency is a combination between the error from the discriminator and the cross-entropy with respect to the ground truth. As they show, a α= 0.1 has good results. LBCE =−1 N N X j=1 (Sjlog(ˆ Sj) + (1 −Sj)log(1 −ˆ Sj))2(2.1) L=αLBCE +L(D(I, ˆ Sj),1) (2.2) During the training of the discriminator, no content loss is available and the loss function is: LD=L(D(I, Sj),1) + L(D(I, ˆ Sj),0) (2.3) 8 2.1 Technical Background, Architecture used 2.1.2 SalBCE SalBCE[3] is an adaptation of SalGAN architectures with some changes. It consists of using only the generator part, using the Binary Cross Entropy (BCE) as the loss function. In addition to training using RGB, it is included depth as well as CoordConv. In the first case, it was based on the idea that the objects closer are more salient than those that are further away. In the second case, the idea of this technique is to provide the convolutional input layers access to its own input coordinates through the use of extra coordinate channels. Finally, the idea of implementing the Optical flow was proposed, although it was not developed in his work. Figure 2.1: SalBCE model architecture In figure 2.1 it can be seen the architecture used, with a total of 31,787,009 hyperparameters: During the training part it has been using the Adam [6] optimizer. The initial weights have been obtained from SalGAN. Starting with a learning rate of 0.00001 and dividing by 10 every 3 epochs (total of 27 epochs) with a batch size of 12 (due to the limitation of space in the GPU) has been proposed. For the baseline weights, SalBCE has trained on SALICON[7] dataset, which the images used are from the COCO[8] dataset. These weights are going to be the ones used as a baseline in our custom CNN head architecture based on SalBCE. 9 2.1 Technical Background, Architecture used 2.1.3 ACLNet ACLNet is a Convolutional Neural Network (CNN), model designed to predict saliency from videos. More recently, they presented a new video saliency prediction benchmark. They propose a novel deep learning based video saliency model (Figure 2.2), which encodes to supervised attention mechanism to explicitly capture static saliency information and help LSTM better capture dynamic saliency representations over successive frames: Figure 2.2: ACLNet architecture composed of VGG-16, Attention module and ConvL- STM. In their model, they used an attention mechanism in order to obtain the static information to leave the LSTM focus on the temporary information. The attention module was trained in the SALICON dataset, while the whole architecture was trained in a combination of different datasets, DHF1K[2], HollyWood2[9] and UCF Sports[10]. They used as a loss function a combination of three different metrics, in order to be able to measure more accurately depending on the different proposed metrics (in SalBCE, BCE was used as a loss function). L(Y, P, Q) = LKL(Y, Q) + α1LCC (Y, Q) + α2LNSS(Y, P )) (2.4) where the predicted saliency map is Y∈ {0,1}28×28, the map of fixation locations is P∈ {0,1}28×28 and the continous saliency map (distribution) is Q∈ {0,1}28×28. Note that in order to obtain the Q continous saliency map, a blurring with a small Gaussian Kernel must be applied to the discrete fixation map P.αs are balance parameters ans are empirically set to α1=α2= 0.1 10 2.1 Technical Background, Architecture used 2.1.4 SalBCE motion approach Our Custom CNN head is based on the motion integration together with the result of SalBCE of the RGB images. To improve the prediction using only the dynamic information, at first, optical flow (OF, see in 3.2) and frame differencing (FD, see in 3.1) are computed, and using a structure of one stream architecture [11] an image is generated, in which the three channels correspond to [F D, OFx axis, OFy axis]. Then, using the SalBCE architecture, the saliency maps are generated only from the images that contain motion’s information. Parallel to this, the saliency maps are also generated from the RGB images, using the Sal- BCE architecture. From this point, an image of 2 channels corresponding to the previous output is generated. Where the first channel corresponds to the saliency map of the static images and the other channel to the dynamic information of those. A new architecture of 4 convulsion layers (Table 6.1) is presented, which finally generates a saliency map integrating all the information. Layers depth Kernel Stride Pad Activation conv2d 64 3x3 1 1 ReLU conv2d 256 3x3 1 1 ReLU conv2d 128 3x3 1 1 ReLU conv2d 64 3x3 1 1 ReLU Output 1 1x1 1 0 Sigmoid Table 2.1: Fusion saliency maps architecture SalBCE’s baseline weights have been used (SalBCE trained on SALICON for 27 epochs), and SalBCE has been trained in RGB images for 4 epochs, and 20 epochs for the dynamic images. Making inference in the images which only have motion information, it is not enough to overcome SalBCE on RGB metrics. However, the results obtained with the PF and OF images are close to it, only in the AUC-shuffle, it obtains better results. In order to train the entire architecture, we have trained every dataset separately (GPU limitations). SalBCE’s baseline weights have been used (SalBCE trained on SALICON 11 2.1 Technical Background, Architecture used for 27 epochs), and SalBCE has been trained in RGB images for 4 epochs, and 20 epochs for the dynamic images. The learning rate started at 1 ·10−5and every 2 epochs we divide it by 10, and we used an Adam optimizer. Once we have generated both saliency maps for the entire train DHF1K dataset, we fuse both maps for each image Ij mix = Ij F rom RGB +Ij from motion as an input of the architecture in Table 6.1. (The results of this implementation are in 4.4) Figure 2.3: The full architecture used. Two SalBCE in parallel, and a custom CNN head. 2.1.4.1 One stream approach In order to simplify the training process and simplify the model, the use of SalBCE is only proposed by inputting 6 channel image as input (the RGB image and the motion information) [R, G, B, FD, OFx axis, OFy axis]. Training with the same parameters as in the 2.1.4 section, the Custom Neural Network is thus eliminated and the training time of the model is halved. Important train from scrath because the model was pre-trained only with the images of 3 channels. If the weights are reused the system will tend to eliminate the information related to the movement. 12 2.2 Working Dataset 2.2 Working Dataset In this thesis, we have exclusively used the dataset called DHF1K. This dataset stand from Dynamic Human Fixations 1K it is the largest video saliency dataset. As we can see in Table 2.2, this dataset is the newest one. It contains 1000 videos, which the first 600 are dedicated to training, from 601 to 701 for validation and the last 300 for the test. For the generation of this dataset, they searched in the Youtube platform for around 200 keywords and selected 1000 video sequences. The videos were exported at 30fps at a resolution of 640x360. Dataset Year Videos Resolution Duration(s) Viewers Task CRCNS 2004 50 640x480 6-94 15 task-goal Hollywood-2 2012 1,707 720x480 2.120 19 task-goal UCF sports 2012 150 720x480 2-14 19 task-goal DIEM 2011 84 1280x720 27-217 ∼50 free-view SFU 2012 12 352x288 3-10 15 free-view DHF1K 2017 1,000 640x360 17-42 17 free-view Table 2.2: Statistics of typical dynamic eye-tracking datasets This set of videos stores a total of 150 different categories. It also offers diversity with different camera movements and content. To generate the Ground Truth of these videos they used an eye-tracker called Sensoc Motoric on a total of 17 participants of an age between 20 and 28 years old. Note that the image size is higher than the input of the above architectures, for this reason, a resize will be applied to use them. 13 2.3 Metrics used 2.3 Metrics used In order to be able to measure how well or badly predictions are made, we need part of the ground truth to compare the correct solutions. The mathematical function that we apply between the reference and the predicted map is called system metrics and they allow us to evaluate the distance with respect to the solution. Although there is a large number of metrics available, only the 5 most popular ones have been used. As it is shown in this paper [12], the result could be optimized for each of these metrics, however, only one prediction has been generated for each frame. Following is a brief summary of the metrics used [13]: Location-based metrics Given the goal of predicting the fixation locations on an image, a saliency map can be interpreted as a classifier of which pixels are fixated or not. This suggests a detection metric for measuring saliency map performance. •AUC Judd: This metric consists of calculating the area under the ROC curve. To draw the ROC curve, only true positive rate (TPR) and false positive rate (FPR) are necessary. The TPR defines how many positive positives results occur among all positive samples available during the test. FPR, on the other hand, defines how many incorrect positives results occur among all negative samples available during the test. TPR =TP P=TP TP +FN FPR =FP N=FP FP +TN (2.5) 14 3.1 Frame Differencing (FD) since one has been chosen that captures enough information. The heatmap has been normalized (See 2.11) between 0 and 1, where 0 means the absence of movement and 1 the maximum possible. It can be understood that, although two videos have objects moving at a different speed, for the purposes of this normalization (applied with respect to the maximum of each frame), there will be no difference. Therefore, once the differencing frame is applied, we will obtain a heatmap whose values will be comprised between 0 and 1, being able to be interpreted as the zones with the most movement of each frame. Figure 3.1: Left image is the video 007 of the DHF1K dataset, frame 99. Right image is the FD saliency map between frames 99 and 100 21 3.2 Optical Flow (OF) 3.2 Optical Flow (OF) Optical Flow can be understood as the motion vectors of each pixel in a given two images. That is, given a couple of images, to determine where each of the pixels moves between the two frames. Depending on the degree of sophistication, 2D or 3D maps can be generated. Optical Flow can also be defined as the distribution of apparent velocities of movement of brightness pattern in an image. Figure 3.2: Optical Flow interpretation. Left image is the frame at time t. Middle image is the frame at time t+ 1. Right image is the Optical Flow output. The result of the optical flow is an image of two channels where for each pixel it expresses the direction x and y associated with the movement vector of this, between the two consecutive frames. Although it may seem a relatively easy task, there are different aspects that should be highlighted. You can define the movement in different ways: there are different factors that can influence the motion, such as the movement of the camera, the scene or the change of luminosity. In order to gain insight into methodology used to calculate the Optical Flow, below is a summary: 22 3.2 Optical Flow (OF) Lukas Kanade methodology [14] First we define the equation of motion, where u and v are the variation for each axis between two frames: I(x, y, t) = I(x+u, y +v, t + 1) (3.2) Take Taylor expansion of I(x+u, y +v, t + 1) at (x, y, t) to linearize the right side: I(x+u, y +v, t + 1) ≈I(x, y, t) + ∂I ∂xu+∂I ∂y v+∂I ∂t (3.3) It+∇I[u, v]T= 0 (3.4) In (3.4), there is only one equation but we need to determine uand v. This is called the aperture problem [15]. In order to understand it, we can imagine the typical barber spiral which is spinning, however, we see as it is moving upward. Therefore we impose additional constraints. We assume that the flow field is smooth locally, one method is to pretend the pixel’s neighbors have the same (u, v). If we use a 5x5 window, that gives us 25 equations per pixel: 0 = It(Pi) + ∇(Pi)·[u, v]T(3.5)         Ix(p1)Iy(p1) Ix(p2)Iy(p2) . . .. . . Ix(p25) Iy(p25)           u v =−         It(p1) It(p2) . . . It(p25)         (3.6) Ad =b−→ minimize ||Ad −b||2(3.7) We have more equations than unknowns: solve least squares problem. This is given by: ATA·d=ATb(3.8) 23 3.2 Optical Flow (OF) Optimal (u, v) satisfies Lucas-Kanade equation:  PIxIxPIxIy PIxIyPIyIy   u v =− PIxIt PIyIt (3.9) This equation is solvable when ATAis convertible, ATAis not too small due to noise, eigenvalues λ1and λ2of ATAshould not be too small, and finally ATAshould be wellconditioned (λ1/λ2) should not be too large. The ATAmatrix has the same shape as the formula for Finding Corners [16]: C= PI2 xPIxIy PIxIyPI2 y (3.10) C=R−1  λ10 0λ2 R(3.11) where R is a rotation matrix, so corners are the things we can track. Corners are when λ1, λ2 are big, this is also when Lucas-Kanade works. Corners are regions with two different directions of the gradient (at least). Aperture problem disappears at corners. To work correctly we have to assume that the movement will be small, there will be a low level of noise in the image and the chosen window will not be too large and the neighboring pixels will move in the same direction. If this is not the case, the pyramid method is proposed, where the image is resized until it has a smaller motion and then it is applied layer by layer. Even so, it will not be detected correctly with color and shape changes. In the beginning, this implementation was started, although in the end it was opted for a coarse-to-fine optical flow method[17] which, in principle, has better results predicting the motion of the objects. The mathematical explanation of this model is summarized below: 24 3.2 Optical Flow (OF) Taking into account the same definition of grayscale sequence, where I(x, y, t) is the grey value of the point (x, y) at the first frame while the gray value of the corresponding point at the next frame is I(x+u, y +v, t + 1). The grey value constancy assumption is very sensitive to the illumination changes, this is the reason for the proposal of the gradient constancy assumption: ∇I(x, y, t) = ∇I(x+u, y +v, t + 1) (3.12) They combined the grey value constancy assumption and the structure tensor constancy assumption to create the energy function to be minimized x= (x, y, t)Tand w= (u, v, 1)T: Edata(u, v) = ZZΩ Ψ(|I(x+w)−I(x)|)2+γΨ(|I(x+w)−∇I(x)|)2dxdy (3.13) Ψ(s2) = √s2+2,  = 0.001 (3.14) where Ψ(s2) is the penalty function which reduce the influence of the outliers. To design the smoothing term, they first introduce the classical smoothing strategy proposed by Horn and Schunck [18] as follows: Esmooth(u, v) = ZZΩ Ψ(|∇3u|2+|∇3v|2)dxdy (3.15) In the traditional optical flow method, the weighting factor of the smoothing term usually was a fixed value which made the same smoothing extent in any area of the image. With the design of the data term and smoothing term, the proposed optical flow model could be written as the followed energy function: E(u, v) = Edata +αEsmooth −→ minimize (3.16) The Euler-Lagrange equations [19] are nonlinear in their argument w= (u, v, 1)2. The first step towards a linear system of equations, which can be solved with common numerical methods, is the use of fixed point iterations on w. In order to implement a multiscale approach, necessary to better approximate the global optimum of the energy, these fixed 25 3.2 Optical Flow (OF) point iterations are combined with a downsampling strategy. Instead of the standard downsampling factor of 0.5 on each level, it is proposed here to use an arbitrary factor η∈(0,1), which allows smoother transitions from one scale to the next 1. Moreover, the full pyramid of images is used, starting with the smallest possible image at the coarsest grid. S(q) = Zb a L(t, q(t), q0(t)) dt (3.17) ∂L ∂qi (t, q(t), q0(t)) −d dt ∂L ∂qi (t, q(t), q0(t)) = 0 for i = 1, ..., n (3.18) After applying the minimization of the energy function of the image, we will obtain for each pixel a component in the x-direction and a component in the y-direction, thus obtaining an image with two channels per pixel. For the realization and application of the above described, the implementation in python, Optical flow method based Coarse2Fine warping method from Thomas Brox has been used. Below are some examples of the Optical flow computed with the script PyFlow[20]: Figure 3.3: Optical Flow Color axis map Figure 3.4: Left image is an example of two consecutives frames. Right image is the Optical Flow output between those images. 26 3.3 Exponential Moving Average 3.3 Exponential Moving Average Exponential Moving Average (EMA) is a type of mean where the most recent samples have a greater weight. Similar to the Simple Moving Average (SMA) but with more sensitivity to the closest changes. It is computed using the following expression: EMAt j=α·Ot j+ (1 −α)·EMAt−1 j(3.19) EMA0 j=O0 j(3.20) The alpha parameter defines the weight of the current image with respect to the past, that is, the higher it is, the lower the importance of the previous images, and the smaller it is, the greater the importance. It should be emphasized that the importance of the past will have a decreasing exponential weight: EMAt j=αOt j+αβOt−1 j+αβ2Ot−2 j+αβ3Ot−3 j+··· (3.21) Therefore, this technique will be interesting as long as the previous information belongs to the same video and scene since otherwise, the past will not have relevance to generate the next image. 27 3.4 Shot Detection 3.4 Shot Detection In the same video, different scenes may appear, which must be detected in order to not take into account the information prior to that scene. Using the exponential moving average (EMA) methodology explained above, it is necessary to know where those changes occur so as not to generate the image taking into account frames that do not belong to the image in question. Let’s suppose that, a car appears on the video moving along the road, and there is a change of scene, then the interior of the car is shown, in this case, the information of the moving vehicle from outside has no visual relationship with the object that is focusing inside the car. For this reason, when there is this type of change in the images, it is necessary to be aware of it. In addition, it is also necessary to define which motion image to calculate, since, the result of the difference between images has no meaning, and does not provide us with the movement of an object. Thus, at the moment that there is a change of scene, the movement between those two images will be defined as a heatmap of value 0 in all the points, and information from the images generated previously will not be used. In the next frame, the FD will be calculated, but neither will the information of the previous frame be taken into account since we have defined it as 0. Currently, there are several ways to be aware of the changes of scene in a video. We soon realize that it is a complex task: Let’s suppose that a bird appears flying in the video where the camera also moves at the same speed, in this case, the background will be in continuous movement but the scene will be the same. Note that, in this case, we detect the movement of the background but not the main object. Then it will be understood that it is a complex task, and for this reason (it is not the objective of this work) a relatively simple system has been used to detect the typical and most relevant changes of the videos: Given a couple of consecutive images, the proposed script will return True or False indicating whether it is a scene change or not. To make this binary decision, it is determined as follows: The 3 indices described below are calculated, which each of them returns True 28 3.4 Shot Detection or False and to finally decide the result is considered positive if at least two of these three indicators are positive: •Sum of absolute differences (SAD): Consists of calculating the sum of all Euclidean distances between the color vector associated with each pixel and the same one of the previous frame. SAD is very sensitive to small changes in the same scene: rapid movements of the camera, explosions or simply turning on the light in a dark room can produce a false detection. On the other hand, SAD does not detect soft cuts very well. With this measure, you can measure the strong changes in scenes very well. SADt=X j||xt j−xt+1 j||2=X j Ot j(3.22) Ot j: Heatmap resulting from the frame differencing, one component per pixel xt j= [r, g, b]T: Full image with 3 components per pixel •Histogram difference (HD): Consists of calculating the difference between the histograms of each frame. To measure this distance Chi-Square is used because in general, it obtains better results compared with the Log-likelihood statistic or Histogram intersection [21]. HD is not as sensitive to small changes in the same scene as it is SAD and therefore produces fewer false detections. The main problem is that the two images can have the same histogram while the content is extremely different. For example, an image of a beach could have the same histogram as a desert with a blue sky. For the same reason, this indicator is not guaranteed to recognize sudden changes in the scene. The chi-square distance between two rows l,kis defined below: 29 3.4 Shot Detection HD(l, k)t=X js1 x+j·xlj xj+·xkj xk+2 (3.23) xi+=Pjxij , x+j=Pjxij M=         xt l,0xt−1 k,0 xt l,1xt−1 k,1 . . .. . . xt l,n xt−1 k,n         : Matrix of the two histograms •Edge change ratio (ECR): The ECR attempts to compare the actual content of two frames. Transforms both frames into edge images, (extracts the contours of the objects within the images). Then, compare these edge images using dilation to calculate the probability that the second frame contains the same objects as the first frame. This metric is very sensitive to sudden changes of scenes and at the same time can detect smooth cuts. The final calculation to determine the ECR of an image is shown below: Figure 3.5: Steps of edge change ratio 30 4.1 Obtaining the movement in mind that this system does not capture static objects without movement. For that reason, all those videos where still objects appear, or moments of the video where there is no motion will not be detected. The rate between the frames where FD obtained better results with respect to all the frames has been computed. The obtained results show that there is an improvement between ∼12% and ∼24% of all frames, that is to say, that almost in 1/4 of the frames, the simple technique of FD showed a better score (Table 4.1, row 14). At first, it was expected that this technique would obtain better results depending on the type of video, and according to the results obtained (see Figure 4.2) where the result is shown in orange using a model without taking into account motion, and in blue the saliency maps with the FD technique, you can see that in almost any video is getting better average results from all the frames in each video. - AUC-Judd SIM S-AUC CC NSS SalBCE 0.8909 0.2667 0.7102 0.3819 2.135 Frame Differencing 0.7052 0.1534 0.5917 0.1335 0.7493 Rate of FD doing it better than SalBCE 12.33% 14.98% 23.81% 13.17% 13.48% Table 4.1: Experiment results Figure 4.2: Comparison of results in the dataset validation 37 4.1 Obtaining the movement To generate the following graph (Figure 4.3), the difference in the value of the metrics for each frame between the dynamic model and the static model has been computed. All those points/frames that obtain a positive value means that they have obtained a better result while, if a negative value is obtained, the static model has obtained a better score. In addition, the absolute value of that difference shows the magnitude of the distance. In blue, the frames are shown where a positive value has been obtained, and in orange, a negative value. It can be verified that, although in almost any video it has obtained better results, there is a great number of frames that it has. Occasionally there are certain videos where you get a much higher score and others that lower, but it is found that the improvement exists in certain frames of all videos: Figure 4.3: Comparison of results in the dataset validation Even so, the average is still lower than the static model (Figure 4.4), and can be checked by comparing the metrics of all the frames of the same video. Next, the value of the static model is shown in orange, and without contemplating movement in blue (dynamic model). You can see that although in most frames the result is much worse, there is a certain number of frames which is higher: 38 4.1 Obtaining the movement Figure 4.4: Comparison of the results of a given video of the validation dataset The trivial conclusion that is obtained from these results, is the fact that this system only captures information when the object which we set is in motion, for this same reason, the only improvement is captured in those frames where this dynamism exists. Those in which there is no motion or is composed of not only dynamic parts, a worse result will be obtained. 39 4.2 Motion integration with static objects 4.2 Motion integration with static objects In a first approximation, it has been proposed to generate a new mixed prediction, that is, from the two maps generated by each system, use both to generate a map that integrates the two types of information. To generate such predictions, two systems have been proposed: •Mixed integration: Apply different mathematical functions to generate another map from the two, such as making a mean, or taking the maximum of each map, etc .. •Binary Classifier: Based on other statistical parameters, which do not include the ground truth, decide in each prediction which system will get the best score and which one, one or the other. Mixed integration In the first methodology, 4 basic functions are proposed to generate the saliency maps. In this case, no statistical parameter has been applied. After the application of these functions all the saliency maps have been norm by range between (0, 255): •Parameter α: A weighted sum has been applied to the two resulting maps. mapnew =α·mapstatic + (1 −α)·mapdinamic •Sum: The direct addition pixel to pixel of the two saliency maps has been applied. mapnew =mapstatic +mapdinamic •Maximum: The maximum pixel to pixel function has been applied to both maps. mapi new =max{mapi static, mapi dinamic} •Minimum: The minimum pixel to pixel function has been applied to both maps. mapi new =min{mapi static, mapi dinamic} 40 4.2 Motion integration with static objects In Table 4.2 it can be verified how the results have been similar, although the one corresponding to the weighted average with α= 0.5, has been the one that has obtained the best results in all the metrics studied. Even so, the results are not better with respect to SalBCE except in SIM and S-AUC metric. - AUC-Judd SIM S-AUC CC NSS α= 0.5 0.8730 0.3412 0.7127 0.3412 1.906 addition 0.8730 0.2289 0.7127 0.3412 1.906 maximum 0.8640 0.2192 0.7091 0.3238 1.813 minimum 0.7813 0.2153 0.6226 0.2395 1.323 SalBCE 0.8909 0.2667 0.7102 0.3819 2.135 Frame Differencing 0.7052 0.1534 0.5917 0.1335 0.7493 Table 4.2: Mixed integration results Note that although αparameter and addition seem exactly the same, there is a difference. While the first one is computing the average of both maps and its value never is more than 255, in the second one, before normalizing we truncate the saliency map. So, all the pixels where the sum of both images in that pixel is greater than 255 will be represented as the same value. Binary Classifier In the second methodology, the use of statistical parameters is proposed in order to predict which model will generate a better prediction. The kurtosis, the variance and the amount of movement have been used to try to make this prediction. The previous statistical parameters have been computed on the FD. The main idea is to decide without having knowledge of the ground truth which of the models will obtain the best result and choose one or the other as appropriate. Next, the difference in a video between the dynamic model and the static model is shown in blue. In orange, the total amount of movement is shown in the first case (Figure 4.5), and in the second, is shown the kurtosis (Figure 4.6). 41 4.2 Motion integration with static objects Figure 4.5: Comparison of kurtosis with the good results Figure 4.6: Comparison of motion with the good results It can be verified that there is a certain relationship between the amount of movement and a better implementation with the model that implements the movement. Actually, the most important thing is not the numerical value, rather if it is positive or not. To do 42 4.2 Motion integration with static objects this, the function sign{kurtosis, motion, variance}has been computed and it has been proved that an important correlation exists. In order to generate the final saliency maps, different implementations have been proposed: •Choose the dynamic model only those frames where the variance of the FD associated with that frame is less than -0.5. Table 4.3 •Choose the dynamic model only those frames where the amount of movement of the FD associated with that frame is greater than 0.5. Table 4.3 •Choose the dynamic model only those frames where the kurtosis of the FD associated with that frame is greater than 0. Table 4.3 •Choose the dynamic model only those frames where the AND function is fulfilled between the amount of movement, the variance and the kurtosis of the FD associated with that frame is greater than 0. Table 4.3 •Choose the dynamic model only those frames where the AND function is fulfilled between the amount of movement is greater than 0.5, the variance less than -0.5 and the kurtosis higher than -0.5 of the FD associated with that frame. Table 4.3 - AUC-Judd SIM S-AUC CC NSS variance from (FD, <−0.5) 0.8687 0.2513 0.6955 0.3494 1.952 average motion (from FD, >0.5) 0.8684 0.2531 0.6986 0.3541 1.981 kurtosi (from FD, >0) 0.8237 0.2261 0.6636 0.2883 1.614 mix (α > 0) 0.8788 0.2602 0.7046 0.3671 2.063 mix (>0.5, > 0.5, > −0.5) 0.8946 0.2698 0.7147 0.3876 2.176 SalBCE 0.8909 0.2667 0.7102 0.3819 2.135 Frame Differencing 0.7052 0.1534 0.5917 0.1335 0.7493 Table 4.3: Binary decision results 43 4.2 Motion integration with static objects It can be seen that all the models have obtained a similar score and lower than the static model. However, the last implementation (Table 4.3), has obtained slightly higher results. It must be taken into account that the decision of the parameters is not optimized to obtain the best results. The difference is very small so it could be the case that in fact due to variations in the computation of the metrics there would not be a big difference between one model or another, so we have to improve our model to include motion in video saliency prediction. In these experiments, we can conclude that motion is important. Although a solid solution has not been proposed as far as implementation is concerned, the foundations of its necessary implementation in prediction have been proposed, as well as a corroboration of the importance of motion in saliency prediction task. 44 4.3 Optical Flow implementation 4.3 Optical Flow implementation Once the involvement of the movement in the prediction of salience has been demonstrated, it has been decided to improve the capture of this movement. PyFlow (see in 3.2 has been used in order to obtain the Optical Flow of the dataset. Unlike the differencing frame, the optical flow identifies the direction and magnitude of that movement. To be able to represent this direction, it is necessary to map the addresses (x, y) with the spectrum (R, G, B) in the range of (0, 255). Although it is also possible to calculate the magnitude, it is preferred to use the extra information provided by this model. For this study we have used the implementation made in C ++ instead of FlowNet 2.0[22], although with this second method, we could probably obtain higher speed of generation of the Optical Flow and greater precision in the detection of this. In Figure 4.2, the different values obtained with SalGAN (orange), FD (blue) and Optical Flow (green) are compared in the AUC judd metric. It can be seen that this system does not obtain a better average score in the videos. It has similar behavior to the FD although in some videos they obtain better results, nevertheless, it obtains a lower percentage of frames better than the static model, as well as a worse score in all the metrics (Table 4.4). In the figure some frames it can be seen that similar behavior is obtained in FD. An improvement in certain frames of the same video, obtaining in the rest a result much lower than the one obtained with SalBCE. On the other hand, it has been verified what is the similarity percentage between these two approximations, that is, what percentage of the frames that best obtain the FD also obtained it in the Optical Flow, and surprisingly the result was approximately ∼60%. It means that ∼40% of frames, which scored better, are different frames. So if we take into account the extra percentage, the percentage of better frames is increased, using only the technology with movement: 45 4.3 Optical Flow implementation - AUC-Judd SIM S-AUC CC NSS Rate of FD doing it better than SalBCE 12.33% 14.98% 23.81% 13.17% 13.48% Rate of PF doing it better than SalBCE 12.09% 14.56% 23.41% 12.14% 12.55% Rate of PF doing it better than SalGAN in which FD did 52.9% 61,7% 52.8% 54.2% 61.1% Rate of FD and PF doing it better than SalBCE 18.02% 20.56% 34.86% 18.73% 18.36% Table 4.4: Ratio of improvement, of movement respect without movement It can be observed in the previous table that with a simple movement model, that is, decide that where there is movement there is salience, it is achieved in the best case, an improvement of 34.86% of the frames, obtaining a clear correlation between movement and salience. To understand what properties a video must have in order to see which model works best, it has been decided to choose certain videos. Specifically, the visualization of videos 626, 655, and 666 has been chosen for the study, coinciding in the peaks where the best result is obtained (see Figure 4.7), with both movement systems and SalBCE where it obtains a worse result. In these videos is where motion models get a better percentage of frames than the static model: 46 4.4 Motion with neural networks approach Figure 4.13: DHF1K video saliency leaderboard. https://mmcheng.net/videosal/. Consulted time: 18 May 2019. 53 Chapter 5 Environment In order to work correctly, organized and safely, a configuration scheme based on the GitHub platform for code storage and a docker[23] for the correct development of this has been proposed. To perform code tasks, visual studio code has been used, together with an external laptop to the server where, through the ssh and scp protocols, they have been communicated. Figure 5.1: Enviorment Due to the need for computing power and storage space, a server with the right components has been used (laptops do not have enough features for this kind of task). Thus, communication with the server has been carried out by means of a laptop. In order to 54 avoid compatibility issues and different versions, the docker technology has been used, so before uploading the programs to the server, local tests were possible (very easy for scalability). All the code has been periodically uploaded to the GitHub repository in order to maintain version control and have all the work saved at all times. The difference of colors between folders serves to understand their connection between them, that is, the datasets folders and saliency maps (due to a large amount of information they store) have not been uploaded to GitHub, and therefore their files inside the docker it is a mapping of the folders inside the server. 55 Chapter 6 Budget For the realization of the thesis a work space has been used at the University of Dublin (DCU) with sufficient material (Office, screen, servers, electricity, etc ...) to carry out the necessary tasks. Insight Center for Data Analitycs has provided my tutor Kevin McGuinness in conjunction with Xavier Giro-i-Nieto (From Universitat Politecnica de Catalunya) to oversee the thesis. The software used are open-source. However, in order to perform the necessary computation, it has been compared with cloud services: •At AWS (Amazon Web Services)1similar GPU used as an Insight, it would cost 0.9$ + IVA per hour. If the use was prolonged (minimum of 3 years) the price would be 0.425$ + IVA. •At GCP (Google Cloud Platform)2a similar GPU with the same amount of RAM it would cost 0.95$ + IVA. If a preemptile system is used (permission is given to google so that it can paralyze the processes up to 24h when they need it) the price is only 0.135$ + IVA. Amount Wage/Hour Dedication Weeks Total Undergraduate researcher 1 10 $ 35 h/week 15 5,250 $ Senior Engineer 2 35 $ 1 h/week 15 1,050 $ GPU Tesla K80 1 0.95 $ 80 h/week 15 1,140 $ Total 7,440 $ Table 6.1: Costs of total hours of work. Social Charges and taxes are not included 1https://aws.amazon.com/es/ec2/instance-types/p2/ 2https://cloud.google.com/compute/pricing#sustained use 56 Chapter 7 Ethics In recent years, research in the field of computer science and artificial intelligence has grown exponentially. Largely due to the increasing computing capacity that this type of architectures requires, however, there is still a long way to go. With these new methodologies have begun to imagine concepts that were previously unthinkable, as could be the autonomous car or the prediction of diseases just by having a photo. The amount of possibilities that these technologies can offer is not even present in our lives. Going a step further, can we imagine a model where, for example, justice is using artificial intelligence to predict whether or not we will be guilty, even before committing any crime. We are not really aware of the repercussion that can be predicting the fixations of the eye in images or videos. To what extent we can understand it as part of our privacy, we could ethically pass through a barrier. On the other hand, there are a lot of applications with which the saliency prediction could work very well. Apart from other tasks in artificial intelligence that this methodology could provide, it could currently be used in marketing or for example in video compression (maybe it is not necessary to transmit all the information of the whole image equally if, in the end, we only look at a part of that frame). During the realization of the thesis, it has also been possible to identify certain bias depending on the type of video. The same action performed by different people, in gender, race, or even religion have different ground truth. This can be seen very well in sports videos carried out by a man or a woman. We understand then that there is a 57 variation of the ground truth in the function of certain parameters of the group that made these images. Taking a small group of people (see in Table 2.2) it is very likely that the result will be diverted towards a certain trend. The saliency maps not only depend on the images that we are seeing but also the people who are behind based on their memories and experiences. It could be interesting to use a group of children to see how their fixation maps are. 58 Chapter 8 Conclusion and Future Developement During this thesis, I have learned a lot of concepts related to artificial intelligence, from the basic operation of a simple neural network to the Depp Neural Networks (DNN) as the one of SalBCE. It has also been very useful to start knowing the pythorch framework and implement my own architecture from scratch. With this project we provide the following contributions: •Different approaches have been presented to demonstrate that motion is important in saliency prediction. Different graphs and findings have been shown using the DHF1K dataset. •We have studied a state-of-the-art saliency model for static images named SalGAN and for videos, SalBCE. We have evaluated its performance in the DHF1K benchmark, rating second in the public leaderboard, under ACLNet. •A custom CNN head has been presented using the well-known SalBCE to implement the motion in the prediction process. The bases have been laid to begin to develop a model that implements this concept. The main goal has been accomplished, as shown in section 1.1, all the proposed objectives have been met, although with some nuance. It has been proved that, indeed, we tend to look more to the parts of the objects in motion. On the other hand, the extraction of the dynamic information has been carried out by means of two known techniques, FD and PyFlow (Lukas Kanade implementation), thus generating (as in the one stream methodology) an image with movement information. An implementation based on SalBCE has also 59 been proposed to integrate that movement in the calculation of saliency prediction. The results obtained with this architecture have not been as expected, although the difference has been small, we have obtained better results in all the metrics. In AUC-Shuffle, up to a 16.3 % improvement has been achieved with respect to the baseline BCE, however, in the other metrics, not much more than 1% improvement has been achieved. Given the previous results, below are different ways to improve the results: •To improve the obtaining of the movement, the use of other neural networks is proposed with the purpose of decreasing the computing time. During the execution of the work we have been studying the implementation of FlowNet2.0 [22] or more recently the use of PWC-Net [24] (is 17 times smaller in size, 2 times faster in inference, and 11 % more accurate on Sintel final than the recent FlowNet2 model). At the end of the work, a new implementation superior to all demands has been published, called SelFlow [25]. •The inclusion of a new more complex architecture that can be implemented - as in ACLNet - attention modules or LSTM between the two image channels, as well as an improved architecture for the merging of the groups of images. •Train the model with different datasets, such as SALICON or UFC Sports, in order to obtain a greater variety of content and improve the accuracy of the prediction. Although different new ways to improve movement are proposed, we believe that the best way to improve this system is to directly include the application of the first point, where the use of a new more precise architecture is necessary. At first, the results obtained with FD and OF were very positive, however, those calculated using this Custom CNN head have not been sufficient compared to the computation cost that is required. A system has been used where the movement information has been considered as important as the static information, and maybe it would be smarter to use this information to help the SalBCE in RGB to fix more in those areas with movement. 60 References [1] I. Goodfellow, Y. Bengio, and A. Courville, “Deep learning. book in preparation for mit press,” URL¡ http://www. deeplearningbook. org, 2016. 1 [2] W. Wang, J. Shen, F. Guo, M.-M. Cheng, and A. Borji, “Revisiting video saliency: A large-scale benchmark and a new model,” in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp. 4894–4903, 2018. 1, 10 [3] J. J. Nieto Salas, “Video saliency prediction with deep neural networks,” B.S. thesis, Universitat Polit`ecnica de Catalunya, 2019. 1, 9 [4] J. Pan, C. C. Ferrer, K. McGuinness, N. E. O’Connor, J. Torres, E. Sayrol, and X. Giro-i Nieto, “Salgan: Visual saliency prediction with generative adversarial networks,” arXiv preprint arXiv:1701.01081, 2017. 8 [5] K. Simonyan and A. Zisserman, “Very deep convolutional networks for large-scale image recognition,” arXiv preprint arXiv:1409.1556, 2014. 8 [6] D. P. Kingma and J. Ba, “Adam: A method for stochastic optimization,” arXiv preprint arXiv:1412.6980, 2014. 9 [7] M. Jiang, S. Huang, J. Duan, and Q. Zhao, “Salicon: Saliency in context,” in The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2015. 9 [8] T.-Y. Lin, M. Maire, S. Belongie, J. Hays, P. Perona, D. Ramanan, P. Doll´ar, and C. L. Zitnick, “Microsoft coco: Common objects in context,” in European conference on computer vision, pp. 740–755, Springer, 2014. 9 61 REFERENCES [9] M. Marsza lek, I. Laptev, and C. Schmid, “Actions in context,” in CVPR 2009- IEEE Conference on Computer Vision & Pattern Recognition, pp. 2929–2936, IEEE Computer Society, 2009. 10 [10] M. Sullivan and M. Shah, “Action mach: Maximum average correlation height filter for action recognition,” in CVPR, pp. 1–8, 2008. 10 [11] A. Khoreva, R. Benenson, E. Ilg, T. Brox, and B. Schiele, “Lucid data dreaming for video object segmentation,” International Journal of Computer Vision, pp. 1–23, 2018. 11, 50 [12] M. Kummerer, T. S. Wallis, and M. Bethge, “Saliency benchmarking made easy: Separating models, maps and metrics,” in Proceedings of the European Conference on Computer Vision (ECCV), pp. 770–787, 2018. 14, 18 [13] Z. Bylinskii, T. Judd, A. Oliva, A. Torralba, and F. Durand, “What do different evaluation metrics tell us about saliency models?,” IEEE transactions on pattern analysis and machine intelligence, vol. 41, no. 3, pp. 740–757, 2019. 14 [14] S. N. Tamgade and V. R. Bora, “Motion vector estimation of video image by pyramidal implementation of lucas kanade optical flow,” in 2009 Second International Conference on Emerging Trends in Engineering & Technology, pp. 914–917, IEEE, 2009. 23 [15] S. SHIMOJO, G. H. SILVERMAN, and K. NAKAYAMA, “Occlusion and the solution to the aperture problem for motion,” 23 [16] C. G. Harris, M. Stephens, et al., “A combined corner and edge detector.,” in Alvey vision conference, vol. 15, pp. 10–5244, Citeseer, 1988. 24 [17] T. Brox, A. Bruhn, N. Papenberg, and J. Weickert, “High accuracy optical flow estimation based on a theory for warping,” in European conference on computer vision, pp. 25–36, Springer, 2004. 24 [18] E. Meinhardt-Llopis, J. S. P´erez, and D. Kondermann, “Horn-schunck optical flow with a multi-scale strategy,” Image Processing on line, vol. 2013, pp. 151–172, 2013. 25 62