def predict_and_show(self, img_num, complete_df, width, height): assert width * height == len(complete_df) logger.info("Predicting neural network results on image %i ..." % img_num) img_out_path = os.path.join(self.out_path, "prediction_image%i.jpg" % img_num) array = np.zeros((width, height, 3), 'uint8') complete_df = self._create_features(complete_df) complete_df = complete_df[self.columns] prediction = neural_networks.predict(self.theta, complete_df) prediction = prediction.reshape((width, height)) array[..., 0] = 255*(1-prediction) array[..., 1] = 255*prediction img_num = Image.fromarray(array) img_num.save(img_out_path)
def predict_and_show(self, img_num, complete_df, width, height): assert width * height == len(complete_df) logger.info("Predicting neural network results on image %i ..." % img_num) img_out_path = os.path.join(self.out_path, "prediction_image%i.jpg" % img_num) array = np.zeros((width, height, 3), 'uint8') complete_df = self._create_features(complete_df) complete_df = complete_df[self.columns] prediction = neural_networks.predict(self.theta, complete_df) prediction = prediction.reshape((width, height)) array[..., 0] = 255 * (1 - prediction) array[..., 1] = 255 * prediction img_num = Image.fromarray(array) img_num.save(img_out_path)
def predict(self, imgs): df = filter_df(self.df, img_nums=imgs, columns=self.columns) return neural_networks.predict(self.theta, df)