Adversarially Learned Abnormal Trajectory Classifier
Pankaj Raj Roy Guillaume-Alexandre Bilodeau













































Adversarially Learned Abnormal Trajectory Classifier
    Pankaj Raj Roy, Guillaume-Alexandre Bilodeau
LITIV lab.

Polytechnique Montréal,
Montréal, Canada

pankaj-raj.roy@polymtl.ca, gabilodeau@polymtl.ca

    December 30, 2023
========================================================================================================================================================





We address the problem of abnormal event detection from trajectory data. In this paper, a new adversarial approach is proposed for building a deep neural network binary classifier, trained in an unsupervised fashion, that can distinguish normal from abnormal trajectory-based events without the need for setting manual detection threshold. Inspired by the generative adversarial network (GAN) framework, our GAN version is a discriminative one in which the discriminator is trained to distinguish normal and abnormal trajectory reconstruction errors given by a deep autoencoder. With urban traffic videos and their associated trajectories, our proposed method gives the best accuracy for abnormal trajectory detection. In addition, our model can easily be generalized for abnormal trajectory-based event detection and can still yield the best behavioural detection results as demonstrated on the CAVIAR dataset.



Deep autoencoder; Unsupervised learning; Abnormal event detection; Generative adversarial networks;



















§ INTRODUCTION

Nowadays, the collection of user data is increasing exponentially. With this huge amount of data, many end users struggle to find the most efficient way of interpreting it. One of the most challenging tasks is to learn and detect unusual information patterns from the observed data. This kind of information can be thought as any form of observations that do not follow the usual ones and that can also look suspicious. A popular application of anomaly detection is the detection of abnormal events in video surveillance  <cit.> in which the main purpose is to identify all the pixel groups that deviate from the ordinarily observed groups. The main issue behind it is the fact that there are many possible abnormal events and detecting most of them requires a large amount of normal and abnormal training data.

In the case of abnormal road user trajectories as shown in figure <ref>, a significant amount of frames is required in order to form a trajectory and, by doing so, the pre-processing step of transforming multiple object locations into their corresponding trajectories significantly lessens the amount of abnormal training data required for any kinds of statistical or machine learning approaches. A solution would be to learn usual representation and detect abnormalities as outliers <cit.>. This, however, needs the computation of a threshold value that separates normal from abnormal data using a generally defined formula. The latter can be context dependent and, therefore, the formula itself might need to be manually tuned in order to have a better threshold value.



In this paper, we propose the idea of using an adversarial network which basically transforms a one-class deep autoencoder (DAE), like the one used in <cit.>, which learns solely from normal data, into a two-class network that can classify normal and abnormal trajectories without the need of setting manually a detection threshold. We use a similar data structure and deep autoencoder model to that of Roy and Bilodeau <cit.> proposed, but, instead of computing the threshold value that separates normal from abnormal data, we integrate the pretrained DAE into a deep fully-connected generative adversarial network (GAN). The GAN is designed in such a way to automatically find the best classification boundary between normal and abnormal data by generating realistic abnormal data for training the discriminator. We applied our method for detecting abnormal road user trajectories, as well as for detecting suspicious behaviours in video surveillance. In both cases, our proposed approach outperforms previous work.

Our contributions are: 1) a GAN model in which the generator produces some mean square trajectory reconstruction errors in order for the discriminator to better distinguish abnormal trajectories, 2) an algorithm for training efficiently our GAN version which enables the discriminative model to learn the most realistic abnormal data while ensuring that normal data is correctly classified, and 3) a demonstration that, by using the same dataset as <cit.>, our proposed method gives better results for the detection of abnormal road user trajectories and that our model can be generalized for other abnormal event detection applications.




§ RELATED WORK

Considering the hypothesis that abnormal events are outliers, many authors recently suggested the idea of using an autoencoder that outputs reconstruction errors to distinguish normal and abnormal data. Ribeiro  <cit.> trained a convolutional autoencoder (CAE) model solely using normal training data for recognizing the structure of normal events. Therefore, the CAE network outputs the regularization of reconstruction errors (RRE) by taking as input the appearance features from a single frame extracted using a Canny edge detector and the motion features from optical flow. Normal and abnormal events are classified using a threshold value based on normal RRE. In <cit.>, the authors use sparse reconstruction analysis by calculating the reconstruction residuals of the test trajectories by using L1-norm minimization and comparing those to the collected normal trajectory dictionary set constructed with the Least-squares Cubic Spline Curves Approximation (LCSCA) method. Again, a threshold is used for the classification decision. In the work of Roy and Bilodeau <cit.>, a similar approach is used for classifying normal and abnormal road user trajectories using a threshold value computed through the mean squared error (MSE) of the reconstructed output of a DAE model trained with normal data only. Although the latter approach gives better precision than the most popular classical methods like a one-class support vector machine (OC-SVM) <cit.>, it suffers from the following limitations: 1) the threshold does not take into account the structure of the variations of the squared reconstruction error (SRE) for each trajectory point, 2) stating that anything smaller or equal than the computed threshold value is considered as normal will not work with noisy input in the DAE model, and 3) the threshold has to be set manually for every new video.

To tackle the issue that comes with one-class models, some authors suggest incorporating GAN for generating plausible abnormalities and using the discriminative model for classifying normal and abnormal data. Sabokrou  <cit.> proposed the idea of using a GAN where the first network acts as a generator which tries to fool the second network working as a regularity detector. Even though their method works well for finding irregularities in surveillance videos, it is difficult to make the generator converge in the case of trajectory data. Similarly, Sabokrou  <cit.> uses the autoencoder (AE) model as the generator to adversarially learn reconstructed outputs that can fool the convolutional neural network (CNN) classifier. It also suffers from the same issue. Another work done by Gupta  <cit.> suggests the social GAN approach where a recurrent discriminator is used for training a generator that outputs socially plausible trajectories. The generator is then used to predict future movements. Although this method can be applied for detecting abnormal trajectories, their proposition is only limited to pedestrians.

The GAN framework is a very interesting approach for generating data, especially when the latter is very limited. Several versions of the GAN have been proposed recently. Odena  <cit.> introduced Auxiliary Classifier GANs (AC-GANs) in order to improve the training of GANs for image synthesis, where the generated samples are based on the Gaussian noise and on the corresponding class label. Makhzani  <cit.> proposed the idea of Adversarial Autoencoder (AAE) in which the encoder of the framework learns to transform the data distribution into the prior one while respecting the formal autoencoder objective. Another one is the Bidirectional Generative Adversarial Network (BiGAN), suggested by Donahue  <cit.>, in which the encoder and the generator of the framework learn to invert each other in order to fool the corresponding discriminator. Although these different varieties of GAN might be useful for image generation tasks, they appear to be very unstable during the training process in the case where we are applying them on a non-image data structure. In the case of the sparse data structure, where each element represents a corresponding point coordinate value, the data does not follow any particular distribution like image data. Therefore, it is difficult to generate realistic abnormal trajectory data with these methods.




§ PROPOSED APPROACH

Given the center of the bounding box of each object for each video frame, trajectory samples are extracted. The data is also augmented in order to increase the training efficiency of our deep neural network (DNN). These extracted and augmented trajectory samples, considered as normal, are then used in the training of a deep AE (DAE) network. We then train a GAN-based framework that adversarially learns an irregularity classifier solely by using the trained DAE and the same corresponding training samples.



 §.§ Problem Definition
 
We define trajectories as a collection of consecutive person/object positions and velocities. After the preprocessing steps that extract and augment the trajectory data, we use the following data structure for each sample <cit.>:


    [ u, x_1, y_1, v_x_1, v_y_1, x_2, y_2, v_x_2, v_y_2, ..., x_m, y_m, v_x_m, v_y_m] ,


where u is the object class label, m is the number of trajectory points per sample, which are given in the 2D Cartesian coordinate system (x, y), v_x and v_y are the velocities of the corresponding object at a particular location according to x and y axes respectively. The problem to solve is to distinguish normal trajectory samples from abnormal ones. It is assumed that we observe only the normal trajectory during the training of our model.



 §.§ Background on Autoencoders and Adversarial Networks

In our proposed method, two main machine learning frameworks are used for the detection of irregularities. Firstly, an autoencoder (AE) model, like the one used in <cit.>, is trained in order to reconstruct the input data. Therefore, any sample that deviates from the ones used during the training of the AE will result in a bad reconstruction, where the output does not resemble the original input data. Secondly, a generative adversarial network (GAN) <cit.> that works, in part, as an abnormality generator that does not depend on any observed or handmade abnormal data, and in part, as a classifier which identifies if the provided input data is real or not.



  §.§.§ Autoencoder (AE)

The general concept of an autoencoder is to be able to reconstruct the input data. The network does so by having two subnetworks stacked together. The original data first enters the encoder model in which the encoded data is generated. The encoded data is also known as the Compressed Feature vector (CFV) or the latent representation. After that, the CFV is passed through the decoder model in order to generate the reconstruction of the original input. The AE model learns to minimize the following objective function Θ_AE, shown in equation <ref>, where ψ(n) and ψ̂(n) are the input data and the corresponding reconstructed data.


    Θ_AE = ∑_n=1^N | ψ(n) - ψ̂(n) |^2


It is worth mentioning that, although the objective function of an AE is the same as the Principal Component Analysis (PCA) method, the AE framework is more flexible and can handle nonlinear representations.



  §.§.§ Generative Adversarial Network (GAN)

Inspired by a 2-player game-theoretic method, GANs are considered as the most efficient approach for generating realistic data. The original framework of GAN was first introduced by Goodfellow  <cit.> and the implementation was optimized for the image data type (like MNIST). The idea is to have a generator G and a discriminator D that are trained to fight each other, where D classifies real/fake data knowing that G generates fake one and where G tries to fool D by generating data that is indistinguishable from the real one. Globally, the networks of a GAN are trained via a two-player minimax game, represented by the optimization of the following objective function:


    min_Gmax_D( .6!_ψ∼ p_ψ[ log D(ψ) ] + _z ∼ p_z[1 - log D(G(z)) ]) ,


where p_ψ is the distribution of the real input data ψ and p_z describes the Gaussian distribution of the random noise z used as an input of G. Basically, D is learned by performing gradient ascent on that objective function and G works by gradient descent on the same function. By following this alternating training approach, G eventually fools D with the generated realistic data G(z).

Even though the training process of a GAN seems easily doable in theory, it can be very unstable when trying to make it work in practice, especially for trajectory data. Therefore, designing an algorithm for efficiently training a GAN model might be necessary for some tasks. In our case of abnormal trajectory detection, it was necessary to apply a training algorithm that makes the learning of the GAN model much more stable.



 §.§ Our Method: Adversarially Learned Reconstruction Error Classifier (ALREC)

Despite the recent success in using the GAN framework, it is very unstable for trajectory data structure when the generator G is trained to generate realistic trajectories that are ordered sequences of points that must respect spatial and temporal constraints in order to fool the discriminator D. To tackle this problem, we propose to train G to generate instead some trajectory reconstruction mean squared errors (MSEs) that reassemble the ones obtained by using a trained DAE with normal trajectory data. The MSE is obtained with normal data by calculating the error between the input and the output of the DAE. The model D of our framework learns to distinguish real reconstruction MSEs from fake ones. Also, an adversarial criteria-based learning algorithm, which controls the learning speed of D and stops the training as soon as a particular criterion is achieved, is followed during the training process of our network in order to let D learn the most realistic abnormal MSEs as fake, while ensuring to classify the normal MSEs as real. When the training is completed, D is used for predicting if the observed trajectory data is normal (real) or not (fake). Figure <ref> illustrates the general architecture of our adversarial approach for detecting trajectory-based abnormalities.



The goal of our G during the training process is to start from generating random sets of reconstruction MSEs and to finish with the most realistic MSEs that might still be considered as abnormal. For example, a car that drives in the wrong direction will result in a very similar looking reconstruction MSEs when using the pretrained DAE, but the D model should be able to identify this as abnormal/fake. Figure <ref> shows the spectrum of abnormality that the generator G is approximately generating during the training process.



Before training our adversarial network, a DAE must be trained using the extracted and augmented trajectory data considered as normal, as already summarized above. After that, the partial averages of the reconstruction error (ϕ_s) are extracted in the following way for each trajectory sample s:


    ϕ_s    = .8![ ∑_i=0^L-1( ψ(i) - ψ̂(i) )^2/L, ∑_i=L^2L-1( ψ(i) - ψ̂(i) )^2/L, …, ∑_i=(M-1) L^M L-1( ψ(i) - ψ̂(i) )^2/L]
       = [ PMSE_0, PMSE_1, …, PMSE_M-1] ,


where PMSE is the partial mean squared error with respect to the input trajectory sample size N = M × L. By using the PMSEs instead of one MSE per sample, D can also learn the "normal" level of variations among each PMSE in ϕ_s. This enables D to distinguish the most realistic looking trajectory. Once the corresponding AE is trained and the ϕ_s are extracted for every training trajectory, the adversarial model, constituting of two networks G and D, is trained following the objective function:


    min_Gmax_D( .7!_ϕ∼ p_ϕ[ log D(ϕ) ] + _z ∼ p_z[1 - log D(G(z)) ])


where p_ϕ represents the distribution of ϕ_s retrieved using the pretrained autoencoder with the normal (real) data and D(…) is the classification decision of the discriminator D.

Algorithm <ref> presents the training process that stabilizes the learning of both G and D models of the GAN framework by basically controlling the learning rate of G (ι_g) relative to that of D (ι_d) based on the performance of G. The training stops as soon as D detects almost all the generated samples by G as real or, when it reaches the maximum number of epochs E_max. In the learning algorithm, α_D(ϕ_s) corresponds to the classification by D of ϕ_s as real, α_D(ϕ_g) is the detection of the generated ϕ_g as fake and α_G(ϕ_g) represents the classification by D of ϕ_g as real. Therefore, α_D(ϕ_g) = 1 - α_G(ϕ_g).



As previously mentioned, only the discriminator D network is used for the testing phase of our GAN framework. Also, the proposed adversarial approach can be seen as a way of transforming an unsupervised network, a DAE in our case, into a supervised binary classifier without the need of using abnormal data.




§ EXPERIMENTS

Our proposed adversarial method for classifying abnormal trajectories (ALREC) is tested on four different outdoor urban traffic videos obtained from the Urban Tracker dataset <cit.>, in which 1) the Sherbrooke video includes 15 cars and 5 pedestrians, 2) the Rouen video includes 4 vehicles, 1 bike and 11 pedestrians, 3) the St-Marc video includes 7 vehicles, 2 bicycles and 19 pedestrians and 4) the René-Lévesque video contains 29 vehicles and 2 bikes. As in <cit.>, all the observed trajectories are considered as being normal. To test our model, abnormal trajectories were generated. They correspond to 1) pedestrians walking in the middle of the road, 2) vehicles driving on the opposite/wrong directions, or in the bike paths or on the sidewalks, and 3) bikes going outside the bike paths when there is one. Figure <ref> illustrates normal and abnormal trajectories.



Also, in order to demonstrate the genericity of our proposed method, we conducted ablation studies in which ALREC is applied to six scenes from the INRIA dataset of the CAVIAR project <cit.>. As in <cit.>, we applied our method on 40 scenarios where 21 are labelled as normal (person walking, browsing, resting, people meeting) and 19 are labelled as abnormal (person slumping or fainting, leaving bags behind and people fighting).



 §.§ Experimental Setup

For comparing ALREC to the method of <cit.>, the same hyperparameters are used during the training of the DAE. To summarize it briefly, the input size of a trajectory sample is set to (1 + 4 × m) = 125, with m = 31 referring to the section <ref>. Then, we train the DAE, containing the following number of neurons in the hidden layers from the first to the last CFV layer: 128, 64, 32, 16, 8, with a batch size of 128 for 100 epochs. The learning rate is fixed to 0.001 using the RMSProp optimizer and the loss function is based on the MSE as presented in equation <ref>. The trajectory samples are collected by sliding a window over complete trajectories, and each complete trajectory of an object is augmented by randomly generating positions and velocities near the original ones.

The additional parameters necessary for the training of ALREC are presented in table <ref>. We have noticed that the discriminator learns better to differentiate between normal and abnormal PMSEs when the vector size of ϕ_s and ϕ_g is small enough and therefore M = 5 seems convenient because of the fact that N is divisible by M. For building the networks G and D, each layer has a number of neurons that is a power of two except for the input and the output layers in which they must have the same sizes of the desired input and output. Note that the size of the input layer in the G network is the same as the size of each random sample z. For the model D, which is the crucial part of our proposed method, we added an extra hidden layer in order to avoid over-fitting. We use the RMSprop optimizer during the training of our networks and the learning rate of G varies following algorithm <ref>, where K = 100. Also, the ReLU and the Sigmoid activation are used in the hidden and the output layers of all our networks respectively. Note that all the implementations[Codes in <https://github.com/proy3/Abnormal_Trajectory_Classifier>.] are done in a Python environment using the Keras package <cit.>.





 §.§ Evaluation Procedure
 
We follow the same evaluation procedure as in <cit.>. Once ALREC is fully trained using 80% of the normal trajectory dataset, it is tested with the other 20% of normal data and the abnormal data. The evaluation of the accuracy is based on Normal Detection Accuracy (NDA) and Abnormal Detection Accuracy (ADA). Given the number of normal sample Size_N and the number of abnormal sample Size_A, NDA and ADA are given by NDA = Size_N/Size_N+Size_A and ADA = Size_A/Size_N+Size_A.



 §.§ Results




  §.§.§ Abnormal Trajectory Detection

For demonstrating that our proposed adversarial classifier (ALREC) performs better than other well-known outliers detection methods, like One-Class Support Vector Machine (OC-SVM) <cit.> and Isolation Forest (IF) <cit.>, and two other based on a single layer AE and an DAE <cit.>, we trained the previous methods (using the code provided by the authors of <cit.>) with the same normal and abnormal trajectory data. Table <ref> shows the results for the classification of each trajectory sample. Note that, although we tried many adversarial approaches proposed in <cit.>, our ALREC is the first adversarial model that is compatible with the structure of our trajectory sample, where the training of the generator G and the discriminator D are stable.



With our proposed ALREC, table <ref> shows that the ADA is significantly better than all the other tested models including OC-SVM, IF, AE and DAE <cit.>, where the latter is used as the pretrained model in our ALREC. Therefore, we show that by adversarially learning to classify the reconstruction error extracted through the pretrained DAE, the abnormal trajectories are better detected, even with the most difficult ones of Rene-L. video. We notice that, generally, the ADA are noticeably better by around 20-30% for St-Marc and Rene-L. videos in which the abnormal samples are very close to the normal ones.

However, for the Sherb. video, the NDA results with ALREC are 1% lower than DAE <cit.>. The reason behind it is that our proposed ALREC model strictly follows the training algorithm <ref> in which the performance of NDA is limited by the condition that ensures to train D with the generated samples only if 99% of the normal reconstruction errors were detected as normal. Therefore, the "normal" generated samples by G, near the end of the training of ALREC, have a chance of lowering NDA by around 1%. In our case, this minimal degradation in NDA is not an issue, mainly because of the fact that we assumed all the observed videos as "normal" even though there might be some that are not. In that logic, a model that is trained to focus slightly more on the detection of abnormal trajectories than the normal ones is more preferable.



  §.§.§ Abnormal Events Detection

In this section, we demonstrate that, by using the INRIA lab entrance dataset of the CAVIAR project <cit.>, our proposed method can be generalized for other abnormal event detection and can give significantly better results than the state-of-the-art method of <cit.>. Each trajectory sample, in this case, follows a slightly different structure than the one defined in equation <ref>, in which the height h, the width w and the orientation o of each bounding box, which is already given in the ground truth, are taken into account.

We also added one additional hidden layer in the DAE and the GAN models, and adjusted the parameters of the table <ref> with N = 232, M = 8 and an additional hidden layer with 256 units, which is added in between the input layer and the first hidden layer of the generator and the discriminator of the GAN framework, and also in the encoder and decoder of the DAE network.

Table <ref> reports the results of ALREC compared to sparse reconstruction analysis (SRA) from <cit.> by using Detection Accuracy (DACC: the number of normal and abnormal test samples detected as normal and abnormal respectively) and Correct Classification Rate (CCR: the number of correctly detected normal test samples as normal) metrics introduced in <cit.>. Note that, in the case of ALREC, we consider that the complete trajectory of a user is abnormal if at least 5% of the corresponding trajectory samples are abnormal. Also, we used the best results that were presented in <cit.> with the same evaluation metrics in order to compare with their best results.



Results show that ALREC is able to detect all abnormal events as abnormal while detecting the normal ones as normal. Also, the improvement compared to SRA <cit.> is quite significant with around 10% in DACC and 30% in CCR. This illustrates that our approach is not only limited to abnormal road user trajectories but can also be generalized for broader applications like detecting abnormal events/activities including people fighting, running or leaving bags behind.



  §.§.§ Ablation Study

In order to further demonstrate the effectiveness of ALREC, we conducted an ablation study for the behavioural detection of complete trajectories using the INRIA lab entrance dataset in which we tested the various possible combination of DAE with ALREC are shown in figure <ref>. Note that the results were plotted by varying the classification behavioural threshold, which is the minimal amount of trajectory samples of a complete trajectory of an object that needs to be detected as abnormal in order for that complete trajectory to be labelled abnormal.



Results show that adding the adversarial learning framework on the pretrained DAE significantly improves the ADA as shown by the AUC. Also, adding additional features (height, width and orientation) into the data structure proves to better classify abnormal events from the normal ones. In addition, we observe that adding ALREC or additional features to the trajectory data does not affect the NDA.




§ CONCLUSION

In this article, we propose an adversarially learned reconstruction error classifier (ALREC) for detecting abnormal trajectory-based events by using a pretrained deep autoencoder (DAE) model. The adversarial method transforms a one-class DAE, which requires to manually define a detection threshold, to a two-class model that can classify normal and abnormal trajectories without that threshold. Compared to a typical GAN which is a generative model, our ALREC framework is a discriminative adversarial model that, instead of the generator generating fake trajectories, it rather generates abnormal MSEs that the discriminator learns to differentiate from the normal ones. An adversarial training algorithm is also proposed which makes the discriminator learn the most realistic looking abnormal MSEs while ensuring to learn the normal ones. The ALREC model was tested against other methods and was shown to outperform them. By conducting the ablation study, results show that all the components of our method ensure its success.







§ ACKNOWLEDGMENT

This research was supported by a grant from IVADO funding program for fundamental research projects.
















IEEEtran







