Fig. 3: Network architectures used in the chemical detection and classification pipeline.

a EdgeNet is built on a transformer backbone for edge detection; it outputs the probabilities of 2 classes: Edge/Other. b The internal structure of the transformer encoder, featuring a multi-head self-attention mechanism. c The schematic of a multi-head attention. d ClassNet, implemented using a CNN for multi-class chemical classification. EdgeNet leverages the global contextual modeling capabilities of transformers to accurately detect sample boundaries, while ClassNet utilizes the local feature extraction strengths of CNNs to enable efficient and robust chemical identification within the sample FOV. B: batch size