# DWPIs: Dynamic-Weight Parallel Instance and Skeleton Network for Railway Centerline Detection
The fitting procedure relies on several empirical parameters, including the number of splitted bins used to segment the mask, the threshold for the association between nodes representing the discrete trapezoidal blocks, the length of filter lines, and the number of filter strong nodes. They are determined through human experience and fixed in advance, thus lacking a theoretical basis. In addition, the fitted curves are not coherent and smooth, resulting in oscillation during the UAV's flight. To avoid these problems, we propose obtaining the centerline of the railway directly using an end-to-end method. Whether the railway in the image is straight or curved, the structure of the railway remains symmetrical. Skeleton is a descriptor that can reveal the symmetry of an object [22]. Therefore, the centerline of the railway, which is needed to guide the UAV's autonomous flight, can be viewed as the skeleton of railway. Through an end-to-end skeleton-detection neural network, the uncertainty caused by the human-determined parameters mentioned above can be reduced. However, extracting the features of the railway skeleton is not an easy task, as objects with a similar shape to the skeleton may be misidentified due to the diversity of the railway's environment. To exclude the skeletons of other useless objects, an end-to-end instance-segmentation neural network is added in parallel to detect the target railway. This parallel network is utilized to extract the features of the useful region, which contains the correct skeleton. Based on the ideas presented above, this paper proposes a novel method called the dynamic-weight parallel instance and skeleton network (DWPIS). The DWPIS network is composed of an instance-segmentation branch based on SOLov2 [23] and a skeleton-detection branch based on our previous work, AdaLSN [24]. The two branches are combined using a fused loss function with dynamic weight. The purpose of this work is illustrated in Figure 1 and the contributions of this paper are summarized as follows:  
* Given the constant shape and structure of the railways, their centerline can be viewed as a skeleton to guide UAVs' autonomous flight. This paper extracts the skeleton directly through an end-to-end skeleton-detection neural network and locates the target through an instance-segmentation neural network, rather than computing and fitting the centerline using detection results. * For the instance-segmentation branch, this paper changes the backbone to the ELAN-based [25] backbone as in YOLOv7 [26], and adds the attention module SimAM [27] after each level of features in the backbone. Experimental results show that the detection accuracy of the instance segmentation is improved. * For the skeleton-detection branch, this paper changes the loss function to Dice loss [28] due to the serious imbalance between skeleton pixels and background. Furthermore, a threshold function is added after the sigmoid function in the inference process to enhance the skeleton results. * This paper designs a fused loss function to adjust the weight of the two parallel branches during training, where the sum of the weights for the two parts remains one. The weight of the loss for the instance-segmentation branch decreases from a large value to quickly extract the necessary features. Meanwhile, the weight of the loss for the skeleton-detection branch gradually increases, to become dominant. The rest of this paper is organized as follows. In Section 2, the work related to the instance-segmentation and skeleton-detection methods is outlined. In Section 3, the architecture of the proposed DWPIS is presented, including the two parallel branches and the novel fused loss function with dynamic weight. In Section 4, the experiments and analysis are discussed. In Section 5, the conclusion is presented.