예제 #1
0
파일: base.py 프로젝트: qbilius/conv-exp
    def predict(self):
        try:
            m = models.get_model(self.model_name)
        except:
            msg("%s is not available for generating responses" % self.model_name)
            raise Exception

            # resps = self.load('resps')
            # if resps is None:
            #     raise ValueError('no response file found for %s' %
            #                     self.model_name)
        else:
            m.load_image = load_image
            preds = m.predict(self.ims, topn=5)
            self.save(preds, "preds")
        return preds
예제 #2
0
    def predict(self):
        try:
            m = models.get_model(self.model_name)
        except:
            msg('%s is not available for generating responses' %
                self.model_name)
            raise Exception

            # resps = self.load('resps')
            # if resps is None:
            #     raise ValueError('no response file found for %s' %
            #                     self.model_name)
        else:
            m.load_image = load_image
            preds = m.predict(self.ims, topn=5)
            self.save(preds, 'preds')
        return preds
예제 #3
0
파일: base.py 프로젝트: qbilius/conv-exp
    def classify(self):
        try:
            m = models.get_model(self.model_name)
        except:
            msg("%s is not available for generating responses" % self.model_name)
            resps = self.load("resps")
            if resps is None:
                raise ValueError("no response file found for %s" % self.model_name)
        else:
            m.load_image = load_image
            output = m.run(self.ims, layers=self.layers, return_dict=True)
            resps = OrderedDict()
            for layer, out in output.items():
                resps[layer] = out.reshape((out.shape[0], -1))

            if self.model_name in ["hmax_hmin", "hmax_pnas"]:
                self.save(resps, "resps")
        return resps
예제 #4
0
    def classify(self):
        try:
            m = models.get_model(self.model_name)
        except:
            msg('%s is not available for generating responses' %
                self.model_name)
            resps = self.load('resps')
            if resps is None:
                raise ValueError('no response file found for %s' %
                                 self.model_name)
        else:
            m.load_image = load_image
            output = m.run(self.ims, layers=self.layers, return_dict=True)
            resps = OrderedDict()
            for layer, out in output.items():
                resps[layer] = out.reshape((out.shape[0], -1))

            if self.model_name in ['hmax_hmin', 'hmax_pnas']:
                self.save(resps, 'resps')
        return resps
예제 #5
0
파일: run.py 프로젝트: mageed/conv-exp
 def predict(self):
     _, sel = self.filter_synset_ids()
     try:
         m = models.get_model(self.model_name)
     except:
         base.msg('%s is not available for generating responses' %self.model_name)
         raise Exception
     else:
         m.load_image = base.load_image
         preds = m.predict(self.ims, topn=1000)
         # limit to top 5 guesses that are in Snodgrass
         top5 = []
         for pred in preds:
             tmp = []
             for p in pred:
                 if p['synset'] in sel: tmp.append(p)
                 if len(tmp) == 5:
                     top5.append(tmp)
                     break
         self.save(top5, 'preds')
     return preds
예제 #6
0
 def predict(self):
     _, sel = self.filter_synset_ids()
     try:
         m = models.get_model(self.model_name)
     except:
         base.msg('%s is not available for generating responses' %
                  self.model_name)
         raise Exception
     else:
         m.load_image = base.load_image
         preds = m.predict(self.ims, topn=1000)
         # limit to top 5 guesses that are in Snodgrass
         top5 = []
         for pred in preds:
             tmp = []
             for p in pred:
                 if p['synset'] in sel: tmp.append(p)
                 if len(tmp) == 5:
                     top5.append(tmp)
                     break
         self.save(top5, 'preds')
     return preds