第3章 数形结合——图像处理基础知识
1:Windows 下ipython(jupyter notebook)中无法使用!ls的问题
l_samp = !ls ./dataset/*vehicles/*/*
查看其输出结果就会显示:“ls” 不是内部或外部命令。
遂改成:
l_samp = %ls “./dataset/*vehicles/*/*”
果不其然,他是不认这个通配符 * 的。
搜索一堆,找到glob模块。
于是:
l_samp = glob.glob(r"./dataset/*vehicles/*/*")
由于输出略有不同,在后面的代码也做相应更改
pd_SampClass = pd.DataFrame({
"Sample" : l_samp,
"Class" : list(map(lambda x: M_ClassDict[x], list(map(lambda x: x.split("\\")[1], l_samp))))
})[['Sample', 'Class']]
成功解决
2:module ‘tensorflow’ has no attribute ‘placeholder’
import tensorflow as tf
mat_input = tf.placeholder(tf.float32)
使用tensorflow 中placeholder函数时会说模块中无此函数。
是因为此时我使用的是tensorflow2 版本
而书中使用的是1.X版本。
作者也在一开始就给我们提了醒。
为了解决这个问题我们需要使用以下代码:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
mat_input = tf.placeholder(tf.float32)
问题解决
3:优达学城行车记录仪数据集
书中给的两个数据集的链接无法下载或下载速度过慢。
给出我已经下载的两个数据集,并按照文中记录的路径格式放入在
dataset文件夹中。解压至项目所在地址即可。
链接:https://pan.baidu.com/s/11UPjJSXr8QLTv1svweTHiQ
提取码:3tsf