In few-shot object detection, as supporting samples are scarce, and the available class information is insufficient, it is particularly important to utilize feature information of limited samples effectively. By enriching usable semantic information in both supporting and query samples, a more comprehensive matching of information between query features and supporting features can be achieved. This is helpful for the model to understand target class in few-shot scenarios, thereby achieving object detection task effectively. Therefore, a model based on spatial context and pixel relationship was proposed. The spatial context module was designed to assist the pixels in constructing a local context region, thereby obtaining semantics of pixels in the region for the center pixel, and enriching the image feature information. In addition, to address the problem that spatial context introduces noisy information easily, the pixel context relationship module was designed to utilize original feature knowledge in the image to explore relationship between pixels and construct intra- and inter-class relationship maps, so as to correct the defect that spatial context module introduces noisy information easily. Experimental results demonstrate that when PASCAL VOC datasets is divided in three ways, the proposed model has the Average Precision (AP50) improved by 2.7, 2.0, and 1.3 percentage points, respectively, under 1-shot setting where samples are extremely sparse, compared to VFA (Variational Feature Aggregation); on MS COCO dataset, under 10-shot and 30-shot settings, the proposed model has the AP improved by 0.4 and 0.6 percentage points, respectively, compared to VFA, and the AP50 improved by 11.4 and 8.7 percentage points, respectively, compared to Meta FR-CNN (Meta Faster R-CNN). It can be seen that the proposed method improves the model’s ability to recognize new classes of samples by using limited feature information more effectively, which has reference value for improving generalization ability of the models in special scenarios where only a very small number of samples can be obtained.