ax0 = plt.subplot(L, 2, 1 + 2 * (i - offset)) else: ax = plt.subplot(L, 2, 1 + 2 * (i - offset), sharex=ax0) #print i #print dct #print '#neg', len(dct['neg_llhs']) #print '#pos', len(dct['pos_llhs']) #print 'unique negs', len(np.unique(dct['neg_llhs'])) #print '------------' #import pdb; pdb.set_trace() if adjusted: neg_R = dct['neg_llhs'].copy().reshape((-1, 1)) pos_R = dct['pos_llhs'].copy().reshape((-1, 1)) nonparametric_rescore(neg_R, dct['start'], dct['step'], dct['points']) nonparametric_rescore(pos_R, dct['start'], dct['step'], dct['points']) #neg_R = (neg_R - dct['neg_llhs'].mean()) / dct['neg_llhs'].std() #pos_R = (pos_R - dct['neg_llhs'].mean()) / dct['neg_llhs'].std() #neg_R = (neg_R - dct['pos_llhs'].mean()) / dct['pos_llhs'].std() #pos_R = (pos_R - dct['pos_llhs'].mean()) / dct['pos_llhs'].std() plt.hist(neg_R, alpha=0.5, label='neg', bins=bins, normed=True) plt.hist(pos_R, alpha=0.5, label='pos', bins=bins, normed=True) else: plt.hist(dct['neg_llhs'], alpha=0.5, label='neg', bins=bins, normed=True) plt.hist(dct['pos_llhs'],
#R = float((X * weights).sum()) #Rst = (R - detector.fixed_train_mean[k]) / detector.fixed_train_std[k] if detector.indices is not None: R = multifeature_correlate2d_with_indices(X, weights.astype(np.float64), detector.indices[k][m])[0, 0] else: R = multifeature_correlate2d(X, weights.astype(np.float64))[0, 0] from gv.fast import nonparametric_rescore Rsts = np.zeros(detector.num_bkg_mixtures) for m in xrange(detector.num_bkg_mixtures): Rarray = R * np.ones((1, 1)) info = detector.standardization_info[k][m] nonparametric_rescore(Rarray, info['start'], info['step'], info['points']) #Rst = R Rsts[m] = Rarray[0, 0] Rst = Rsts[det['bkgcomp']] # Replace bounding boxes with this single one #fileobj.boxes[:] = [bbobj] fn = 'det-{0}.png {1}'.format(i, bbobj.img_id) #print '{batsu} {fn}: {standardized:.2f} {raw:.2f} ({mixcomp}, {bkgcomp})'.format(fn=fn, standardized=Rst, raw=det['confidence'], batsu=['X', '.'][det['correct']], mixcomp=det['mixcomp'], bkgcomp=det['bkgcomp']) print '{batsu} {fn}: {standardized:.2f} {raw:.2f} ({mixcomp}, {bkgcomp}) dist={dist}'.format( fn=fn, standardized=Rst, raw=det['confidence'], batsu=['X', '.'][det['correct']],
ax0 = plt.subplot(L, 2, 1 + 2*(i-offset)) else: ax = plt.subplot(L, 2, 1 + 2*(i-offset), sharex=ax0) #print i #print dct #print '#neg', len(dct['neg_llhs']) #print '#pos', len(dct['pos_llhs']) #print 'unique negs', len(np.unique(dct['neg_llhs'])) #print '------------' #import pdb; pdb.set_trace() if adjusted: neg_R = dct['neg_llhs'].copy().reshape((-1, 1)) pos_R = dct['pos_llhs'].copy().reshape((-1, 1)) nonparametric_rescore(neg_R, dct['start'], dct['step'], dct['points']) nonparametric_rescore(pos_R, dct['start'], dct['step'], dct['points']) #neg_R = (neg_R - dct['neg_llhs'].mean()) / dct['neg_llhs'].std() #pos_R = (pos_R - dct['neg_llhs'].mean()) / dct['neg_llhs'].std() #neg_R = (neg_R - dct['pos_llhs'].mean()) / dct['pos_llhs'].std() #pos_R = (pos_R - dct['pos_llhs'].mean()) / dct['pos_llhs'].std() plt.hist(neg_R, alpha=0.5, label='neg', bins=bins, normed=True) plt.hist(pos_R, alpha=0.5, label='pos', bins=bins, normed=True) else: plt.hist(dct['neg_llhs'], alpha=0.5, label='neg', bins=bins, normed=True) plt.hist(dct['pos_llhs'], alpha=0.5, label='pos', bins=bins, normed=True) neg_N = len(dct['neg_llhs']) pos_N = len(dct['pos_llhs'])
from gv.fast import multifeature_correlate2d_with_indices, multifeature_correlate2d #R = float((X * weights).sum()) #Rst = (R - detector.fixed_train_mean[k]) / detector.fixed_train_std[k] if detector.indices is not None: R = multifeature_correlate2d_with_indices(X, weights.astype(np.float64), detector.indices[k][m])[0,0] else: R = multifeature_correlate2d(X, weights.astype(np.float64))[0,0] from gv.fast import nonparametric_rescore Rsts = np.zeros(detector.num_bkg_mixtures) for m in xrange(detector.num_bkg_mixtures): Rarray = R * np.ones((1, 1)) info = detector.standardization_info[k][m] nonparametric_rescore(Rarray, info['start'], info['step'], info['points']) #Rst = R Rsts[m] = Rarray[0,0] Rst = Rsts[det['bkgcomp']] # Replace bounding boxes with this single one #fileobj.boxes[:] = [bbobj] fn = 'det-{0}.png {1}'.format(i, bbobj.img_id) #print '{batsu} {fn}: {standardized:.2f} {raw:.2f} ({mixcomp}, {bkgcomp})'.format(fn=fn, standardized=Rst, raw=det['confidence'], batsu=['X', '.'][det['correct']], mixcomp=det['mixcomp'], bkgcomp=det['bkgcomp']) print '{batsu} {fn}: {standardized:.2f} {raw:.2f} ({mixcomp}, {bkgcomp}) dist={dist}'.format( fn=fn, standardized=Rst, raw=det['confidence'], batsu=['X', '.'][det['correct']], mixcomp=det['mixcomp'], bkgcomp=det['bkgcomp'], dist=dists, ) #import IPython #IPython.embed()