In indoor positioning, Channel State Information (CSI) holds significant importance. CSI provides detailed channel characteristics, including amplitude and phase information, enabling the positioning system to estimate device locations more accurately. Compared to traditional RSSI methods, CSI offers higher positioning accuracy and better interference resistance. Additionally, it supports various advanced positioning algorithms, making it suitable for complex indoor environments and enabling real-time precise positioning. In this study, a localization method based on CSI phase and amplitude data is proposed with the aim of improving the accuracy and robustness of indoor localization. In the offline training phase, for each reference point, we construct a new dataset using pre-processed amplitude and phase data, which are transformed into image data for pre-training to extract features. Subsequently, a CNN-LSTM neural network with an integrated attention mechanism is trained to capture complex spatio-temporal relationships in the data. However, manual tuning of neural network hyperparameters has its limitations. Therefore, this paper introduces the Sparrow Search Algorithm (SSA)bio-inspired algorithm to optimize the combination of hyperparameters, aiming to obtain a more optimal model performance. During the online orientation phase, CSI data collected from the target device is processed using the same steps as in the offline phase to convert it into images. The trained model is then used to perform regression predictions on test points, enabling localization of the target position. To assess the effectiveness of our proposed approach, we ran tests in both open and complicated laboratory settings. Comparisons were made with several existing indoor localization solutions (such as PCNB, MIMO, LSTM, and FIFS), demonstrating that our approach exhibits significant advantages regarding localization accuracy and robustness.