Weakly supervised classification of medical images