# -*- coding: utf-8 -*-
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"#忽略警告默认1显示全部信息
os.environ["CUDA_VISIBLE_DEVICES"]="-1"#禁用GPU,默认1/0使用
tf.compat.v1.disable_eager_execution()
# # 建议使用GPU最小显存使用量
# config=tf.compat.v1.ConfigProto()
# config.gpu_options.allow_growth = True
# sess=tf.compat.v1.Session(config=config)
# with tf.io.gfile.GFile(filename,'rb') as f:
# image_data = f.read()
# with tf.Session() as sess:
# image_data = tf.image.decode_jpeg(image_data)
print("program starting......")
filename = 'D:\Pictures\cscscs\sc15.jpg'
img_content02 = tf.io.gfile.GFile(filename,'rb').read()
image_data=tf.image.decode_jpeg(img_content02,channels=3) #https://blog.csdn.net/qq_20084101/article/details/87440231
sess=tf.compat.v1.Session()
image = sess.run(image_data)
h,w,c=image.shape
img_data = sess.run(tf.image.rgb_to_grayscale(image_data)) # 灰度化
print('大小:{}'.format(img_data.shape))
print("类