How do you mathematically reverse a perspective transformation?
Blender has build in camera tracker. Load the images as a video sequence and mark trackers in each by hand (spots and freckles work well). Then solve the images to get your trackers perfectly positioned in 3d space. Now you know exactly where things should be in 3d space.

You can deform your current geometry to conform to the trackers with big sculpt brushes.

It's hard to say if there is mathematical solution, because it is unclear how you modeled the mesh. You had multiple reference sources and you introduced error from each view, each error in different direction. Manual correction is the fastest way for now and using actual photogrammetry is the way for future, you don't need to waste time with this script (unless you want to develop your own photogrammetry tool:).