使用深度学习进行目标检测经历总结

当你有决心学一样东西并且一点一滴地去学习去搜索才能有机会找到出路!!!

图像标注工具Labelme和LabelImg

 

实战参考链接:https://blog.csdn.net/Houchaoqun_XMU/article/details/78529069

YOLOv3 实练(以VOC2007、2012数据集为例)

学习链接:(评论里面的链接)https://bbs.csdn.net/wap/topics/392368317

github网址:https://github.com/yizt/cv-papers

算法网址: http://gluon-cv.mxnet.io/build/examples_detection/index.html

 

一、下载并使用labelimg标注工具

1、安装anaconda3

2、下载labelimg

下载地址:https://github.com/tzutalin/labelImg

3、进入到下载的labellmg文件夹下安装pyqt

conda install pyqt=5                          //安装之后执行以下命令

pyrcc5 -o resources.py resources.qrc
python labelImg.py                            //此时打开了labelImg窗口

4、使用labelImg

详见使用参考链接:https://cloud.tencent.com/developer/news/325876

github参考链接:https://github.com/tzutalin/labelImg

二、voc数据集详解

PASCAL VOC数据集分析

二、

 
  1. TypeError: softmax() got an unexpected keyword argument 'axis'

就网上说是keras 2.1.6的softmax没有axis这个参数了,于是,我回退了keras版本:

pip install keras==2.1

1.控制使用哪块GPU
~/ CUDA_VISIBLE_DEVICES=0  python your.py    # 使用GPU0
~/ CUDA_VISIBLE_DEVICES=0,1 python your.py   # 使用GPU0,1
或者在 程序开头
os.environ['CUDA_VISIBLE_DEVICES'] = '0'      # 使用 GPU 0
os.environ['CUDA_VISIBLE_DEVICES'] = '0,1'    # 使用 GPU 0,1
三、阅读深度学习代码

1.cv2.rectangle(img, (x, y), (x+w. y+h), (0, 0, 255), 2) 用于在图像上画出矩阵

参数说明:img表示图片,(x, y)表示矩阵左上角的位置,(x+w, y+h)表示矩阵右下角的位置, (0, 0, 255)表示颜色,2表示线条

 refer : https://www.cnblogs.com/my-love-is-python/p/10403203.html

链接1:如何用Tensorflow训练模型成.pb文件和和如何加载已经训练好的模型文件

四、

实战一:学习线性方程的参数

import tensorflow as tf
import numpy as np

# create data
x_data = np.random.rand(100).astype(np.float32)
y_data = x_data*0.1 + 0.3



Weights = tf.Variable(tf.random_uniform([1],-1.0,1.0))
biases = tf.Variable(tf.zeros([1]))

y = Weights*x_data + biases
loss = tf.reduce_mean(tf.square(y-y_data))
optimizer = tf.train.GradientDescentOptimizer(0.5)
train = optimizer.minimize(loss)

init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)

for step in range(201):
    sess.run(train)
    if step %20 == 0: print(step ,sess.run(Weights),sess.run(biases))

实战二:tf.Session()的两种打开方式

import tensorflow as tf

# create two matrixes

matrix1 = tf.constant([[3,3]])
matrix2 = tf.constant([[2],
                       [2]])
product = tf.matmul(matrix1,matrix2)

# method 1
sess = tf.Session()
result = sess.run(product)
print(result)
sess.close()
# [[12]]

# method 2
with tf.Session() as sess:
    result2 = sess.run(product)
    print(result2)
# [[12]]

实战三、Variable的用法
 

import tensorflow as tf

state = tf.Variable(0, name='counter')

# 定义常量 one
one = tf.constant(1)

# 定义加法步骤 (注: 此步并没有直接计算)
new_value = tf.add(state, one)

# 将 State 更新成 new_value
update = tf.assign(state,new_value)
# 如果定义 Variable, 就一定要 initialize
# init = tf.initialize_all_variables() # tf 马上就要废弃这种写法
init = tf.global_variables_initializer()  # 替换成这样就好

# 使用 Session
with tf.Session() as sess:
    sess.run(init)
    sess.run(update)
    print(sess.run(state))
    print(sess.run(new_value))
    sess.run(update)
    print(sess.run(state))
    print(sess.run(new_value))

    sess.run(update)
    print(sess.run(state))
    print(sess.run(new_value))

    sess.run(update)
    print(sess.run(state))
    print(sess.run(new_value))

实战四、placehoder的用法

这一次我们会讲到 Tensorflow 中的 placeholder , placeholder 是 Tensorflow 中的占位符,暂时储存变量.

Tensorflow 如果想要从外部传入data, 那就需要用到 tf.placeholder(), 然后以这种形式传输数据 sess.run(***, feed_dict={input: **}).

示例:



import tensorflow as tf

#在 Tensorflow 中需要定义 placeholder 的 type ,一般为 float32 形式
input1 = tf.placeholder(tf.float32)
input2 = tf.placeholder(tf.float32)

# mul = multiply 是将input1和input2 做乘法运算,并输出为 output 
ouput = tf.multiply(input1, input2)

接下来, 传值的工作交给了 sess.run() , 需要传入的值放在了feed_dict={} 并一一对应每一个 input. placeholder 与 feed_dict={} 是绑定在一起出现的。

with tf.Session() as sess:
    print(sess.run(ouput, feed_dict={input1: [7.], input2: [2.]}))
# [ 14.]

实战五、

 

问题解决:

'NoneType' object has no attribute 'shape'  这种情况可能是由于你在标注过数据集之后又更改名字了 在同一个地方摔倒了两次

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值