Beispiel #1
0
    def __init__(self, data_json, data_h5, dets_json):
        # parent loader instance
        Loader.__init__(self, data_json, data_h5)

        # prepare attributes
        self.att_to_ix = self.info['att_to_ix']
        self.ix_to_att = {ix: wd for wd, ix in self.att_to_ix.items()}
        self.num_atts = len(self.att_to_ix)
        self.att_to_cnt = self.info['att_to_cnt']

        # prepare dets
        self.dets = json.load(open(dets_json))
        self.Dets = {det['det_id']: det for det in self.dets}

        # add dets to image
        for image in self.images:
            image['det_ids'] = []
        for det in self.dets:
            image = self.Images[det['image_id']]
            image['det_ids'] += [det['det_id']]

        # img_iterators for each split
        self.split_ix = {}
        self.iterators = {}
        for image_id, image in self.Images.items():
            split = self.Refs[image['ref_ids'][0]]['split']
            if split not in self.split_ix:
                self.split_ix[split] = []
                self.iterators[split] = 0
            self.split_ix[split] += [image_id]
        for k, v in self.split_ix.items():
            print('assigned %d images to split %s' % (len(v), k))
Beispiel #2
0
    def __init__(self, data_json, data_h5, dets_json):
        # parent loader instance
        Loader.__init__(self, data_json, data_h5)

        # prepare attributes
        self.att_to_ix = self.info['att_to_ix']
        self.ix_to_att = {ix: wd for wd, ix in self.att_to_ix.items()}
        self.num_atts = len(self.att_to_ix)
        self.att_to_cnt = self.info['att_to_cnt']

        # prepare dets
        self.dets = json.load(open(dets_json))
        self.Dets = {det['det_id']: det for det in self.dets}

        # add dets to sentence
        for sent in self.sentences:
            sent['det_ids'] = []
        for det in self.dets:
            sent = self.Sentences[det['sent_id']]
            sent['det_ids'].append(det['det_id'])

        # img_iterators for each split
        self.split_ix = {}
        self.iterators = {}
        for sent_id in self.Sentences.keys():
            # we use its ref's split
            split = self.sentToRef[sent_id]['split']
            if split not in self.split_ix:
                self.split_ix[split] = []
                self.iterators[split] = 0
            self.split_ix[split].append(sent_id)
        for k, v in self.split_ix.items():
            print('assigned %d sentences to split %s' % (len(v), k))
Beispiel #3
0
    def __init__(self, data_json, data_h5):
        # parent loader instance
        Loader.__init__(self, data_json, data_h5)

        # prepare attributes
        #self.att_to_ix = self.info['att_to_ix']
        #self.ix_to_att = {ix: wd for wd, ix in self.att_to_ix.items()}
        #self.num_atts = len(self.att_to_ix)
        #self.att_to_cnt = self.info['att_to_cnt']

        # img_iterators for each split
        self.batch_size = 1
        self.split_ix = {}
        self.iterators = {}
        self.perm = {}
        for image_id, image in self.Images.items():
            # we use its ref's split (there is assumption that each image only has one split)
            split = self.Refs[image['ref_ids'][0]]['split']
            if split not in self.split_ix:
                self.split_ix[split] = []
                self.iterators[split] = 0
            self.split_ix[split] += [image_id]
        for k, v in self.split_ix.items():
            self.perm[k] = np.arange(len(v))  #np.random.permutation(len(v))
            print('assigned %d images to split %s' % (len(v), k))
 def __init__(self):
     if FreeAgentsLoader.FREE_AGENTS_CACHE:
         self.player_positions = FreeAgentsLoader.FREE_AGENTS_CACHE.player_positions
     else:
         self.batter_soup = self.get_free_agents_soup(0)
         self.pitcher_soup = self.get_free_agents_soup(1)
         self.player_positions = self.get_player_positions()
         FreeAgentsLoader.FREE_AGENTS_CACHE = self
     Loader.__init__(self)
Beispiel #5
0
    def __init__(self, data_json, data_h5, sub_obj_wds, similarity, opt):
        # parent loader instance
        Loader.__init__(self, data_json, sub_obj_wds, similarity, data_h5)
        # prepare attributes
        self.att_to_ix = self.info['att_to_ix']
        self.ix_to_att = {ix: wd for wd, ix in self.att_to_ix.items()}
        self.num_atts = len(self.att_to_ix)
        self.att_to_cnt = self.info['att_to_cnt']

        # img_iterators for each split
        self.split_ix = {}
        self.iterators = {}
        for image_id, image in self.Images.items():
            # we use its ref's split (there is assumption that each image only has one split)
            split = self.Refs[image['ref_ids'][0]]['split']
            if split not in self.split_ix:
                self.split_ix[split] = []
                self.iterators[split] = 0
            self.split_ix[split] += [image_id]
        for k, v in self.split_ix.items():
            print('assigned %d images to split %s' % (len(v), k))
Beispiel #6
0
 def __init__(self, team_id):
     self.team_id = team_id
     self.roster_soup = self.get_team_roster_soup()
     self.home_soup = self.get_team_home_soup()
     self.team = self.load_team()
     Loader.__init__(self)
Beispiel #7
0
 def __init__(self):
     if not DateLoader.CURRENT_DATE:
         DateLoader.CURRENT_DATE = self.get_current_date()    
     self.date = DateLoader.CURRENT_DATE
     Loader.__init__(self)