def update_valid(reset=False): print('[interact] updating valid') if reset is True: state.reset() is_valid[:] = True if state.scale_min: is_valid[:] = np.bitwise_and(scale >= state.scale_min, is_valid) if state.scale_max: is_valid[:] = np.bitwise_and(scale <= state.scale_max, is_valid) print(state) print('%d valid keypoints' % sum(is_valid)) print('kpts scale ' + helpers.printable_mystats(scale[is_valid])) select_ith_keypoint(fx_ptr[0])
def leave_out(expt_func=None, split_test=False, **kwargs): ''' do with TF-IDF on the zebra data set. Let M be the total number of *animals* (not images and not chips) in an experimental data set. Do a series of leave-M-out (M >= 1) experiments on the TF-IDF scoring, where the "left out" M are M different zebras, so that there are no images of these zebras in the images used to form the vocabulary. The vocabulary is formed from the remaining N-M animals. Test how well TF-IDF recognition does with these M animals. Repeat for different subsets of M animals. import experiments as expt from experiments import * ''' # --- # Testing should have animals I have seen and animals I haven't seen. # Make sure num descriptors -per- word is about the same as Oxford # --- # Notes from Monday: # 1) Larger training set (see how animals in training do vs animals out of training) # 2) More detailed analysis of failures # 3) Aggregate scores across different pictures of the same animal if not 'expt_func' in vars() or expt_func is None: expt_func = run_experiment # Load tables hs = ld2.HotSpotter(ld2.DEFAULT, load_basic=True) # Grab names db_names_info = db_info.get_db_names_info(hs) nx2_cxs = db_names_info['nx2_cxs'] valid_nxs = db_names_info['valid_nxs'] multiton_nxs = db_names_info['multiton_nxs'] # How to generate samples/splits for names num_nsplits = 5 nsplit_size = (db_names_info['num_names_with_gt']//num_nsplits) # How to generate samples/splits for chips csplit_size = 1 # number of indexed chips per Jth experiment # Generate name splits kx2_name_split = far_appart_splits(multiton_nxs, nsplit_size, num_nsplits) result_map = {} kx = 0 # run K experiments all_cxs = np.hstack(nx2_cxs[list(valid_nxs)]) for kx in xrange(num_nsplits): print('***************') print('[expt] Leave M=%r names out iteration: %r/%r' % (nsplit_size, kx+1, num_nsplits)) print('***************') # Get name splits (test_nxs, train_nxs) = kx2_name_split[kx] # Lock in TRAIN sample train_cxs_list = nx2_cxs[list(train_nxs)] train_samp = np.hstack(train_cxs_list) # Generate chip splits test_cxs_list = nx2_cxs[list(test_nxs)] test_nChip = map(len, test_cxs_list) print('[expt] testnames #cxs stats: %r' % helpers.printable_mystats(test_nChip)) test_cx_splits = [] if not split_test: # Chucks version of the test (much simplier and better) indx_samp = all_cxs train_samp = train_samp test_samp = all_cxs hs.set_samples(test_samp, train_samp, indx_samp) m_label = '[LNO: %r/%r]' % (kx+1, num_nsplits) expt_locals = expt_func(hs, pprefix=m_label, **kwargs) #result_map[kx] = expt_locals['allres'] return locals()
def leave_out(expt_func=None, split_test=False, **kwargs): ''' do with TF-IDF on the zebra data set. Let M be the total number of *animals* (not images and not chips) in an experimental data set. Do a series of leave-M-out (M >= 1) experiments on the TF-IDF scoring, where the "left out" M are M different zebras, so that there are no images of these zebras in the images used to form the vocabulary. The vocabulary is formed from the remaining N-M animals. Test how well TF-IDF recognition does with these M animals. Repeat for different subsets of M animals. import experiments as expt from experiments import * ''' # --- # Testing should have animals I have seen and animals I haven't seen. # Make sure num descriptors -per- word is about the same as Oxford # --- # Notes from Monday: # 1) Larger training set (see how animals in training do vs animals out of training) # 2) More detailed analysis of failures # 3) Aggregate scores across different pictures of the same animal if not 'expt_func' in vars() or expt_func is None: expt_func = run_experiment # Load tables hs = ld2.HotSpotter(ld2.DEFAULT, load_basic=True) # Grab names db_names_info = db_info.get_db_names_info(hs) nx2_cxs = db_names_info['nx2_cxs'] valid_nxs = db_names_info['valid_nxs'] multiton_nxs = db_names_info['multiton_nxs'] # How to generate samples/splits for names num_nsplits = 5 nsplit_size = (db_names_info['num_names_with_gt'] // num_nsplits) # How to generate samples/splits for chips csplit_size = 1 # number of indexed chips per Jth experiment # Generate name splits kx2_name_split = far_appart_splits(multiton_nxs, nsplit_size, num_nsplits) result_map = {} kx = 0 # run K experiments all_cxs = np.hstack(nx2_cxs[list(valid_nxs)]) for kx in xrange(num_nsplits): print('***************') print('[expt] Leave M=%r names out iteration: %r/%r' % (nsplit_size, kx + 1, num_nsplits)) print('***************') # Get name splits (test_nxs, train_nxs) = kx2_name_split[kx] # Lock in TRAIN sample train_cxs_list = nx2_cxs[list(train_nxs)] train_samp = np.hstack(train_cxs_list) # Generate chip splits test_cxs_list = nx2_cxs[list(test_nxs)] test_nChip = map(len, test_cxs_list) print('[expt] testnames #cxs stats: %r' % helpers.printable_mystats(test_nChip)) test_cx_splits = [] if not split_test: # Chucks version of the test (much simplier and better) indx_samp = all_cxs train_samp = train_samp test_samp = all_cxs hs.set_samples(test_samp, train_samp, indx_samp) m_label = '[LNO: %r/%r]' % (kx + 1, num_nsplits) expt_locals = expt_func(hs, pprefix=m_label, **kwargs) #result_map[kx] = expt_locals['allres'] return locals()