G-valued flat deformations and local models