# Cross Domain Adaptation of Crowd Counting with Model-Agnostic Meta-Learning
## 3 Methods
### Density-Map Estimator Module Based on Dynamic-\(\beta\) MAML  
With the rapid development of computer science, powerful computing and significant data volume have greatly improved the accuracy of computer-vision algorithms, and with great success [64]. However, there are still many challenges, one of which is model generalization. When there is limited labeled data, it is essential to apply a training method that improves model generalization [52]. The supervised learning algorithm aims to learn a function between image data and labeled data. Moreover, the meta-learning algorithm is trained in different tasks, each containing a training set and a testing set. Originating from meta-learning, few-shot learning solves the predictions problem with limited training samples, while also enabling the model to adapt to new, unseen scenes with little or no labeled data. In most real-world scenarios there is limited training data, so, improving the model generalization to adapt more scenes quickly is an area worth studying, particularly in crowd-counting problems. There are naturally different domains because of the angle, location, exposure, and position of photos. Thus, we mainly focus on the meta-learning model generalization method for estimating density in this section. Inspired by the alpha model-agnostic meta-learning algorithm, we propose a meta-learning-based approach to generate a dynamic learning rate for faster convergence. Therefore, this will allow the model to quickly adapt to new scenes. The MAML algorithm [62] is model-agnostic, which means that it is compatible with deep learning models trained with gradient descent. Therefore, we studied the approaches to adaptive crowd counting based on the MAML algorithm with a few samples. In this  
Figure 1: Comparison of the main proposed algorithm flow with general crowd-counting algorithm flow. The three modules proposed to enhance model generalization capability: Adaptive Domain-Invariant Features Extracting module, Dynamic-\(\beta\) Model-Agnostic Meta-Learning Density Estimator Module, and Counting Map Refiner Module. paper, we chose the GCC dataset [53], consisting of 15,212 synthetic images with different scenes: rainy, cloudy, night, and so on. We combined images in different scenes to organize multiple tasks for meta-learning [65]. The framework of the density-map estimator, based on model-agnostic meta-learning, is shown as Figure 2. The meta-learning aims to learn a mapping function \(g(\cdot)\), trained on a set of tasks. Each task contains a training dataset and a testing dataset. In Figure 2, the meta-learning is divided into two phases; the meta-train phase, and the meta-test phase. We aimed to improve the model generalization ability based on model-agnostic meta-learning. Furthermore, as the feature extraction parameters are fixed, we will discuss an adaptive feature extraction method in the next section, but the density estimating parameters are trainable. The MAML algorithm aims to adapt to a new task, \(\mathcal{T}_{t}\), with SGD, given the model parameters \(\theta\). Originating from model-agnostic meta-learning, the key to our learning procedure is to generate the initial parameters, \(\theta\), to adapt to new scenes quickly. Available domains \(\mathcal{D}_{meta-learning}\) are split into sets of meta-train domains \(\mathcal{D}_{meta-train}\) and meta-test domains \(\mathcal{D}_{meta-test}\). In our study, the feature extractor is defined as \(f(\cdot)\) and the density-map estimator is defined as \(g(\cdot)\). The \(p(\mathcal{T})\) is the distribution over tasks. \(\mathcal{T}_{train(t)}\) and \(\mathcal{T}_{test(t)}\) denote the training and testing datasets, respectively, corresponding with task \(t\). The basic MAML algorithm is formulated as below:  
\[\hat{\theta}_{t}=\theta-\alpha\
abla_{\theta}\mathcal{L}_{\mathcal{T}_{train }}(f_{\theta}) \tag{1}\]  
where, \(t\) is the task number, and \(\alpha\) is the inter-learning rate. The tasks are sampled from the meta-train domain \(\mathcal{D}_{meta-train}\).