コード例 #1
0
 def __init__(self, feats=Feats()):
     self.feats = feats
     self.le = preprocessing.LabelEncoder()
     self.cls = struct_perceptron.StructuredPerceptron(self,
                                                       max_iter=25,
                                                       average=True,
                                                       verbose=True)
コード例 #2
0
ファイル: matching.py プロジェクト: speed-of-light/pyslider
 def single_match(self, fid, sid, thres=0.9):
     """
     BruteForce-L1 BruteForce-Hamming BruteForce-Hamming(2) FlannBased
     """
     mod = dict(kp_algo=self.algorithm['keypoint'],
                des_algo=self.algorithm['descriptor'])
     mtype = self.algorithm['matching']
     fimg, simg = self.__image_pair(fid, sid)
     ff = Feats(self.root, self.name)
     sif = ff.feats_set([simg], mod=mod)[0]
     vif = ff.feats_set([fimg], mod=mod)[0]
     mat = cv2.DescriptorMatcher_create(mtype)
     mra = mat.knnMatch(sif['des'], vif['des'], k=2)
     mra = self._filter_matches(mra, thres)
     col = ['qix', 'tix', 'iix', 'dt']
     if len(mra) is 0:
         res = pd.DataFrame(columns=col)
     else:
         mra = self._pickle_matches(mra)
         res = pd.DataFrame(mra, columns=col)
     return dict(matches=res, sif=sif, vif=vif, qsize=simg['img'].shape)
コード例 #3
0
ファイル: matching.py プロジェクト: speed-of-light/pyslider
 def set_match(self, fids=[], ransac=0, thres=.9):
     """
     ransac:
         0, no ransac
         1, use ransac
     """
     mod = dict(kp_algo=self.algorithm['keypoint'],
                des_algo=self.algorithm['descriptor'])
     mtype = self.algorithm['matching']
     sr = self.root
     sn = self.name
     ff = Feats(sr, sn)
     isl = ff.o_slides(gray=True, resize=True)
     vv = Video(sr, sn)
     ivl = vv.get_frames(ids=fids, gray=True)
     sfs = ff.feats_set(isl, mod=mod)
     vfs = ff.feats_set(ivl, mod=mod)
     res = []
     for qf in vfs:
         frs = []
         for sf in sfs:
             _info = self._match_info(sf['idx'], qf['idx'], mod['kp_algo'],
                                      mod['des_algo'], mtype, thres)
             self.elog.info(_info)
             with ExpTimer(verbose=0) as ts:
                 mr = self._match_desc(sf['des'], qf['des'], mtype, thres)
                 if ransac is True and len(mr) > 0:
                     ra = Ransac()
                     h**o, mask = ra.compute(mr, sf['kps'], qf['kps'])
                     mr = mr[mask[mr.index] == 1]
             mt = ts.msecs + sf['ts'] + qf['ts']
             dr = dict(sid=sf['idx'], fid=qf['idx'], ts=mt, mr=mr)
             frs.append(dr)
         ds = self._dist_stat(frs)
         vr = self._voting(ds)
         res.append(dict(feats=frs, vr=vr))
     return res, sfs, vfs
コード例 #4
0
    def __init__(self, epochs=10, batch_size=8, feats=Feats()):
        self.feats = feats
        from sklearn import preprocessing
        self.le = preprocessing.LabelEncoder()
        self.cls = struct_perceptron.StructuredPerceptron(
            self,
            max_iter=epochs,
            batch_size=batch_size,
            average=True,
            verbose=True)
        # max_len is set to be longer than any sentences in trainset
        # if you want to use smaller number, you may need to need to spend some time debugging
        self.max_len = 40

        self.batch_size = batch_size
コード例 #5
0
 def __init__(self, feats=Feats()):
     self.feats = feats
     from sklearn.linear_model import LogisticRegression
     self.cls = LogisticRegression()
     from sklearn import preprocessing
     self.le = preprocessing.LabelEncoder()
コード例 #6
0
    def __init__(self, feats=Feats()):
        self.feats = feats

        self.cls = LogisticRegression()

        self.le = preprocessing.LabelEncoder()
コード例 #7
0
 def __init__(self, feats = Feats()):
     self.feats = feats
     self.le = preprocessing.LabelEncoder()
     self.cls = struct_perceptron.StructuredPerceptron(self, max_iter=24, average=True, verbose=True)#, decay_t0=-0.05, decay_exponent=1)