# Microorganism Detection in Activated Sludge Microscopic Images Using Improved YOLO
## 2 Materials and Methods
### YOLO Model  
In the field of object detection, there are primarily two architectures: the two-stage models, including R-CNN, Fast R-CNN, and Faster R-CNN, and the single-stage models, including the YOLO model and Single Shot Multibox Detector (SSD) [16]. Each of these architectures has its own advantages. Single-stage models offer an end-to-end training process, eliminating the need for complex two-stage computation. Additionally, single-stage models typically have simpler architectures and require fewer parameters, reducing the model complexity and the computational resources needed for training and inference. Their architecture makes them more deployable and user-friendly. Consequently, single-stage models like the YOLO model have found wider practical applications across various fields.  
The core of the YOLO model is to transform the object detection problem into a regression problem by employing a neural network that directly predicts the class and location information for each object [20]. In contrast to conventional object detection algorithms, YOLO eliminates the need for employing sliding windows of varying sizes across the entire image. Instead, the image is subdivided into grid cells of \(S\times S\) dimensions. Each individual grid cell is assigned the task of predicting both the bounding box and the class of one object. For an input image, it first passes through a convolutional neural network, resulting in an output tensor of dimensions \(S\times S\times(B\times 5+C)\), where \(B\) represents the quantity of predicted bounding boxes for each grid cell, and \(C\) represents the quantity of object classes. This output tensor can be interpreted as a three-dimensional matrix, where the first and second dimensions correspond to the rows and columns of the grid, and the third dimension contains information about the predicted bounding boxes and classes for each grid cell. In the output tensor, each grid cell predicts \(B\) bounding boxes, and each bounding box consists of 5 elements: center locations, width, height, and confidence. Furthermore, YOLO typically applies multiple detection layers, with each layer being responsible for detecting objects of different sizes and aspect ratios. It enables the model to detect large, medium, and small objects, enhancing the adaptability of detections [20].  
There are from YOLOv1 to YOLOv5, with continuous upgrades and improvements in the YOLO model [21]. Each version attempts to address the limitations of previous iterations and enhance the model's performance. Currently, the best-performing model is YOLOv5. In comparison to the previous iterations, it exhibits superior inference speeds and accuracy, making it more suitable for practical applications. There are three main parts in YOLOv5's architecture: the backbone network, the neck network, and the detection, as shown in Figure 5.  
In the detection of microscopic images, there were challenges related to the irregular shapes of the objects. The conventional convolutional modules in the original YOLOv5 model struggled to address these issues. Therefore, we introduced the DCN, which could help to dynamically modify the shape and position of convolutional kernels during the convolution process, thereby improving the ability of feature capture. Specifically, within the backbone network of the YOLOv5 architecture, we replaced all the standard convolutions with DCN modules for better feature capture.