We perform the TSH simulations to investigate the photoisomerization reaction inside the cavity. The photoinduced non-adiabatic dynamics process of azomethane has been widely investigated. Since azomethane is the simplest azoalkane and has rich dynamics (i.e., photoisomerization and photodissociation), it is also often used as a model molecular system to test the performance of the non-adiabatic dynamics methods or the electrical structure methods in the non-adiabatic dynamics simulations. Thus, we adopt azomethane in this work to see how the light-matter coupling can affect the photoinduced reaction of the molecular system. Our polariton dynamics results also demonstrate the isomerization reaction of azomethane can be effectively tuned by coupling to an optical cavity. The machine learning model developed in this work illustrates its potential applications in the polariton dynamics simulations, where we can in principle construct the derivatives of dipoles for molecules with any electronic structure method if that method can provide the dipoles. This development paves the way toward simulating complex molecular systems inside an optical cavity.