1 Introduction

Over the last decade, machine learning has taken the scientific world by storm and even more so the commercial one. Even though it is not all old gold that glitters [1], the potential of machine learning to gain new insights into a variety of complex systems in science and society is unquestionably tantalizing [2, 3].

Deep learning is a sub-field of machine learning specifically inspired by the structure and function of the human brain [4]. Its core consists of artificial neural networks that imitate the operation of the human brain in data processing and decision making. In the actual digital era, which generates an unprecedented amount of data (Big Data) in the form of images, text, and audio-video clips, deep learning techniques have proved capable of extracting relevant information and correlations [4], sometimes dramatically abating the amount of time required by humans or classical algorithms to perform a similar task. This automation in learning from the data has led to the development of many useful computer applications, such as handwriting reading [5, 6], human speech analysis [7, 8], text sentiment analysis of posts on social media platforms [9,10,11], to name a few. In recent years, deep learning networks are being also used to study biological and physical systems [12, 13]. In microfluidics, for example, deep learning networks were employed to learn physical parameters, study the size and shapes of the droplets in emulsions [14, 15].

Nowadays, digital cameras assisted by deep learning are used everywhere for traffic management, surveillance, crowd management, automated billing, and customer services [16,17,18,19]. Given a video feed from these cameras, object detection and subsequent tracking of the detected objects are the two most basic tasks in computer vision before carrying out any further analysis. To achieve these tasks, deep learning algorithms are the fundamental tools.

In recent years, multi-layer convolutional neural networks (CNN) have a surge of popularity for feature extraction to accomplish object identification, classification, and tracking [20,21,22,23]. The output of the object detection network typically consists of bounding boxes encapsulating the identified objects for visual inspection. The tracking network across sequential images then processes the detected objects to construct tracks of moving objects. State-of-the-art deep learning models for object detection have demonstrated remarkable accuracy compared with classical algorithms and human performance [23, 24].

For the first task of object detection, various deep learning-based models differ in their network architecture, such as the number of convolutional layers, number of pooling layers, filter sizes, and the base algorithm used to analyze the input. At present, Faster region-based convolutional neural networks (FRCNNs) [21], You Only Look Once (YOLO) [23], Single Shot Detector (SSD) [25] are state of the art in the field. Out of these models, we adapt the YOLO algorithm for object detection due to its ease of training and superior image analysis speed, which is further scalable using GPUs. For the second task of tracking the detected objects, we employ a state-of-the-art DeepSORT algorithm [22], which uses the appearance of the objects to track them across a sequence of frames. Recently, YOLO and DeepSORT algorithms have been deployed for several real-world applications, such as monitoring covid-19 protocols in real-time [26, 27], tracking ball or player trajectories in sports [28, 29], and many others.

In this work, we develop YOLO + DeepSORT based droplet recognition application to analyze the multi-core emulsions and soft granular media simulated via Lattice Boltzmann (LB) methods. We train the object detection network to identify droplets from digital images with a synthetically prepared dataset, thereby avoiding the labor-intensive training data gathering process. In principle, the developed application can also be used to analyze the data generated by the experimental setup of similar physical systems. The goal is to extract trajectories of the center of mass of individual droplets as they move within the flow and then use this information to analyze the dynamics of this complex many-body system. The application developed in this work can extract trajectories of the droplets in real-time by analyzing the video of the system.

The paper is organized as follows. Before we dive into details of the YOLO + DeepSORT based droplet recognition application, in the next section, we provide a brief account of the Lattice Boltzmann method and relevant simulation details. In Sect. 3, we describe the YOLO and the DeepSORT methods and how the training is implemented. In Sect. 4, we report our results on a four-core emulsion and a more complex soft granular material, focusing on the accuracy of the YOLO + DeepSORT procedure in trajectory extraction. Finally, we analyze extracted trajectories of the droplets in a dense emulsion system and compare them with apparently similar active matter systems such as a flock of birds.

2 Lattice Boltzmann method and simulations

We employed two variants of the Lattice Boltzmann approach for the multicomponent flows simulations, namely the color-gradient approach with near-contact interactions and the free energy model for multicomponent fluids. In Appendices A and  B, we briefly outline the two models, while in the following sections, we report the simulation details for the two physical systems under consideration.

2.1 Simulation details for translocation of a soft granular material within narrow channels

This system is studied using the color gradient LB. The simulation setup consists of a two-dimensional microfluidic channel made of an inlet reservoir followed by a thinner channel connected to a further downstream reservoir. The height of the chambers is \(h=600\) lattice units and the one of the constriction is \(h_s=120\) lattice units while its length is \(l_s=240\) lattice units. We impose a bounce-back rule for the distribution functions at the walls, while at the outlet, we employ absorbing (zero gradient) [30].

The soft granular material is formed by droplets (component A, white region in Fig. 1) immersed within an inter-droplet continuous phase (component B, blue lines) surrounded by an external bulk phase (component C, black region outside the emulsion). Its structure closely resembles that of a high internal phase double emulsion with multi-core morphology [31, 32]. In Fig. 1a we show a snapshot of the domain with the relevant dimension of the geometrical setup and in Fig. 1b a translocation sequence of the soft material made of \(N_d=49\) internal droplets occupying an area fraction \(\phi \simeq 0.9\).

Fig. 1
figure 1

a A triple emulsion with \(\phi \simeq 0.9\) and \(N_d=49\) initialized within the inlet chamber. b Translocation dynamics of a dense emulsion \(\phi =0.9\), \(N_d=49\) and \(h_s/D\simeq 0.45\). Once the emulsion crosses the constriction, the resulting shape observed in the outlet chamber crucially depends on the area fraction \(\phi \)

In our numerical experiment, a uniform velocity profile of speed \(U_{in}=2\times 10^{-3}\) (in simulation units) is imposed at the inlet, which pushes the emulsion within the narrow constriction. Finally, the value of the velocity ensures that Capillary and Reynolds numbers remain well within the typical range of microfluidic experiments (\(Ca\sim \mathcal{O}(10^{-3})\) and \(Re\sim \mathcal{O}(1)\)).

2.2 Simulation details for a flow of a multi-core emulsions within a microchannel.

Here we report the numerical details of the multi-core emulsion simulated using the free-energy LB. The droplet is set between two flat walls placed at distance \(L_y\), where no-slip conditions hold for the velocity field \(\mathbf{v}\) and neutral wetting for the fluid density \(\psi \). The former means that the velocity is zero at the boundaries, while the latter that no mass flux crosses the walls where droplet interfaces are perpendicular.

In Fig. 2 we show two examples of multi-core emulsions whose design is inspired by experimental realizations. They are made of monodisperse immiscible droplets arranged in a symmetric configuration. In Fig. 2a, three cores (white) of diameter \(D_i=30\) lattice sites are accommodated within a larger drop (black) of diameter \(D_O=100\) lattice sites, in turn, surrounded by a further fluid (white). An analogous setup is used for the four-core emulsion (see Fig. 2b). Starting from these configurations, the emulsions are then driven out of equilibrium by applying a symmetric shear flow, where the top wall moves rightwards (along the positive x axis) at constant speed \(v_w\) and the bottom wall in the opposite direction at speed \(-v_w\). This sets a shear rate of \(\dot{\gamma }=2L_y/v_w\). In previous works [33, 34], it has been shown that, once the shear is turned on, the external shell elongates and aligns along the direction imposed by the flow, while the internal cores acquire a periodic rotational motion triggered by a fluid vortex formed within the emulsion. These dynamics persist over long periods of time provided that the shear is on. In Fig. 2c, d we show two instantaneous configurations of a three and a four-core emulsion at late times, where \(\dot{\gamma }\simeq 10^{-4}\) with \(v_w=0.01\) and \(L_y=170\) in simulation units.

Fig. 2
figure 2

a, b Initial configurations of a three and a four-core monodisperse emulsion. The diameter of the cores is \(D_i=30\) lattice sites while that of the shell is \(D_O=100\) lattice sites. c, d Examples of instantaneous configurations of a the multi-core emulsions subject to a symmetric shear flow. The shear rate is \(\dot{\gamma }\simeq 10^{-4}\) in simulation units. In both cases internal cores rotate periodically clockwise, following an almost elliptical path triggered by the fluid vortex confined within the shell. For more details see Ref.[33, 34]. Here \(Ca\simeq 0.2\) and \(Re\simeq 1.2\)

This system approximately corresponds to a real multi-core emulsion with a shell of diameter \(\simeq 100\mu \)m and cores of diameter \(\simeq 30\mu \)m, having a surface tension ranging between \(1-10\)mN/m, a viscosity \(\simeq 10^{-1}\) Pa\(\cdot \)s and a shear rates varying between \(0.1-1\)/s. Like in the previous method, Capillary and Reynolds numbers here range between 0.1 and 1 as well, as in typical microfluidic experiments.

The output of the simulations of the physical systems described above are saved as video files and later given as input to the deep learning-based application for automatic extraction of the trajectories of the moving droplets. In the supplementary material [35], see video1.avi file for the simulation output of translocation of triple emulsions within narrow channels and video2.avi for a flow of multi-core emulsions within a microchannel.

3 Technique

In this work, we develop an application to extract trajectories of individual droplets simulated via LB methods by adapting two different algorithms, one for object detection and another one for object tracking. The first task consists of training an artificial neural network to analyze digital images and locate the objects of interest, which in this case are the droplets. Later, the second task is to track the located objects across multiple sequential frames to infer their trajectories. Figure 3 shows the typical steps involved to accomplish the object recognition task [36]. In the following section, we briefly describe the algorithm employed for the object recognition.

Fig. 3
figure 3

Typical steps in developing the deep learning-based application for object detection. In the training phase, difference between prediction and truth is used to improve the accuracy of the network by updating the parameters of the network. At the inference stage, a real world data, in our case from LB simulation, is fed to the network to obtain the bounding boxes around the droplets

3.1 You only look once (YOLO)

You Only Look Once (YOLO) is a state-of-the-art algorithm that employs a single multi-layer network for object identification and classification. The YOLO algorithm has shown remarkable accuracy with high processing speed in identifying and classifying objects from the COCO dataset, which consists of 80 types (classes) of everyday objects [23].

Fig. 4
figure 4

High level sketch of the YOLO network structure

The building structure of the YOLO network consists of two main components, a feature extractor and a detector. When an image is given as an input to the YOLO network, the extractor (also called backbone) produces feature representations at different scales (see Fig. 4). Such representations are then passed to the detector that outputs the bounding boxes along with the confidence score and the classes of the detected objects. In this work, we use the YOLO algorithm to identify droplets in the digital images produced by LB simulations of two physical systems. We employ the YOLO-v3 network, which uses the Darknet-53 network as a backbone. The Darknet-53 is a deep network consisting of 53 layers, which has shown significant improvement in object detection over its predecessors YOLO-v2 and YOLO-v1, which employ backbone with fewer layers [24].

The YOLO algorithm achieves high speed of image analysis due to its operating principle, namely by treating object detection as a regression instead of a classification task in determining class probabilities to the bounding boxes. The operating procedure of the YOLOv3 algorithm is sketched in Fig. 5. All objects in the given images are located and classified simultaneously. To achieve that, the YOLO algorithm divides the input image into \(S \times S\) grid cells. Each grid cell is responsible for detecting an object if the object’s center is within the cell domain. Each grid cell predicts B bounding boxes with their confidence score for the object and C conditional class probabilities for the given object belonging to a specific class. This information is then combined to produce the final output as a single bounding box around the detected object along with the class of that object. The final output is then passed to the DeepSORT algorithm for tracking the droplets.

3.2 DeepSORT

DeepSORT is an algorithm that tracks detected objects between two successive frames [22]. By analyzing sequential frames, DeepSORT can construct trajectories of individual objects. It uses the Hungarian algorithm to distinguish the objects detected in two consecutive frames and assigns individual objects their unique identity. Kalman filtering is then used to predict the future position of the objects based on their current positions.

The YOLO and the DeepSORT algorithms together accomplish droplet recognition and tracking from the simulated systems. In the next section, we outline the training data acquisition process employed in this work and later describe the training process for the YOLO network for droplet detection.

Fig. 5
figure 5

Operating principle of the YOLO algorithm. Initially, an input image is split into \(S \times S\) grid. In the next stage, multiple bounding boxes are predicted along with a class probability map (blue color highlights cells hosting an object belonging to the “droplet” class) to give final bounding boxes and classes of objects

3.3 Training data

Before training a network, acquiring training data is a crucial part of an object detection network. Training data consists of several images of the objects to be detected along with information about their location and dimensions. Practically, acquiring the training data is a labor-intensive task involving gathering the images and manually marking the positions and dimensions of the objects. For example, gathering thousands of images of street view cameras and marking the location of the cars to train a network to identify cars in a video feed. In addition, the prospect of manual marking of the objects makes the training data susceptible to human errors.

We avoided the labor-intensive process by preparing a synthetic training data set. In this dataset, each image is a collage with few solid white circles, mimicking the droplets placed randomly on a dark uniform background. The solid white circles of different sizes and shapes are prepared with commonly used computer graphics software. A separate text file is generated to note the positions and dimensions of the randomly placed droplets. A Python script generates several thousand images and associated text files in a matter of few seconds. The script is provided in the supplementary material [35]. We prepared several types of training datasets, and the detailed description is given in Appendix C.

We wish to emphasize that the training data, prepared synthetically, was intended to mimic the snapshots of the LB simulation, and it is not generated by a physical process associated with LB simulations. However, it is noteworthy that the synthetic data preparation method described above bypasses the labor-intensive data acquisition part and minimizes human errors, thus making the development process of the droplet tracking application much quicker and more precise. This method can potentially be used in several other object detection applications. In the next section, we describe the YOLO network’s training process to identify the droplets with the synthetic data.

3.4 Training

The training of the YOLO network is carried out through an iterative process. A subset of training data, called batch size, is passed through the network in each iteration, and then the network predicts the bounding boxes around the detected objects. A loss value is computed based on the difference between the output and the ground truth. The supplied label information is taken as the ground truth. The network parameters (weights and biases of the nodes) are updated to minimize the total loss and improve the accuracy of the network. For the YOLOv3 algorithm, the loss value, also called total loss, is the weighted sum of three separate contributions, regression loss, confidence loss, and classification loss [23]. In the training process, the weights of these contributions to the total loss are the same as proposed in Ref. [23] to optimize the mean average precision and maintain the model stability.

At regular intervals, i.e., after a few iterations, the accuracy of the network is assessed by computing mean average precision (mAP) [37, 38]. The mean average precision is a good measure to know how well the trained network performs on a dataset that is different from the training dataset. Typically, a separate dataset, called validation dataset, is compiled to compute the mean average precision.

We trained two YOLO networks to identify the droplets from the LB simulations. We adapted the code for training the network from Ref. [39]. The first network, called YOLO-tiny, is a lighter version of the full YOLO network consisting of fewer convolutional layers than the full YOLO network to trade training and inference speed for accuracy. For many practical purposes, the lighter version (YOLO-tiny) does perform reasonably well.

For training the YOLO-tiny network, we consolidated a total of 10000 images, consisting of an equal number of two different types of synthetic images as shown in Fig. 14a,b. The parameters set for the training are mentioned here [40]. The parameters of the network are updated at the end of every batch. A separate dataset of 1000 images, called validation data, was prepared from the same type of images to calculate the mean average precision. The total loss and mean average precision as the training progresses are shown in Fig. 6a. As the training progresses, the total loss decreases, and the mean average precision of the network increases, indicating that the network is gaining performance with the training, reaching a total loss value very close to zero at the end of the training. The mean average precision value is saturated to 0.985, indicating that the network is 98.5% accurate in detecting the droplets in broad terms.

Fig. 6
figure 6

Total loss and mean average precision (mAP) as the training progresses. a YOLO-tiny network, b YOLO network

The second network we trained is the full YOLO network, with Darknet-53 as a backbone. Ten thousand images similar to the image shown in Fig. 14c were used as the training data. Another 1000 images of the same type were reserved as the validation data, and the training parameters are listed in  [41]. In this case as well, as the training progresses, the total loss decreases and mean average precision augments (as seen in Fig. 6b) saturating to 0.99, i.e. the network is 99% accurate in detecting the droplets. The trained model in the form of a binary file containing the model’s parameters (called weights) is saved. The weight file will be used later to analyze the data from LB simulations, and it is provided for both networks, the YOLO-tiny and the YOLO, as supplementary material [35].

By training the YOLO network, we accomplish the first task of droplet recognition from the digital images, while the DeepSORT algorithm handles the second task of droplet tracking. In the next section, we analyze two LB simulations as case studies to test and use the developed application.

4 Results

After the model is trained with the desired accuracy in terms of mean average precision, it is ready to analyze the real-world data. From simulations or experiments, the real word images can be given as input to the trained network, and individual droplets’ trajectories can be obtained. This process is also called inference.

We run inference on the data generated with two LB simulations to test our trained network as described in Sect. 2. For inference, only the droplets (white color mass) were plotted on a dark background. The output video was then fed to the YOLO + DeepSORT network to infer the trajectories of individual droplets. We adapted code with Tensorflow implementation to run inference from Ref. [42].

4.1 Multi-core emulsions

Figure 7 shows a visual depiction of the object recognition by the YOLO network and tracking of the located objects by the DeepSORT network in four sequential images from the LB simulations. The bounding boxes predicted by the YOLO network are shown in blue color, and the unique ID assigned by the DeepSORT algorithm is written above each bounding box (see video3.avi).

Fig. 7
figure 7

Object detection and tracking at sequential frame number N. a \(N=18\), b \(N=19\), c \(N=20\), d \( N=21\)

Fig. 8
figure 8

Extracted trajectories of the center of mass of the individual droplets in a four core emulsion. On X-axis and Y-axis are the pixel numbers

It is then straightforward to extract trajectories of the individual droplets across sequential frames since we have dimensions of all the bounding boxes in all the frames with their unique ID. The center of mass of the individual droplets is approximated as the geometric center of its bounding box. Figure 8 shows the paths traced by the droplets.

4.2 Soft granular media

In the second case, we run inference on LB simulation of soft granular media. This time, we employed the YOLO network to identify the droplets since the trained YOLO-tiny network makes many mistakes in droplet recognition. This is likely due to the increased complexity of the system, which presents a densely packed configuration of droplets moving through a narrow channel significantly deviating from its initial shape.

Fig. 9
figure 9

Droplet recognition and tracking in four frames with frame number a \(N=5\), b \(N=6\), c \(N=8\), d \(N=9\). Blue bounding boxes are generated by the YOLO algorithm and unique IDs are assigned by the DeepSORT algorithm

The YOLO network, however, can locate the droplets with almost perfect accuracy. Here, we note again that the training of the YOLO network was carried out with the training data consisting of randomly placed dense clusters of solid white circles. As before, Fig. 9 shows the droplet identification by the YOLO network and tracking with the DeepSORT algorithm. The recognized droplets are shown with blue bounding boxes, and the unique IDs assigned by the DeepSORT algorithm are placed within the bounding box for visual inspection (see video4.avi).

In Fig. 10, we plot the extracted trajectories of the center of mass of the individual droplets. The center of the bounding box is approximated as the center of mass. In this case, we obtain 49 trajectories for the 49 droplets. Each separate trajectory is shown with a unique color.

Fig. 10
figure 10

Extracted trajectories of the center of mass of the individual droplets represented by unique colors. X and Y axis show the pixel number

4.3 Accuracy of the trained model

During the training, validation data were used to estimate the accuracy of the object detector model. In our case, they were statistically identical to the training dataset and could provide a biased estimate of the accuracy. Unbiased accuracy of the trained model can be obtained by analyzing a test case (also called test data), ideally from a real-world dataset with known droplet trajectories. From the output trajectories of the model and the known trajectories as ground truth, the accuracy of the trained model can be estimated for real-world applications.

To measure the accuracy of the trained model, we compute mean square errors (MSE) by a Euclidean metric:

$$\begin{aligned} MSE = \frac{1}{N}\sum _{i=1}^{N} (y_{cm}(i) - \hat{y}_{cm}(i))^2. \end{aligned}$$
(1)

Here, N is the total number of frames, \(y_{cm}\) is the ground truth y coordinate of the center of mass, \(\hat{y}_{cm}\) is the inferred y coordinate of the center of mass by the deep learning tool.

Fig. 11
figure 11

a – d Comparison of the inferred center of mass of the four individual droplets in every frame with the ground truth computed by the analytical expression in Ref. [34]. Mean square error MSE between the inferred values and the ground truth values is computed to measure the error. (a) \(MSE = 3.44 \times 10^{-2}\), (b) \(MSE = 1.80 \times 10^{-2}\), (c) \(MSE = 3.12 \times 10^{-2}\), (d) \(MSE = 1.59 \times 10^{-2}\)

We measure the accuracy of the YOLO-tiny + DeepSORT model by comparing the inferred trajectories of the droplets with the known ground truth. In this case, the ground truth is the center of mass computed with an analytical expression (see Ref. [34]). In Fig. 11, we compare the ground truth y-coordinates of the center of mass (\(y_{cm}\)) of individual droplets with the inferred y-coordinate values (\(\hat{y}_{cm}\)) by the deep learning tool. We observe that the deep learning model agrees with the analytical expression after a few initial frames. However, in the initial frames, the deep learning model slightly deviates from the true values, even though both the curves are in qualitative agreement. The mean square value MSE is of the order of \(10^{-2}\) for all four tracked droplets, indicating a good agreement between the ground truth and the inferred values.

Fig. 12
figure 12

Measuring accuracy of the YOLO + DeepSORT model. a – d Inferred path of four different droplets compared with their predefined paths. Mean square error MSE between the inferred values and the ground truth values is computed to measure the error. (\(\mathbf {a}\)) \(MSE = 1.41 \times 10^{-4}\), (\(\mathbf {b}\)) \(MSE = 1.52 \times 10^{-4} \), (\(\mathbf {c}\)) \(MSE = 1.55 \times 10^{-4} \), (\(\mathbf {d}\)) \(MSE = 1.45 \times 10^{-4} \)

For measuring the accuracy of the full YOLO + DeepSORT model, we prepared a synthetic test case where the center of mass of the droplets move along some predefined paths (see Appendix D). The predefined paths serve as the ground truth. We employed the YOLO + DeepSORT model to infer trajectories of the droplets from the video and the comparison is shown in Fig. 12. Four droplets were tracked and the inferred path is compared with the known predefined trajectories of these droplets. Both the trajectories are in excellent agreement and we see no deviation in the inferred and true trajectories in any phase of the tracking. The YOLO + DeepSORT model is highly accurate with MSE of the order of \(10^{-4}\). The low values of mean square errors once again point to the high accuracy of the trained model.

We emphasize that we measure the accuracy of the developed application, including the object recognition and the object tracking process. The error values are indicative of the total expected error in extracted trajectories from the real-world data. Apart from the model’s accuracy, the model’s analysis speed is an important factor to consider while developing an application for practical use. In the next section, we report the inference speed, i.e., the rate of image analysis by the developed application on different computer hardware configurations.

4.4 Inference speed

We test the inference speed of the object detection and tracking model on a typical notebook computer and a commonly used GPU machine. For inference, we used Tensorflow implementation [42]. The inference speed, analyzed frame per second (FPS), for the YOLO-tiny and the YOLO network are tabulated in Table 1.

Table 1 Average inference speed in frames per second (fps) on two hardware configurations

These data clearly show that there is room for improvement and optimization of the inference speed for both YOLO and DeepSORT, for instance, by coding them in other programming languages, such as C++. This is an interesting topic for future work.

Having accurate trajectories of moving objects is the first step to study the system. In the next section, we present an analysis of the inferred trajectories to test a hypothesis.

4.5 Flocks of droplets?

At first sight, the droplets seem to move like the agents in active matter systems, such as birds in a flock. Several statistical physics models have been proposed to explain the flocking behavior in animal groups [43,44,45], and experimental studies involving observation of moving animal groups inferred the interaction rules between the agents [46, 47]. One prominent feature common in most of these models is that the agents (birds) move along the average direction of their neighbors.

Given the superficial similarity between a flock and the soft granular media system studied here, we perform a quick analysis to test a hypothesis that the droplets behave like agents in an active matter system. To this end, we calculate the average moving direction \(\theta _S\) of the neighbors of each individual droplet. The neighbors of droplet i are defined as droplets within a circle of radius R, fixed on the center of the droplet i. We set the size of the neighborhood in such a way that few neighboring droplets are included (see Fig. 13a). Figure 13b shows a scatter plot between individual droplet’s moving direction \(\theta _i\) and the average direction of their neighbors \(\theta _S\) for the entire duration of the simulation. The moving direction is measured as angle \(\theta \) made by the velocity vector with the x-axis in a fixed frame of reference. Thus, the range of \(\theta \) is from \(-\pi \) to \(+\pi \). Each different color in this plot shows a separate identity of the individual droplets. The red line is a guideline for the eyes to show the situation when the individual droplet’s moving direction is identical to that of its neighbors.

Fig. 13
figure 13

a Neighborhood of one of the randomly chosen droplet. The neighborhood of a droplet is a circle with \(R=30\) pixels. b Scatter plot of the direction of individual droplets \(\theta _i\) with the average moving direction of droplets \(\theta _S\) in the neighbourhood of the droplet i. Values on the axes are in radians. The thick red line is a guideline to identify instances when the moving direction of droplets and their neighbors are identical

In Fig. 13, around 47% of all the total points are in the band when \(\vert \theta _i - \theta _S \vert < 0.12\). i.e., when the angle between the droplet’s motion and its neighbors is less than 7 degrees. This suggests that the moving direction of individual droplet deviates (by more than 7 degrees) from the average direction of their neighbors 53% of the time.

We conclude that individual droplets frequently deviate from the average direction of their neighbors than the individual birds do in a polarized flock. This is plausible since, besides some similarities, there are also several points of departure between the two systems. First, in soft granular media systems, the fluid flow carries the droplets along the flow direction, like a systematic wind and second, the wall boundaries impose a stringent constraint on the motion of the droplets. None of the two aspects above are generally considered in the modeling of active matter systems.

In this analysis, we compared only the polarization between the system of droplets and the ordered flock. Numerous other observations characterize a flock [48], and a detailed comparison is required to quantify the similarities between these two systems. Nevertheless, this raises an interesting question on how to generalize the flock equations to come up with a set of effective equations of the droplets in complex many-body flows such as the one explored here. We plan to address this question in future work.

5 Conclusions

We adapted and combined deep learning-based object recognition algorithm YOLO and object tracking algorithm DeepSORT to analyze data generated by fluid simulations of two soft flowing systems, multicore emulsions, and soft granular media. In particular, the trajectories of the individual droplets moving within a microchannel flow were extracted from the digital images of the system.

We determine the accuracy of the complete application by comparing the inferred trajectories with the ground truth trajectories computed by independent methods. Although we used LB simulation data as a case study; the developed application can also be applied data generated by two-dimensional experimental setups.

With the use of commonly available GPUs, the YOLO + DeepSORT based application can analyze the images at a remarkable rate, above the image capture rate of typical cameras, thus offering a practical, low-cost application capable of analyzing real-time data as it is acquired.

From the technical point of view, we showed that the synthetically prepared datasets could be used to train the object detection network with almost perfect accuracy, thus avoiding labor-intensive, time-consuming training data acquisition for object recognition network training.

We combined two state-of-the-art algorithms to identify and track the droplets and tested the model on two physical systems. It would be interesting to see how the application works for other dense emulsion systems. Nevertheless, YOLO and DeepSORT have shown remarkable performance in object recognition and tracking in more complex environments. We hope and expect that further developments of the work presented here may pave the way to the automatic detection and tracking of moving agents in complex flows of scientific, engineering, and biological interest.