1. A computer-implemented method for detecting objects in an input image, comprising: receiving a set of training images and associated annotations, the annotations labeling categories and locations of objects which appear in the images; determining one or more subcategories for each of the categories of objects, wherein the number of subcategories for an object category is inferred from the training images and the associated annotations via a clustering technique in which the number of subcategories is driven by appearance variations within the object category, and wherein the clustering technique does not require the number of subcategories for the object category to be specified as an input to the clustering technique; training classifiers for detecting the subcategories; training a respective structured model for each of the categories of objects, the respective structured model accounting for relationships between detected subcategories; and detecting the objects in the input image using the trained subcategory classifiers and structured models.