In this work, we perform the on-the-fly non-adiabatic dynamics simulation of a realistic molecular system coupled to the cavity. We extend the TSH method to simulate the quantum dynamics of coupled electronicphotonic-nuclear DOFs, and use the accurate nuclear gradient expressions developed in our previous work. The cavity loss is described with the Lindblad super operator, ensuring proper treatment of both population decay and decoherence among states. During the polariton dynamics simulations, the energies and gradients of the electronic states as well as the NAC between them are directly obtained from the ab initio one-the-fly electronic structure calculations at the level of CASSCF, while the molecular dipoles (including permanent and transition dipoles) and their derivatives are obtained from the machine learning model which is also trained with the data at the CASSCF level.