Learning Graph Weighted Models on Pictures