def test_cnn_val(): dataset_params = { 'batch_size': -1, 'path': 'resources/train_data/chars', 'labels_path': 'resources/train_data/chars_list_val.pickle', 'thread_num': 3, 'gray': True } val_dataset_reader = DataSet(dataset_params) model = Lenet() model.compile() image, label = val_dataset_reader.batch() print("Total dataset number: ", val_dataset_reader.record_number) pred, acc = eval_model([model.pred_labels, model.accuracy], { model.x: image, model.y: label, model.keep_prob: 1 }, model_dir="train/model/chars/models/") print("Label: {}({}), Pred: {}({})".format(label[0], index2str[label[0]], pred[0], index2str[pred[0]])) # imshow("tmp", image[0]) print("Accuary: {:.2f}%".format(acc * 100))
def test_judge_val(): dataset_params = { 'batch_size': -1, 'path': 'resources/train_data/whether_car', 'labels_path': 'resources/train_data/whether_list_val.pickle', 'thread_num': 3, 'gray': False } val_dataset_reader = DataSet(dataset_params) model = Judgenet() model.compile() image, label = val_dataset_reader.batch() print("Total dataset number: ", val_dataset_reader.record_number) pred, acc = eval_model([model.pred_labels, model.accuracy], { model.x: image, model.y: label, model.keep_prob: 1 }, model_dir="train/model/whether_car/models/") print("Label: {}, Pred: {}".format(label[0], pred[0])) print("Accuary: {:.2f}%".format(acc * 100))
def identify(self, images): tmp = images / 255 * 2 - 1 pred = eval_model(self.model.pred_labels, { self.model.x: tmp, self.model.keep_prob: 1 }, model_dir="train/model/chars/models/", eval_sess=self.eval_sess) return pred
def judge(self, images): judgeRes = [] tmp = images / 255 * 2 - 1 pred = eval_model(self.model.pred_labels, { self.model.x: tmp, self.model.keep_prob: 1 }, model_dir="train/model/whether_car/models/", eval_sess=self.eval_sess) for i, tmp in enumerate(pred): if tmp == 1: judgeRes.append(images[i]) return judgeRes