deepModel.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:DeepPicker-python 作者: nejyeah 项目源码 文件源码
def __preprocess_particle(self, batch_data):
        # scale the image to the model input size
        #batch_data = tf.image.resize_images(batch_data, self.num_col, self.num_row)
        # get the scale tensor shape
        batch_data_shape = batch_data.get_shape().as_list()
        # uppack the tensor into sub-tensor
        batch_data_list = tf.unpack(batch_data)
        for i in xrange(batch_data_shape[0]):
            # Pass image tensor object to a PIL image
            image = Image.fromarray(batch_data_list[i].eval())
            # Use PIL or other library of the sort to rotate
            random_degree = random.randint(0, 359)
            rotated = Image.Image.rotate(image, random_degree)
            # Convert rotated image back to tensor
            rotated_tensor = tf.convert_to_tensor(np.array(rotated))
            #slice_image = tf.slice(batch_data, [i, 0, 0, 0], [1, -1, -1, -1])
            #slice_image_reshape = tf.reshape(slice_image, [batch_data_shape[1], batch_data_shape[2], batch_data_shape[3]])
            #distorted_image = tf.image.random_flip_up_down(batch_data_list[i], seed = 1234)
            #distorted_image = tf.image.random_flip_left_right(distorted_image, seed = 1234)
            #distorted_image = tf.image.random_brightness(distorted_image, max_delta=63)
            #distorted_image = tf.image.random_contrast(distorted_image, lower=0.2, upper=1.8)
            # Subtract off the mean and divide by the variance of the pixels.
            distorted_image = tf.image.per_image_whitening(rotated_tensor)
            batch_data_list[i] = distorted_image
        # pack the list of tensor into one tensor
        batch_data = tf.pack(batch_data_list)
        return batch_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号