Wildfire detection is an important societal, economic, and environmental task. Accurately and timely identifying wildfires is crucial for protecting natural resources and ensuring the safety of human life and property. Currently, deep learningbased algorithms for wildfire detection in the wild suffer from issues such as low detection accuracy, high false positive rates, and slow inference speeds. This paper proposes a wildfire detection method, WG-YOLOv5, based on the improved YOLOv5 architecture. The method introduces two-dimensional wavelet transform into the YOLOv5 network model to extract frequency domain information from wildfire images, and integrates it with spatial features extracted by the backbone network. Additionally, the YOLOv5 neck structure is optimized based on GSConv. Experimental results on a collected dataset of wildfire images demonstrate that WG-YOLOv5 outperforms YOLOv5 and other comparison methods in terms of higher accuracy, lower false positive rates, and improved real-time performance. This makes it well-suited for real-time wildfire detection tasks in wild environments.