One crucial component of ghost imaging (GI) is the encoded mask. Higher-quality reconstruction at lower sampling rates is still a major challenge for GI. Inspired by deep learning, max-projection method is proposed in the paper to reorder the Hadamard masks for its efficient and rapid reconstruction. The simulations demonstrated that max-projection ordering with only 20 face training images yielded excellent reconstruction outcomes. In noise-free simulations, at an ultralow sampling rate of 5%, the PSNR of the max-projection ordering was 1.1 dB higher than that of the cake-cutting ordering with the best performance in the reference group. In noisy simulations, at ultralow sampling rates, the retrieved images remained almost identical to their noise-free counterparts. Irrespective of the presence or absence of noise, the max-projection ordering guaranteed the highest fidelity of image reconstruction at ultralow sampling rates. The reconstruction time was reduced to mere milliseconds, thereby enabling swift visualization of dynamic phenomena. Accordingly, the max-projection ordering Hadamard matrix offers a promising solution for real-time GI due to its higher reconstruction quality, stronger noise immunity and millisecond reconstruction time.