To address the problem that existing deep learning methods are not sufficiently accurate to detect rice pests with changeable shapes or similar appearances, a self-attention feature fusion model for rice pest detection (SAFFPest) was proposed. The model was based on VarifocalNet. First, a deformable convolution module was added to the feature extraction network, to improve the feature extraction ability of pests with changeable shapes. Second, by obtaining the balance features of multiple feature maps, the selfattention mechanism was introduced to refine the balance feature, in order to better restore the semantic information of some pests with similar appearances. Subsequently, the group normalization method was used to replace the batch normalization method in the original model, to reduce the impact of batch size on model training. The IP102 rice pest dataset was used to train and verify this model. The experimental results showed that the model can accurately detect nine kinds of rice pests, such as rice leaf rollers and rice leaf caterpillars. Compared with FasterRCNN, RetinaNet, CP-FCOS, VFNet and BiFA-YOLO, the mean average precision of the model improved by 33.7%, 6.5%, 4.5%, 2.9% and 2% respectively.