人工智能——机器视觉及图像识别(Bilibili视频学习)
Day01——tensorflow-hello代码书写
视频代码:
tensorflow——
import tensorflow as tf
hello = tf.constant('hello tf!')
sess = tf.Session()
print(sess.run(hello))
问题:
1、目前tensorflow版本为v2,原视频版本为v1,因此需将第一行代码改为import tensorflow.compat.v1 as tf;
2、若改换版本后其他不变会出现The Session graph is empty. Add operations to the graph before calling run(),需在import后加入tf.disable_eager_execution(),原理未知
更新——定义init:init = tf.global_variables_initializer()
sess.run(init)
print(sess.run(hello))
即可
opencv——
import cv2
img = cv2.imread('image0.jpg',1)#图片的读取 1 彩色,0 灰度
cv2.imshow('image',img)#窗体的名称|当前图片的内容
cv2.waitKey(0)#暂停
Look at the falling leaves,it fades away quietly.Just like the life,but not codes.

浙公网安备 33010602011771号