# Adaptive Detection and Classification of Brain Tumour Images Based on Photoacoustic Imaging
## 2 Materials and Methods
### Deep Learning Algorithm for Brain Tumour Detection Segmentation  
Brain tumour detection segmentation is a key task in medical imaging analysis. Existing detection segmentation methods suffer from the lack of effective adaptivity to adequately adapt to different scenes and data feature changes. The YoLov8-MedSAM model proposed in this paper is based on the YoLov8 algorithm [26; 27; 28] for the target detection of photoacoustic brain tumour images which accurately locates and labels brain tumour  
Figure 1: A flowchart of the overall framework.  
Figure 2: Photoacoustic imaging image reconstruction.  
regions and subsequently uses the MedSAM model to directly segment the labelled regions with different brain tumour sizes and shapes without the need to input the user-drawn bounding box. The YoLov8-MedSAM model proposed in this paper can effectively solve the problem of the lack of adaptivity of existing methods, achieve the accurate detection and segmentation of photoacoustic brain tumour images, and provide an efficient and reliable auxiliary tool for medical imaging diagnosis, and its model overview diagram is shown in Figure 3.  
YOLOv8 is an advanced neural network architecture for target detection, known for its efficient real-time detection and accuracy [26]. Its core architecture consists of a deep convolutional neural network, which combines multi-scale feature fusion and an attention mechanism to achieve accurate target localisation with precision, and the network structure is shown in Figure 4. The YOLO model [29] is different from the two-stage detectors of the R-CNN family, and the single detector is more focused on predicting the position and category of the object at the same time, which can be focused on predicting both the position and category of objects at the same time and achieve faster and high detection accuracy, which is suitable for various application scenarios of real-time target detection tasks.  
The YoLov8 model [28,30,31] consists of four components: input, Backbone, Neck, and Head. Among them, Backbone is responsible for feature extraction and employs the C2f module and SPPF for feature fusion [32]; Neck employs FPN and PAN to achieve multi-scale feature fusion; the Head component switches from an anchor-based to an anchor-free  
Figure 4: YOLOv8 network architecture.  
Figure 3: An overview of the YoLov8-MedSAM model.  
approach and uses task-oriented allocators to perform positive-negative sample matching. The YoLov8 model ultimately achieves small, medium, and large target accurate prediction.  
MedSAM is a deep learning-based medical image segmentation network that is a fine-tuning of the network architecture of SAM [26]. MedSAM incorporates convolutional neural networks (CNNs) and Recurrent Neural Networks (RNNs) and introduces state-of-the-art techniques such as dense connectivity and attention mechanisms. As the first basic model in the field of general purpose medical image segmentation, MedSAM is able to accurately identify and describe important regions in medical images, such as tumours or other tissue lesions, and the model includes specific components and ways of interaction of neural grids and neural networks. The model follows the network architecture in SAM and includes an image encoder, a cue encoder, and a mask decoder, as shown in Figure 5. The image encoder maps the input image to a high-dimensional image embedding space, the cue encoder converts the user-drawn bounding box into a feature representation by positional encoding, and finally, the mask decoder fuses the image embedding and the cue features using cross-attention. The network uses pre-trained convolutional neural networks (e.g., ResNet, VGG, or U-Net) to capture the features underlying medical images. The network has the ability to accurately segment lesion regions and extract key feature information, providing physicians with an efficient and reliable diagnostic aid.