摄像头行为分析系统运用3D三维视觉优化算法和人工智能优化算法,摄像头行为分析系统可以支持人员摔倒、剧烈运动、抽烟识别、徘徊滞留、人数超员、区域入侵、睡岗离岗等行为分析功能,实现各种场景的个性化智能需求。如:越界侦测、区域入侵侦测、进入区域侦测、离开区域侦测、攀高识别、河道漂浮物识别、徘徊侦测、人员聚集侦测、快速运动侦测、违规停车、人脸侦测。
深度学习应用到实际问题中,一个非常棘手的问题是训练模型时计算量太大。为了加速训练,TensorFlow可以利用GPU或/和分布式计算进行模型训练。TensorFlow可以通过td.device函数来指定运行每个操作的设备,这个设备可以是本设备的CPU或GPU,也可以是远程的某一台设备。TF生成会话的时候,可愿意通过设置tf.log_device_placemaent参数来打印每一个运算的设备。
import tensorflow as tf
a = tf.constant([1.0,2.0,3.0],shape=[3],name='a')
b = tf.constant([1.0,2.0,3.0],shape=[3],name='b')
c= tf.add_n([a,b],name="c")
with tf.Session(config=tf.ConfigProto(log_device_placement = True)) as sess:
print(sess.run(c))
########
Device mapping: no known devices.
c: (AddN): /job:localhost/replica:0/task:0/device:CPU:0
b: (Const): /job:localhost/replica:0/task:0/device:CPU:0
a: (Const): /job:localhost/replica:0/task:0/device:CPU:0
[2. 4. 6.]
在配置好了GPU环境的TensorFlow中,如果没有明确指明运行设备,TF会优先选择GPU。
import tensorflow as tf
a = tf.constant([1.0,2.0,3.0],shape=[3],name='a')
b = tf.constant([1.0,2.0,3.0],shape=[3],name='b')
c= tf.add_n([a,b],name="c")
with tf.Session(config=tf.ConfigProto(log_device_placement = True)) as sess:
print(sess.run(c))
########
Device mapping: no known devices.
c: (AddN): /job:localhost/replica:0/task:0/device:GPU:0
b: (Const): /job:localhost/replica:0/task:0/device:GPU:0
a: (Const): /job:localhost/replica:0/task:0/device:GPU:0
[2. 4. 6.]
可以通过tf.device 来制定运行操作的设备。
import tensorflow as tf
with tf.device("/CPU:0"):
a = tf.constant([1.0,2.0,3.0],shape=[3],name='a')
b = tf.constant([1.0,2.0,3.0],shape=[3],name='b')
with tf.device("/GPU:0"):
c= tf.add_n([a,b],name="c")
with tf.Session(config=tf.ConfigProto(log_device_placement = True)) as sess:
print(sess.run(c))
社会安全难题越来越受大众的高度重视。如果视频监控系统只具备视频监控搜集,没有视频分析作用,就需要大量人力资源管理去完成视频内容人力分析。伴随着监控系统的迅速发展,监控系统的应用愈来愈多。当监控数量太多,仅依据人力分析显而易见不太现实,成本费也较高。
分布式TensorFlow训练甚多学习模型的理论。本小节将具体介绍如何使用TF在分布式集群中训练深度学习模型。TensorFlow集群通过一系列的任务(tasks)来执行TF计算图中的运算。一般来说,不同的任务跑在不同的机器上。当然,使用GPU时,不同任务可以使用用一太机器上的不同GPU。TF中的任务可以聚合成工作。每个工作可以包含一个或多个任务。当一个TF集群有多个任务的时候,需要使用tf.train.ClusterSpec来指定运行每一个人物的机器。
配置第一个任务集群
import tensorflow as tf
c = tf.constant('Hello ,this is the server1!')
#生成一个有两个人物的集群,一个任务跑在本地的2222端口,另一个跑在本地的2223端口
cluster = tf.train.ClusterSpec({"local":['localhost:2998','localhost2999']})
#通过上面生成的集群配置生成Server。并通过job_name和task_index指定当前启动的任务。
server = tf.train.Server(cluster,job_name='local',task_index=0)
#通过server.target生成会话来使用来使用TF集群中的资源。通过log_device_placement可以看到执行每一个操作的任务
sess = tf.Session(server.target,config=tf.ConfigProto(log_device_placement = True))
print(sess.run(c))
配置第二个任务,使用同样的集群配置
import tensorflow as tf
c = tf.constant('Hello ,this is the server2!')
#和第一个任务一样的集群配置
cluster = tf.train.ClusterSpec({"local":['localhost:2998','localhost2999']})
#指定task_index = 1,所以第二个任务是运行在2999端口上
server = tf.train.Server(cluster,job_name='local',task_index=0)
sess = tf.Session(server.target,config=tf.ConfigProto(log_device_placement = True))
print(sess.run(c))
摄像头行为分析系统可以代替人们对视频中的场景进行分析。当出现问题,系统能够及时警报,减轻安全人员压力。与此同时,该系统还具备自动报警作用,能有效降低违法犯罪的产生。