Fluid inclusion is microscopic or nanoscopic cavity within minerals or rocks containing trapped fluids, and its detection is meaningful in various scientific and industrial applications. In response to the challenge posed by the presence of numerous small and medium targets in photomicrograph with clustered target distribution, resulting in difficulties in extracting target features and achieving low detection accuracy, this study proposes a fluid inclusion detection method based on improved YOLOX algorithm. We employ a sliding window approach and clip the photomicrograph enhance the representation of small targets. Furthermore, the Neck component incorporates the Convolutional Block Attention Module to enhance the feature representation, capturing both spatial and channel-wise attention, thereby improving localization accuracy. Moreover, the SIoU Loss is adopted as the loss function to optimize the training process in terms of both speed and precision. Experimental results demonstrate that the improved YOLOX algorithm outperforms the original YOLOX algorithm, exhibiting improvements of 1.8% and 1.9% in terms of AP50 and AP50:95, respectively. These empirical findings substantiate the effectiveness of the proposed enhanced model in fluid inclusion detection.