Mice are the most common and easily manipulated experimental model animals. The potential information embedded in their behaviors can reflect intrinsic physical and mental states. High-precision head-face segmentation helps track and analyze the behavioral patterns of mice. In biology and medicine, it is crucial for understanding the psychological state and neural mechanisms of mice. However, there are limited semantic segmentation studies for mice, with most focusing on the mouse as a whole rather than just the head or face. This study proposes a lightweight Yolov8-based algorithm that achieves high-precision segmentation of mouse head-faces using a small dataset of 120 images. The dataset is captured and processed by our team and available on Mendeley Data. Specifically, for model improvement, we incorporate a bidirectional retention mechanism for image-specific spatial attenuation within the backbone, enabling more efficient parallel inference. Additionally, our model dynamically adjusts feature weight allocation to utilize both local and global features effectively. The algorithm also introduces a lightweight detection head that reduces computational load and parameter quantities by sharing weights across layers. Experimental results demonstrate that our model achieves remarkable performance in the mouse head-face segmentation task, with a segmentation accuracy of 99.5 %, significantly surpassing the original Yolov8 model.