Frequent outbreaks of cyanobacterial blooms have become one of the most challenging water ecosystem issues and a critical concern in environmental protection. To overcome the poor stability of traditional detection algorithms, this paper proposes a method for detecting cyanobacterial blooms based on a deep-learning algorithm. An improved vegetation-index method based on a multispectral image taken by an Unmanned Aerial Vehicle (UAV) was adopted to extract inconspicuous spectral features of cyanobacterial blooms. To enhance the recognition accuracy of cyanobacterial blooms in complex scenes with noise such as reflections and shadows, an improved transformer model based on a feature-enhancement module and pixel-correction fusion was employed. The algorithm proposed in this paper was implemented in several rivers in China, achieving a detection accuracy of cyanobacterial blooms of more than 85%. The estimate of the proportion of the algae bloom contamination area and the severity of pollution were basically accurate. This paper can lay a foundation for ecological and environmental departments for the effective prevention and control of cyanobacterial blooms.