1. A method performed by one or more computers, the method comprising: selecting a plurality of candidate videos from videos identified in a response to a search query derived from a label for an object category; selecting one or more initial frames from each of the candidate videos; detecting one or more initial images of objects in the object category in the initial frames; for each initial frame including an initial image of an object in the object category, tracking the object through surrounding frames to identify additional images of the object; selecting one or more images from the one or more initial images and one or more additional images as database images of objects belonging to the object category; generating statistics that identify frequencies of co-occurrences of objects in the candidate videos; and using the database images as training data for one or more learning models that predict a context of images or videos.