Utilizing magnetic anomaly data for effective edge detection of source bodies can provide crucial evidence for the delineation of geological units and the division of fault structures. However, the existing edge detection methods of source bodies from magnetic anomalies are influenced by factors such as the source bodies’ burial depth, magnetization direction, and mutual interference of magnetic anomalies, leading to errors in subsequent interpretation tasks. The advanced convolutional neural network possesses robust capabilities for feature representation and deep learning, prompting this paper to introduce an edge detection method for source bodies based on convolutional neural networks. The issue is initially framed as a semantic segmentation problem, and four network architectures aimed at edge detection of a source body from magnetic anomaly are designed and modified based on the U-Net and ResNet. Subsequently, a multitude of high-quality sample data sets are constructed using models with varying locations, scales, quantities, and physical properties to train the network. This paper then details model experiments that escalate from simple to complex, taking into account the combined effects of burial depth and inclined magnetization on edge detection. Compared to conventional edge detection methods, the method proposed in this paper is shown to accurately identify edges of source bodies at various depths with little impact from inclined magnetization and can automatically extract edge information without manual intervention. The method’s efficacy is corroborated through real data tests.