从入门到放弃,tensorflow只需要几个小时hhh

遇到的坑

# -*- coding:utf-8 -*-
import matplotlib.pyplot as plt
import tensorflow as tf
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\sc1.jpg'

img_content02 = tf.io.gfile.GFile(filename,'rb').read()

print("数据类型",type(img_content02))
image_data=tf.image.decode_jpeg(img_content02,channels=3) #https://blog.csdn.net/qq_20084101/article/details/87440231
'''(
    contents,
    channels=0,1灰度-3RGB
    ratio=1,快速缩小倍数1,2,4,8
    fancy_upscaling=True,
    try_recover_truncated=False,
    acceptable_fraction=1,
    dct_method='',
    name=None)'''


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("类型:%s" % type(img_data))
print("origin picture:",image.shape)
print("类型:%s" % type(image))
print("数据类型",type(img_data))
plt.imshow(img_data, 'hsv')
img_out2t='D:\Pictures\cscscs\sc5256.jpg'

img_resized = tf.image.resize(img_data, size=[256, 256],method=tf.image.ResizeMethod.AREA)

print("resized picture:",img_resized.shape)
plt.show(img_resized,"gray")
img_wt=tf.image.encode_jpeg(img_resized)
# # resized_wt = tf.image.convert_image_dtype(img_resized, dtype=tf.uint8)
# # resized_wt  = np.array(resized_wt, dtype='float32')
# # print("leixxx",type(resized_wt))
# # img_write= tf.io.gfile.GFile(img_output,'wb').write(resized_wt)
# # resized = tf.image.convert_image_dtype(img_resized, dtype=tf.uint8)
# encoded_image = tf.image.encode_jpeg(resized_wt,dtype=tf.uint8)
# img = tf.image.encode_jpeg(encoded_image)

img_resized.tf.io.gfile.GFile('D:\Pictures\cscscs\sc35555.jpg')
# with tf.io.gfile.GFile('sc355.jpg', 'wb') as file:
#     file.write(img)

print("well done!!!")
#
# image_data_raw = tf.io.gfile.GFile('D:\Pictures\cscscs\sc1.jpg').read()
#
# image_data = tf.image.convert_image_dtype(image_data_raw, dtype=tf.float32)
#
# resized66 = tf.image.resize(image_data, [256, 256])
#
# plt.show(resized66,"gray")

动不动复制粘贴,嘿嘿嘿,机器没有坏,人不行了。。啊哈哈

program starting…
数据类型 <class ‘bytes’>
大小:(1024, 1024, 1)
类型:<class ‘numpy.ndarray’>
origin picture: (1024, 1024, 3)
类型:<class ‘numpy.ndarray’>
数据类型 <class ‘numpy.ndarray’>
。。。。。。。。。。。。。。。。
然后是一万字草嘛飞过,什么问题,什么玩意。
从入门到放弃,只需要几个小时摧毁即可。
一个个帕拉问题,找原因,不是干程序员的料,还在那大话西游瞎扯淡。
GG

都抵不过,时间流逝,太仓促太匆匆,短时间精通,不现实,入门容易,后面的路自己走,可就不一样啦。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

海宝7号

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值