tobybreckon - fire-detection-cnn

tobybreckon - fire-detection-cnn

https://github.com/tobybreckon/fire-detection-cnn

Real-time fire detection in video imagery using a convolutonal neural network (deep learning).

IEEE International Conference on Image Processing,ICIP

1. EXPERIMENTALLY DEFINED CONVOLUTIONAL NEURAL NETWORK ARCHITECTURE VARIANTS FOR NON-TEMPORAL REAL-TIME FIRE DETECTION

Python 3.x
TensorFlow 1.13.0
OpenCV 3.3.x / OpenCV 4.0.x (opencv module - ximgproc module for superpixel segmentation)

Extended Image Processing: opencv_contrib/modules/ximgproc/

1.1 Architectures

在这里插入图片描述

FireNet architecture

在这里插入图片描述

InceptionV1-OnFire architecture

1.2 Abstract

In this work we investigate the automatic detection of fire pixel regions in video (or still) imagery within real-time bounds without reliance on temporal scene information. As an extension to prior work in the field, we consider the performance of experimentally defined, reduced complexity deep convolutional neural network architectures for this task. Contrary to contemporary trends in the field, our work illustrates maximal accuracy of 0.93 for whole image binary fire detection, with 0.89 accuracy within our superpixel localization framework can be achieved, via a network architecture of signficantly reduced complexity. These reduced architectures additionally offer a 3-4 fold increase in computational performance offering up to 17 fps processing on contemporary hardware independent of temporal information. We show the relative performance achieved against prior work using benchmark datasets to illustrate maximally robust real-time fire region detection.
在这项工作中,我们研究在实时边界内自动检测视频 (或静止) 图像中的火焰像素区域,而不依赖于时间场景信息。作为对先前工作的扩展,我们考虑了实验定义的,降低复杂度的深度卷积神经网络架构的性能。与这个领域当代趋势相反,我们的工作表明整个图像二元火焰检测的最大准确度为 0.93,在我们的超像素定位框架内可以实现 0.89 的准确度,使用显著降低复杂性的网络架构。这些简化的架构还提供了 3-4 倍的计算性能提升,在独立于时间信息的现代硬件上提供高达 17 fps 的处理。我们展示了使用基准数据集相比于先前工作所取得的相对性能,以说明最大鲁棒的实时火焰区域检测。

non-stationary:adj. 不稳定的,非平稳
still [stɪl]:adv. 仍然,还,还是,依旧 conj. 然而 adj. 静止的,平静的,安静的,寂静的 v. 安静 n.剧照, (电影或录像的) 定格画面,(制酒的) 蒸馏器
reliance [rɪ'laɪəns]:n. 信赖,信心,受信赖的人或物
bound [baʊnd]:n. 跳跃,蹦跳 adj. 一定会,很可能会,受 (法律、义务或情况) 约束 (必须做某事) v. 跳跃着跑,形成...的边界 (或界限)
contrary ['kɒntrərɪ]:adj. 相反的,对立的 adv. 相反地 n. 相反,反面
contemporary [kən'temp(ə)r(ər)ɪ]:adj. 发生 (属) 于同时期的,当代的 n. 同代人,同龄人,同时期的东西

(1) using InceptionV1-OnFire CNN model (2) using SP-InceptionV1-OnFire CNN model

在这里插入图片描述

Original frame (left), Frame after superpixel segmentation (middle), Frame after superpixel fire prediction (right).

1.3 Instructions to test pre-trained models

To download and test the supplied code and pre-trained models (with TFLean/OpenCV installed) do:

$ git clone https://github.com/tobybreckon/fire-detection-cnn.git
$ cd fire-detection-cnn
$ sh ./download-models.sh
$ python firenet.py models/test.mp4
$ python inceptionV1OnFire.py models/test.mp4
$ python superpixel-inceptionV1OnFire.py models/test.mp4

strong@foreverstrong:~$ source ./venv/bin/activate
(venv) strong@foreverstrong:~$ 
(venv) strong@foreverstrong:~$ pip3 install tflearn
Collecting tflearn
  Downloading https://files.pythonhosted.org/packages/16/ec/e9ce1b52e71f6dff3bd944f020cef7140779e783ab27512ea7c7275ddee5/tflearn-0.3.2.tar.gz (98kB)
     |████████████████████████████████| 102kB 10kB/s 
Requirement already satisfied: numpy in /usr/local/lib/python3.5/dist-packages (from tflearn) (1.13.3)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from tflearn) (1.10.0)
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from tflearn) (3.1.2)
Building wheels for collected packages: tflearn
  Building wheel for tflearn (setup.py) ... done
  Stored in directory: /home/strong/.cache/pip/wheels/d0/f6/69/0ef3ee395aac2e5d15d89efd29a9a216f3c27767b43b72c006
Successfully built tflearn
Installing collected packages: tflearn
Successfully installed tflearn-0.3.2
(venv) strong@foreverstrong:~$ 


(venv) strong@foreverstrong:~$ python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
Tensor("Sum:0", shape=(), dtype=float32)
(venv) strong@foreverstrong:~$ 
(venv) strong@foreverstrong:~$ pip3 list | grep tensorflow
tensorflow                    1.13.0rc2             
tensorflow-estimator          1.13.0                
(venv) strong@foreverstrong:~$ 


(venv) strong@foreverstrong:~$ cd venv/
(venv) strong@foreverstrong:~/venv$ ll
total 20
drwxrwxr-x  5 strong strong 4096 Jul 18 21:17 ./
drwxr-xr-x 97 strong strong 4096 Jul 18 22:03 ../
drwxrwxr-x  2 strong strong 4096 Jul 18 22:05 bin/
drwxrwxr-x  2 strong strong 4096 Jul 18 21:17 include/
drwxrwxr-x  3 strong strong 4096 Jul 18 21:17 lib/
(venv) strong@foreverstrong:~/venv$ mkdir tensorflow_work
(venv) strong@foreverstrong:~/venv$ cd tensorflow_work/
(venv) strong@foreverstrong:~/venv/tensorflow_work$ ls
(venv) strong@foreverstrong:~/venv/tensorflow_work$ git clone https://github.com/tobybreckon/fire-detection-cnn.git
Cloning into 'fire-detection-cnn'...
remote: Enumerating objects: 243, done.
remote: Counting objects: 100% (243/243), done.
remote: Compressing objects: 100% (125/125), done.
remote: Total 447 (delta 142), reused 195 (delta 108), pack-reused 204
Receiving objects: 100% (447/447), 2.82 MiB | 15.00 KiB/s, done.
Resolving deltas: 100% (250/250), done.
Checking connectivity... done.
(venv) strong@foreverstrong:~/venv/tensorflow_work$ 
(venv) strong@foreverstrong:~/venv/tensorflow_work$ cd fire-detection-cnn
(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ 


(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ sh ./download-models.sh
Downloading pretrained models...

curl: (60) server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ 

修改 download-models.sh,添加 -k,完成正常下载。

################################################################################

# model downloader / unpacker - (c) 2018 Toby Breckon, Durham University, UK

################################################################################

URL_MODELS=https://collections.durham.ac.uk/downloads/r19880vq98m
MODEL_DIR_LOCAL_TARGET=models

MODELS_FILE_NAME=dunnings-2018-fire-detection-pretrained-models.zip
MODELS_DIR_NAME_UNZIPPED=dunnings-2018-fire-detection-pretrained-models
MODELS_MD5_SUM=98815a8594a18f1cafb3e87af8f9b0f1

################################################################################

# set this script to fail on error

set -e

# check for required commands to download and md5 check

(command -v curl | grep curl > /dev/null) ||
  (echo "Error: curl command not found, cannot download!")

(command -v md5sum | grep md5sum > /dev/null) ||
  (echo "Error: md5sum command not found, md5sum check will fail!")

################################################################################

# perform download

echo "Downloading pretrained models..."

mkdir -p $MODEL_DIR_LOCAL_TARGET

MODELS=./$MODEL_DIR_LOCAL_TARGET/$MODELS_FILE_NAME

curl --progress-bar $URL_MODELS > $MODELS -k

################################################################################

# perform md5 check and move to required local target directory

cd $MODEL_DIR_LOCAL_TARGET

echo "checking the MD5 checksum for downloaded models..."

CHECK_SUM_CHECKPOINTS="$MODELS_MD5_SUM  $MODELS_FILE_NAME"

echo $CHECK_SUM_CHECKPOINTS | md5sum -c

echo "Unpacking the zip file..."

unzip -q $MODELS_FILE_NAME

echo "Tidying up..."

mv $MODELS_DIR_NAME_UNZIPPED/* .

rm $MODELS_FILE_NAME && rm -r $MODELS_DIR_NAME_UNZIPPED

cd ..

################################################################################

# tlearn format specific - create checkpoint path files to enable conversion to pb format

echo "model_checkpoint_path: \"firenet\"" > $MODEL_DIR_LOCAL_TARGET/FireNet/checkpoint
echo "all_model_checkpoint_paths: \"firenet\"" >> $MODEL_DIR_LOCAL_TARGET/FireNet/checkpoint

echo "model_checkpoint_path: \"inceptiononv1onfire\"" > $MODEL_DIR_LOCAL_TARGET/InceptionV1-OnFire/checkpoint
echo "all_model_checkpoint_paths: \"inceptiononv1onfire\"" >> $MODEL_DIR_LOCAL_TARGET/InceptionV1-OnFire/checkpoint

echo "model_checkpoint_path: \"sp-inceptionv1onfire\"" > $MODEL_DIR_LOCAL_TARGET/SP-InceptionV1-OnFire/checkpoint
echo "all_model_checkpoint_paths: \"sp-inceptionv1onfire\"" >> $MODEL_DIR_LOCAL_TARGET/SP-InceptionV1-OnFire/checkpoint

################################################################################

echo "... completed -> required models are in $MODEL_DIR_LOCAL_TARGET/"

################################################################################
strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ bash ./download-models.sh 
Downloading pretrained models...
######################################################################## 100.0%
checking the MD5 checksum for downloaded models...
dunnings-2018-fire-detection-pretrained-models.zip: OK
Unpacking the zip file...
Tidying up...
... completed -> required models are in models/
strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ 

strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ source /home/strong/venv/bin/activate
(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$

(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ deactivate
strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$

strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ source /home/strong/venv/bin/activate
(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ 
(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ ls
12334.txt  converter  download-models.sh  firenet.py  images  inceptionV1OnFire.py  LICENSE  models  README.md  superpixel-inceptionV1OnFire.py
(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ python firenet.py models/test.mp4
WARNING:tensorflow:From /home/strong/venv/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /home/strong/venv/lib/python3.5/site-packages/tflearn/initializations.py:119: UniformUnitScaling.__init__ (from tensorflow.python.ops.init_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.initializers.variance_scaling instead with distribution=uniform to get equivalent behavior.
WARNING:tensorflow:From /home/strong/venv/lib/python3.5/site-packages/tflearn/layers/core.py:239: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.
Instructions for updating:
Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.
2019-07-19 09:41:45.056623: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-07-19 09:41:45.220846: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3600000000 Hz
2019-07-19 09:41:45.227599: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x48eef40 executing computations on platform Host. Devices:
2019-07-19 09:41:45.227629: I tensorflow/compiler/xla/service/service.cc:158]   StreamExecutor device (0): <undefined>, <undefined>
Constructed FireNet ...
WARNING:tensorflow:From /home/strong/venv/lib/python3.5/site-packages/tensorflow/python/training/saver.py:1266: checkpoint_exists (from tensorflow.python.training.checkpoint_management) is deprecated and will be removed in a future version.
Instructions for updating:
Use standard file APIs to check for files with this prefix.
Loaded CNN network weights ...
Loaded video ...
QObject::moveToThread: Current thread (0x4ab2f40) is not the object's thread (0x4714590).
Cannot move to target thread (0x4ab2f40)

QObject::moveToThread: Current thread (0x4ab2f40) is not the object's thread (0x4714590).
Cannot move to target thread (0x4ab2f40)

......

QObject::moveToThread: Current thread (0x4ab2f40) is not the object's thread (0x4714590).
Cannot move to target thread (0x4ab2f40)

QObject::moveToThread: Current thread (0x4ab2f40) is not the object's thread (0x4714590).
Cannot move to target thread (0x4ab2f40)

Qt: Cannot set locale modifiers: 
... end of video file reached
(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ 
(venv) strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ deactivate
strong@foreverstrong:~/venv/tensorflow_work/fire-detection-cnn$ 
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值