Hierarchical probabilistic graphical models for image recognition