PSDs are layered, and a correctly organized PSD file with some layer naming conventions should contain enough information to generate layout code without needing to use machine learning.
Altia has a product (PhotoProto) that can import PSDs to their tool which can then generate C code for embedded systems.