示例#1
0
    def load_dataset(self):
        if self.config.label == "detection":
            if not self.contain_dataset_files():
                self.meet_convention()
            Log.DEBUG_OUT = True
            Log.DEBUG("Loading pickle files")
            Log.DEBUG_OUT = False
            self.train_dataset = self.get_meta(
                os.path.join(self.config.dataset_dir, "train.pkl"))
            self.test_dataset = self.get_meta(
                os.path.join(self.config.dataset_dir, "test.pkl"))
            if os.path.exists(
                    os.path.join(self.config.dataset_dir, "validation.pkl")):
                self.validation_dataset = self.get_meta(
                    os.path.join(self.config.dataset_dir, "validation.pkl"))
            else:
                self.validation_dataset = None
                frameinfo = getframeinfo(currentframe())
                Log.WARNING("Unable to find validation dataset",
                            file_name=__name__,
                            line_number=frameinfo.lineno)
            self.train_dataset = self.fix_labeling_issue(self.train_dataset)
            self.test_dataset = self.fix_labeling_issue(self.test_dataset)
            self.validation_dataset = self.fix_labeling_issue(
                self.validation_dataset)
            Log.DEBUG_OUT = True
            Log.DEBUG("Loaded train, test and validation dataset")
            Log.DEBUG_OUT = False
            test_indexes = np.arange(len(self.test_dataset))
            np.random.shuffle(test_indexes)
            validation_indexes = np.arange(len(self.validation_dataset))
            np.random.shuffle(validation_indexes)

            self.test_dataset = self.test_dataset.iloc[
                test_indexes].reset_index(drop=True)
            self.validation_dataset = self.validation_dataset.iloc[
                validation_indexes].reset_index(drop=True)

            self.test_dataset = self.test_dataset[:1000]
            self.validation_dataset = self.validation_dataset[:100]
            Log.DEBUG_OUT = True
            Log.DEBUG("Loading test images")
            Log.DEBUG_OUT = False
            self.test_dataset_images = self.load_images(
                self.test_dataset).astype(np.float32) / 255
            Log.DEBUG_OUT = True
            Log.DEBUG("Loading validation images")
            Log.DEBUG_OUT = False
            self.validation_dataset_images = self.load_images(
                self.validation_dataset).astype(np.float32) / 255
            self.test_detection = self.test_dataset["is_face"].as_matrix()
            self.dataset_loaded = True
            Log.DEBUG_OUT = True
            Log.DEBUG("Loaded all dataset and images")
            Log.DEBUG_OUT = False

        else:
            raise NotImplementedError("Not implemented for labels:" +
                                      str(self.labels))
示例#2
0
 def __init__(self,config):
     self.config = config
     self.model = AllInOneModel(self.config.image_shape)
     if(config.model_weight!=None and os.path.exists(config.model_weight)):
         Log.DEBUG_OUT = True
         Log.DEBUG("Loading model weights from '"+config.model_weight+"'")
         try:
             self.model.model.load_weights(config.model_weight)
             Log.DEBUG("Loaded model weights")
         except:
             Log.DEBUG("Unable to load model weight from "+config.model_weight)
         Log.DEBUG_OUT =False
示例#3
0
    def load_dataset(self):
        if set(self.labels).issubset(["Age", "Gender"]):
            if not self.contain_dataset_files():
                self.meet_convention()
            Log.DEBUG_OUT = True
            Log.DEBUG("Loading pickle files")
            Log.DEBUG_OUT = False
            self.train_dataset = self.get_meta(
                os.path.join(self.config.dataset_dir, "train.pkl"))
            self.test_dataset = self.get_meta(
                os.path.join(self.config.dataset_dir, "test.pkl"))
            if os.path.exists(
                    os.path.join(self.config.dataset_dir, "validation.pkl")):
                self.validation_dataset = self.get_meta(
                    os.path.join(self.config.dataset_dir, "validation.pkl"))
            else:
                self.validation_dataset = None
                frameinfo = getframeinfo(currentframe())
                Log.WARINING_OUT = True
                Log.WARNING("Unable to find validation dataset",
                            file_name=__name__,
                            line_number=frameinfo.lineno)
                Log.WARINING_OUT = False
            self.train_dataset = self.fix_labeling_issue(self.train_dataset)
            self.test_dataset = self.fix_labeling_issue(self.test_dataset)
            self.validation_dataset = self.fix_labeling_issue(
                self.validation_dataset)
            Log.DEBUG_OUT = True
            Log.DEBUG("Loaded train, test and validation dataset")
            Log.DEBUG_OUT = False
            self.test_dataset = self.test_dataset[:5000]
            self.validation_dataset = self.validation_dataset[:100]
            Log.DEBUG_OUT = True
            Log.DEBUG("Loading test images")
            Log.DEBUG_OUT = False
            self.test_dataset_images = self.load_images(
                self.test_dataset).astype(np.float32) / 255
            Log.DEBUG_OUT = True
            Log.DEBUG("Loading validation images")
            Log.DEBUG_OUT = False
            self.validation_dataset_images = self.load_images(
                self.validation_dataset).astype(np.float32) / 255
            self.dataset_loaded = True
            Log.DEBUG_OUT = True
            Log.DEBUG("Loaded all dataset and images")
            Log.DEBUG_OUT = False

        else:
            raise NotImplementedError("Not implemented for labels:" +
                                      str(self.labels))
示例#4
0
 def __init__(self,config):
     self.config = config
     self.model = AllInOneModel(self.config.image_shape)
     self.model.save_model_to_json("/home/samuel/projects/All-In-One/AgeModel.json")
     if(config.model_weight!=None and os.path.exists(config.model_weight)):
         Log.DEBUG_OUT = True
         Log.DEBUG("Loading model weights from '" + config.model_weight +"'")
         try:
             self.model.model.load_weights(config.model_weight)
             #Freeze some layers in the network
             """
             for layer in model.layers[:5]:
                 layers.trainable = False
                 """
             Log.DEBUG("Loaded model weights")
         except:
             Log.DEBUG("Unable to load model weight from "+config.model_weight)
         Log.DEBUG_OUT =False