Today, indoor localization technology based on WiFi signals has become more and more popular and applicable. It not only facilitates people's lives but also creates enormous economic value. However, during the propagation of the WiFi signal, it is easily interfered by obstacles, and the signal fluctuation is significant, resulting in low accuracy of positioning. To overcome these problems, we reduce the influence of environmental factors firstly. Then the positioning accuracy is improved by using the SVM model to distinguish the NLOS or LOS environment and employing the capsule networks to derive the users' positions with the WiFi 2.4G and 5G signals. As we all know, the WiFi 2.4G signal has excellent penetrability and is less affected by obstacles, while the WiFi 5G signal has excellent stability and small fluctuations. Therefore, we use the advantages of these two kinds of signals to derive the optimal suggestion by the capsule neural network, which is the learning system with minimum data sets needed. The experimental results show that the positioning effect of the two signals simultaneously is better than the positioning effect of a single signal. We also compare with the traditional indoor positioning methods and use the simulation data to carry out the robustness test, and the positioning accuracy reached 0.99 m in the field environment finally.INDEX TERMS Indoor localization, NLOS and LOS channel propagation condition, WiFi 2.4G and WiFi 5G, SVM, capsule network.