コード例 #1
0
ファイル: qt_inc_automatch.py プロジェクト: heroinlin/ibeis
    def next_query_slot(self):
        """
        callback used when all interactions are completed.
        Generates the next incremental query and then tries
        the automatic interactions
        """
        try:
            # Generate the query result
            item = six.next(self.inc_query_gen)
            (ibs, cm, qreq_, incinfo) = item
            # update incinfo
            self.cm      = cm
            self.qreq_     = qreq_
            self.incinfo = incinfo
            incinfo['count'] += 1
            automatch.run_until_name_decision_signal(ibs, cm, qreq_, incinfo=incinfo)
            #import plottool as pt
            #pt.present()

        except StopIteration:
            #TODO: close this figure
            # incinfo['fnum']
            print('NO MORE QUERIES. CLOSE DOWN WINDOWS AND DISPLAY DONE MESSAGE')
            import plottool as pt
            fig1 = pt.figure(fnum=511)
            fig2 = pt.figure(fnum=512)
            pt.close_figure(fig1)
            pt.close_figure(fig2)
            if 'finish_callback' in self.incinfo:
                self.incinfo['update_callback']()
            if 'finish_callback' in self.incinfo:
                self.incinfo['finish_callback']()
            pass
コード例 #2
0
ファイル: qt_inc_automatch.py プロジェクト: Erotemic/ibeis
    def test_incremental_query(
        self, ibs_gt, ibs, aid_list1, aid1_to_aid2, num_initial=0, interactive_after=None, back=None
    ):
        """
        Adds and queries new annotations one at a time with oracle guidance
        """
        incinfo = self.incinfo
        if back is not None:
            self.setup_back_callbacks(back, incinfo)
        self.ibs = ibs
        incinfo["nTotal"] = len(aid_list1)
        # incinfo['nTotal'] = len(aid_list1)
        # Create test query generator
        next_query_callback = self.incinfo["next_query_callback"]  # NOQA
        del self.incinfo["next_query_callback"]
        self.inc_query_gen = automatch.test_generate_incremental_queries(
            ibs_gt, ibs, aid_list1, aid1_to_aid2, num_initial, incinfo
        )
        # When in interactive mode it seems like the stack never gets out of hand
        # but if the oracle is allowed to make decisions and emit signals like
        # the user then we get into a maximum recursion limit.
        incinfo["interactive"] = False
        incinfo["use_oracle"] = True
        hack_run_name_decision = False
        with ut.Timer("test_incremental_query"):
            for item in self.inc_query_gen:
                (ibs, cm, qreq_, incinfo) = item
                # update incinfo
                self.cm = cm
                self.qreq_ = qreq_
                self.incinfo = incinfo
                incinfo["count"] += 1
                if incinfo.get("STOP", False):
                    print("STOP triggered")
                    interactive_after = incinfo["count"] - 1
                    incinfo["next_query_callback"] = next_query_callback
                    incinfo["use_oracle"] = False
                    incinfo["interactive"] = True
                    hack_run_name_decision = True
                    break
                automatch.run_until_name_decision_signal(ibs, cm, qreq_, incinfo=incinfo)
                # ut.embed()
                if interactive_after is not None and incinfo["count"] > interactive_after:
                    # stop the automated queries and start interaction
                    print("Interactive after triggered")
                    incinfo["interactive"] = True
                    break

        # BEGIN INTERACTIVE PART
        # (this does nothing if inc_query_gen is exhausted)
        # need to fix the incinfo dictionary
        incinfo["next_query_callback"] = next_query_callback
        incinfo["use_oracle"] = False
        # incinfo['metatup'] = None
        if hack_run_name_decision:
            # need to rn this so STOP can trigger user interaction
            automatch.run_until_name_decision_signal(ibs, cm, qreq_, incinfo=incinfo)
        else:
            incinfo["next_query_callback"]()
        return incinfo["interactive"]
コード例 #3
0
ファイル: qt_inc_automatch.py プロジェクト: whaozl/ibeis
    def next_query_slot(self):
        """
        callback used when all interactions are completed.
        Generates the next incremental query and then tries
        the automatic interactions
        """
        try:
            # Generate the query result
            item = six.next(self.inc_query_gen)
            (ibs, cm, qreq_, incinfo) = item
            # update incinfo
            self.cm = cm
            self.qreq_ = qreq_
            self.incinfo = incinfo
            incinfo['count'] += 1
            automatch.run_until_name_decision_signal(ibs,
                                                     cm,
                                                     qreq_,
                                                     incinfo=incinfo)
            #import plottool as pt
            #pt.present()

        except StopIteration:
            #TODO: close this figure
            # incinfo['fnum']
            print(
                'NO MORE QUERIES. CLOSE DOWN WINDOWS AND DISPLAY DONE MESSAGE')
            import plottool as pt
            fig1 = pt.figure(fnum=511)
            fig2 = pt.figure(fnum=512)
            pt.close_figure(fig1)
            pt.close_figure(fig2)
            if 'finish_callback' in self.incinfo:
                self.incinfo['update_callback']()
            if 'finish_callback' in self.incinfo:
                self.incinfo['finish_callback']()
            pass
コード例 #4
0
ファイル: qt_inc_automatch.py プロジェクト: whaozl/ibeis
    def test_incremental_query(self,
                               ibs_gt,
                               ibs,
                               aid_list1,
                               aid1_to_aid2,
                               num_initial=0,
                               interactive_after=None,
                               back=None):
        """
        Adds and queries new annotations one at a time with oracle guidance
        """
        incinfo = self.incinfo
        if back is not None:
            self.setup_back_callbacks(back, incinfo)
        self.ibs = ibs
        incinfo['nTotal'] = len(aid_list1)
        #incinfo['nTotal'] = len(aid_list1)
        # Create test query generator
        next_query_callback = self.incinfo['next_query_callback']  # NOQA
        del self.incinfo['next_query_callback']
        self.inc_query_gen = automatch.test_generate_incremental_queries(
            ibs_gt, ibs, aid_list1, aid1_to_aid2, num_initial, incinfo)
        # When in interactive mode it seems like the stack never gets out of hand
        # but if the oracle is allowed to make decisions and emit signals like
        # the user then we get into a maximum recursion limit.
        incinfo['interactive'] = False
        incinfo['use_oracle'] = True
        hack_run_name_decision = False
        with ut.Timer('test_incremental_query'):
            for item in self.inc_query_gen:
                (ibs, cm, qreq_, incinfo) = item
                # update incinfo
                self.cm = cm
                self.qreq_ = qreq_
                self.incinfo = incinfo
                incinfo['count'] += 1
                if incinfo.get('STOP', False):
                    print('STOP triggered')
                    interactive_after = incinfo['count'] - 1
                    incinfo['next_query_callback'] = next_query_callback
                    incinfo['use_oracle'] = False
                    incinfo['interactive'] = True
                    hack_run_name_decision = True
                    break
                automatch.run_until_name_decision_signal(ibs,
                                                         cm,
                                                         qreq_,
                                                         incinfo=incinfo)
                #ut.embed()
                if interactive_after is not None and incinfo[
                        'count'] > interactive_after:
                    # stop the automated queries and start interaction
                    print('Interactive after triggered')
                    incinfo['interactive'] = True
                    break

        # BEGIN INTERACTIVE PART
        # (this does nothing if inc_query_gen is exhausted)
        # need to fix the incinfo dictionary
        incinfo['next_query_callback'] = next_query_callback
        incinfo['use_oracle'] = False
        #incinfo['metatup'] = None
        if hack_run_name_decision:
            # need to rn this so STOP can trigger user interaction
            automatch.run_until_name_decision_signal(ibs,
                                                     cm,
                                                     qreq_,
                                                     incinfo=incinfo)
        else:
            incinfo['next_query_callback']()
        return incinfo['interactive']