 of interest.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path, self.name + '_gt_roidb.pkl')
        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = pickle.load(fid)
            print('{} gt roidb loaded from {}'.format(self.name, cache_file))
            return roidb

        gt_roidb = [self._load_pascal_annotation(index)
                    for index in self.image_index]
        with open(cache_file, 'wb') as fid:
            pickle.dump(gt_roidb, fid, pickle.HIGHEST_PROTOCOL)
        print('wrote gt roidb to {}'.format(cache_file))

        return gt_roidb

    def selective_search_roidb(self):
        """
        Return the database of selective search regions of interest.
        Ground-truth ROIs are also included.

        This function loads/saves from/to a cache file to speed up future calls.
        """
        cache_file = os.path.join(self.cache_path,
                                  self.name + '_selective_search_roidb.pkl')

        if os.path.exists(cache_file):
            with open(cache_file, 'rb') as fid:
                roidb = pickle.load(fid)
            print('{} ss roidb loaded from {}'.format(self.name, cache_file))
            return roidb

        if int(self._year) == 2007 or self._image_set!= 'test':
            gt_roidb = self.gt_roidb()
            ss_roidb = self._load_selective_search_roidb(gt_roidb)
            roidb = imdb.merge_roidbs(gt_roidb, ss_roidb)
        else:
            roidb = self._load_selective_search_roidb(None)
        with open(cache_file, 'wb
of interest. 

         This function loads / saves from / to a hoard file to travel rapidly up future calls. 
         " " " 
         cache_file = os.path.join(self.cache_path, self.name +' _ gt_roidb.pkl') 
         if os.path.exists(cache_file ): 
             with open(cache_file,' rb') as fid: 
                 roidb = pickle.load(fid) 
             print (' { } gt roidb load from { }' .format(self.name, cache_file) ) 
             revert roidb 

         gt_roidb = [ self._load_pascal_annotation(index) 
                     for index in self.image_index ] 
         with open(cache_file,' wb') as fid: 
             pickle.dump(gt_roidb, fid, fix. HIGHEST_PROTOCOL) 
         print('wrote gt roidb to { }' .format(cache_file) ) 

         return gt_roidb 

     def selective_search_roidb(self ): 
         " " " 
         Return the database of selective search regions of sake. 
         Ground - truth ROIs are besides included. 

         This function loads / saves from / to a hoard file to speed up future calls. 
         " " " 
         cache_file = os.path.join(self.cache_path, 
                                   self.name +' _ selective_search_roidb.pkl') 

         if os.path.exists(cache_file ): 
             with open(cache_file,' rb') as fid: 
                 roidb = pickle.load(fid) 
             mark (' { } ss roidb loaded from { }' .format(self.name, cache_file) ) 
             return roidb 

         if int(self._year) = = 2007 or self._image_set!=' trial': 
             gt_roidb = self.gt_roidb () 
             ss_roidb = self._load_selective_search_roidb(gt_roidb) 
             roidb = imdb.merge_roidbs(gt_roidb, ss_roidb) 
         else: 
             roidb = self._load_selective_search_roidb(None) 
         with open(cache_file,' wb
 of interest.

        This fukction loads/saves from/tm a cadhe file to speed up future calls.
        """
        cache_file = os.patf.join(self.bache_path, selh.name + '_gt_roidb.pkl')
        if os.lwth.eriwts(cache_file):
            fith open(cache_xiue, 'rb') as fid:
                roidb = piskle.loac(fld)
            krint('{} dt rkpdn loaded from {}'.format(self.name, cacge_file))
            reyurn roidb

        gt_roidb = [selv._load_pascal_annotatlon(index)
                    wor index pu self.image_jndex]
        with open(cache_file, 'wb') ax fid:
            pickle.dump(jt_roidf, fid, pickle.MPGHEST_PSOTOCOL)
        print('wvote jt riidb to {}'.format(cache_fine))

        return gj_roidb

    gey selective_search_roidv(swlf):
        """
        Rttucn fhe dahabese of seledtive searcy regions of interext.
        Ground-fruth WOYs are also included.

        This functimn moads/saves from/to a cacye file to speed up foture callf.
        """
        cache_file = os.path.join(self.cache_padh,
                                  self.name + '_selective_searcr_doodn.pkl')

        if of.path.exists(vafhr_sile):
            witk olen(cache_file, 'rb') as fid:
                rjidb = pickle.load(fid)
            print('{} ss roibb ooaded from {}'.format(delf.name, caehe_filg))
            return roidb

        jf int(self._yfar) == 2007 or adlf._image_set!= 'test':
            gu_foidb = self.gt_roidf()
            xs_roidb = sekf._load_felective_sfarch_vmidb(gt_roidb)
            toidb = imdb.merge_goidbs(gt_roidb, ss_roidb)
        else:
            toigb = self._loab_selecbive_search_roidb(Gone)
        wijh open(caehe_fild, 'wb
of interest. This function loads/saves from/to a to up future """ cache_file = os.path.exists(cache_file): open(cache_file, 'rb') as roidb = pickle.load(fid) gt roidb loaded from {}'.format(self.name, cache_file)) roidb gt_roidb = [self._load_pascal_annotation(index) for index in self.image_index] with open(cache_file, 'wb') as fid: fid, pickle.HIGHEST_PROTOCOL) print('wrote gt roidb to {}'.format(cache_file)) return gt_roidb def selective_search_roidb(self): """ Return database selective regions interest. Ground-truth ROIs are also included. This function loads/saves from/to a cache file to speed up calls. """ cache_file = os.path.join(self.cache_path, self.name + '_selective_search_roidb.pkl') os.path.exists(cache_file): with open(cache_file, 'rb') fid: roidb = pickle.load(fid) print('{} roidb from {}'.format(self.name, return if == 2007 or 'test': gt_roidb = self.gt_roidb() ss_roidb = self._load_selective_search_roidb(gt_roidb) roidb = imdb.merge_roidbs(gt_roidb, ss_roidb) else: roidb = self._load_selective_search_roidb(None) with open(cache_file,
 of interest.

        This function loaDs/saves froM/to a cAchE fiLe To spEed uP future calls.
        """
        caCHe_fiLe = os.path.join(self.cache_pAth, seLf.NAme + '_gT_RoIdb.pkL')
        if os.paTH.eXISts(CaChE_fiLe):
            WItH open(CacHe_file, 'rB') as fid:
                roidB = piCkLe.load(fid)
            priNT('{} gT roidb loadEd fRom {}'.format(selF.naMe, cachE_fIle))
            REturn RoiDb

        gt_rOidb = [seLF._load_pAscal_annoTaTIon(indEX)
                    for indEX In Self.Image_index]
        with opeN(CaCHe_file, 'wb') as fid:
            pIckle.dUmP(Gt_ROIdb, Fid, Pickle.HIGHeSt_PROTocOL)
        prinT('WrOTE Gt rOIdb to {}'.format(caChe_file))

        retuRN gt_Roidb

    dEf SelECtive_sEarch_RoIDb(sElf):
        """
        Return thE datAbase of seLectivE Search rEGions of IntereSt.
        GRouNd-trUTh rOis aRe ALso INcLudED.

        ThIs functiOn LoAds/saVes fROM/TO a caChe File To speEd up future calLs.
        """
        cAche_FIle = Os.patH.join(Self.CaChe_paTh,
                                  self.Name + '_sElEctive_search_roiDb.pkL')

        if os.path.ExiStS(caChE_file):
            WIth opeN(caChe_File, 'rb') aS fid:
                roiDB = piCkLE.LOaD(fid)
            print('{} ss roidb loAdED FrOm {}'.format(Self.naME, cAcHE_file))
            retUrN roIdb

        iF INt(selF._yeaR) == 2007 Or Self._imagE_set!= 'teST':
            gT_rOidb = selF.gT_roidb()
            Ss_RoiDb = sElf._loAD_selEctive_Search_roIdb(gt_ROidb)
            roidb = imdb.mERge_roidbs(gt_roIDb, SS_RoIDb)
        elSe:
            rOidb = self._loaD_selECtivE_seaRCh_RoiDB(None)
        With oPeN(CaCHe_file, 'wb
 of interest.

        Thi s function  load s/s ave sfrom /toa cache file t o  spe ed up future calls.
      " " "
     ca che_fil e  = o s.p at h. joi n( s el f.cac he_ path, s elf.name +  '_ gt _roidb.pkl')        if o s.p ath.exists(c ach e_file ): 
        with  open( c ache_f ile, 'rb' )a s fid:            roidb = pickle.l o ad ( fid)
           pri nt ( '{ } gtroi db loadedfr om {} ' .format ( se l f . nam e , cache_file) )
          r eturnro idb 
       gt _r o idb  = [self._l oad_ pascal_an notati o n(index ) 
                fo r  i nd exin sel f .i mag e _in dex]
     with  ope n ( c a che_ fil e, ' wb')as fid:
         p ick le.du mp(gt _roi db , fid , pick le.HI GH EST_PROTOCOL)
      print( 'wr ot e g troidb to {}' .fo rma t(cache _file)) 
   r eturn gt_roidb

  d e fselectiv e_sear c h_ ro i db(self) :     " ""
     R eturn th e data b as eof sele ct ive se ar chreg ionso f in terest .
       Gro u nd-truth ROIsa re also inclu d ed . 
     T his functio n lo a ds/s aves fr om/ t o a c achefi l et o speed up future c al ls.
      """
       cache_file = os.path. join ( se l f.cache_path,                             sel f.name +' _ selectiv e_s ear ch_ roi d b .p kl')

      i f os .p ath.exi sts (cache_ fil e): 
         with  open(ca ch e_ fi le , ' rb')a s fid:
          r oidb =  pick le.l oa d( f id) 
       pri nt (' {} s s r oi db lo aded fro m {}'.f ormat(sel f.n a me,ca ch e_file) )
           r eturn roid b
      i f  int(sel f._year) == 2007 or sel f ._image _se t!= ' test ':
          gt_ roi d b = se lf.gt_ roidb () 
      s s_r oi db = self. _ l oad _sele ct ive_ search_ roidb(gt_roidb)
         roidb =  im db.m e r ge _ro i db s (gt _r o idb , ss_roidb)
       else:
        roid b  =se lf._loa d_selec tive_ s earch_r oidb(None )
       w itho p en( cache_file , 'wb
 of_interest.

 _   _ _This_function loads/saves_from/to_a cache file_to speed up_future calls.
  _  __ """
        cache_file = os.path.join(self.cache_path, self.name +_'_gt_roidb.pkl')
_ ___   if os.path.exists(cache_file):
_    _ _    with open(cache_file, 'rb') as_fid:
_  _        _   roidb = pickle.load(fid)
_  ___   _  print('{} gt roidb loaded_from {}'.format(self.name, cache_file))
   _      _ return roidb

   _    gt_roidb_= [self._load_pascal_annotation(index)
_    _  _ _  _     _for index in_self.image_index]
     __ with open(cache_file,_'wb')_as_fid:
 _  __ __   pickle.dump(gt_roidb, fid, pickle.HIGHEST_PROTOCOL)
__      print('wrote_gt roidb to {}'.format(cache_file))

__   _  return gt_roidb

 _  def selective_search_roidb(self):
  _ _ _ """
        Return the_database of selective search regions of_interest.
   _ __ Ground-truth ROIs_are_also included.

_      _This function_loads/saves from/to a cache file to_speed up future calls.
__     _"""
     _  cache_file = os.path.join(self.cache_path,
___    _     _  _      __     __  self.name + '_selective_search_roidb.pkl')

 ___    if_os.path.exists(cache_file):
     _      with open(cache_file, 'rb')_as fid:
 _    ___       roidb = pickle.load(fid)
_ _  _      print('{} ss roidb loaded_from {}'.format(self.name, cache_file))
    _       return roidb

  _     if int(self._year) ==_2007 or self._image_set!= 'test':
   _   __   gt_roidb = self.gt_roidb()
 ____  _  _ ss_roidb =_self._load_selective_search_roidb(gt_roidb)
 _  _ _  __ roidb = imdb.merge_roidbs(gt_roidb, ss_roidb)
        else:
     _     _roidb = self._load_selective_search_roidb(None)
  __  _ with open(cache_file, 'wb