This article was originally posted here: Deep-Learning (CNN) with Scilab – Using Caffe Model by our partner Tan Chin Luh.
You can download the Image Processing & Computer Vision toolbox IPCV here: https://atoms.scilab.org/toolboxes/IPCV
- Caffe provides state-of-the-art modeling for advancing and deploying deep learning in research and industry with support for a wide variety of architectures and efficient implementations of prediction and learning. Caffe supports cuDNN v5 for GPU acceleration. Supported interfaces: C, C, Python, MATLAB, Command line interface. What is Caffe?
- Aug 31, 2016 1. Go to caffe root directory, open Makefile.config, and modify the follwoing: to your MATLAB parent directory (above the bin/) e.g. Make Matcaffe binaries: 3. Test matcaffe installation: 4. Now open /.bashrc and check if the following lines are there, otherwise find them in your (it can be different for your case) system.
Nov 03, 2014 Caffe provides multimedia scientists and practitioners with a clean and modifiable framework for state-of-the-art deep learning algorithms and a collection of reference models. The framework is a BSD-licensed C library with Python and MATLAB bindings for training and deploying general-purpose convolutional neural networks and other deep. This repo contains a MATLAB re-implementation of Fast R-CNN. Details about Fast R-CNN are in: rbgirshick/fast-rcnn. This code has been tested on Windows 7/8 64-bit, Windows Server 2012 R2, and Linux, and on MATLAB 2014a. Python version is available at py-faster-rcnn.
In the previous post on Convolutional Neural Network (CNN), I have been using only Scilab code to build a simple CNN for MNIST data set for handwriting recognition. In this post, I am going to share how to load a Caffe model into Scilab and use it for objects recognition.
This example is going to use the Scilab Python Toolbox together with IPCV module to load the image, pre-process, and feed it into Caffe model to recognition. I will start from the point with the assumption that you already have the Python setup with caffe module working, and Scilab will call the caffe model from its’ environment. On top of that, I will just use the CPU only option for this demo.
Let’s see how it works in video first if you wanted to:
Let’s start to look into the codes.
The codes above will import the python libraries and set the caffe to CPU mode.
This will load the caffe model, the labels, and also the means values for the training dataset which will be subtracted from each layers later on.
Initially the data would be reshape to 3*227*227 for the convenient to assign data from the new image. (This likely is the limitation of Scipython module in copying the data for numpy ndarray, or I’ve find out the proper way yet)
This part is doing the “transformer” job in Python. I personally feel that this part is easier to be understand by using Scilab. First, we read in the image and convert it to 227 by 227 RGB image. This is followed by subtracting means RGB value from the training set from the image RGB value resulting the data from -128 to 127. (A lot of sites mentioned that the range is 0-255, which I disagreed).
This is followed by transposing the image using permute command, and convert from RGB to BGR. (this is how the network sees the image).
Change reply to address in outlook office 365 for mac. In this 3 lines, we will reshape the input blob to 1 x 154587, assign input to it, and then reshape it to 1 x 3 x 227 x 227 so that we could run the network.
Finally, we compute the forward propagation and get the result and show it on the image with detected answer.
A few results shown as below:
Word Count: 1,757
Read Count:
Series
Guide
requirements:
- windows: 10
- caffe:
caffe-windows
- nvidia driver: gtx 1060 382.05 (gtx 970m)
- GPU arch(s): sm_61 (sm_52)
- cuda: 8.0
- cudnn: 5.0.5
- opencv: 3.1.0 WITH_CUDA (compiled from source)
- other libs:
libraries_v140_x64_py27_1.1.0.tar.bz2
cuda+cudnn
- download and install driver by standalone for
GTX 970
orGTX 1060
from here. - download and install
cuda_8.0.61_win10.exe
, skip install nvidia driver and install toolkit only. - download and install
cudnn-8.0-windows10-x64-v5.0-ga.zip
.
nvidia driver
driver can be installed by standalone or from
we choose to install by standalone
cuda_xxx_win10.exe
.we choose to install by standalone
download proper driver for
GTX 970
or GTX 1060
eg: 398.36-notebook-win10-64bit-international-whql.exe
from herecuda toolkit
ref: cuda install guides for windows
download
cuda_8.0.61_win10.exe
from hereThe CUDA Toolkit installs the CUDA driver and tools needed to create, build and run a CUDA application as well as libraries, header files, CUDA samples source code, and other resources
cuda_8.0.61_win10.exe
includes: Nvidia driver + toolkit.install to
- driver install to
C:/Program Files/NVIDIA Corporation
andC:/ProgramData/NVIDIA Corporation
- tookit install to
C:/Program Files/NVIDIA GPU Computing Toolkit
,which contains headers,libs,tools for compiling CUDA applications.C:/ProgramData/NVIDIA GPU Computing Toolkit
contains cuda plugins for Visual Studio.
verify
cudnn
extract
cudnn-8.0-windows10-x64-v5.0-ga.zip
and copy include
,lib
and bin
to C:Program FilesNVIDIA GPU Computing ToolkitCUDAv8.0
check cuda
compile
download
- place
caffe-windows
atC:/compile/caffe-windows
- extract
libraries_v140_x64_py27_1.1.0.tar.bz2
toC:Userszunli.caffedependencieslibraries_v140_x64_py27_1.1.0libraries
config
edit
C:Userszunli.caffedependencieslibraries_v140_x64_py27_1.1.0librariescaffe-builder-config.cmake
edit
caffe-windows/cmake/Dependencies.cmake
Tips:
(1) we use
(2) we use caffe
(1) we use
C:Boost
1.64 to replace caffe dependencies C:Userszunli.caffedependencieslibraries_v140_x64_py27_1.1.0libraries
1.61, because we have compile PCL 1.8.1
with Boost 1.64 static
.(2) we use caffe
C:Userszunli.caffedependencieslibraries_v140_x64_py27_1.1.0librariesx64vc14lib
to replace C:/Program Files/opencv
. (opencv3.1 <opencv3.4)configure caffe with
with options Acronis backup %26 recovery 11.5 free with crack.
configure and output
build and install
tips: Visual Studio 2015 can not generate shared library. So we build static caffe library.
Build with
Release x64
with Visual Studio 2015
and 38 modules will be generated and We Install
to C:/car_libs/caffe/
.build result.
install to
C:/car_libs/caffe
.![Caffe Caffe](https://initialneil.files.wordpress.com/2015/01/configuration-manager-1.png)
caffe usage
CMakeLists.txt
when we use
caffe
lib in our program, errors will occur. And we need to fix CaffeTargets-release.cmake
file。usage error fix
(1) error with shared.lib
solution:
(2) error with
hdf5
Caffe Matlab Download
hdf5.lib
>libcaffehdf5.lib
hdf5_hl.lib
>libcaffehdf5_hl.lib
(3) error with libopenblas
solution:
cd
C:Userszunli.caffedependencieslibraries_v140_x64_py27_1.1.0librarieslib
and- copy
libopenblas.a
>libopenblas.a.lib
- copy
libopenblas.dll.a
>libopenblas.dll.a.lib
(4) error NtClose
solution:
CaffeTargets-release.cmake
edit
C:car_libscaffeshareCaffeCaffeTargets-release.cmake
comiple errors with caffe.pb.h
tips: sometimes we not need to do this. Dpms lower receiver serial number.
CMakeLists.txt
vim
C:car_libscaffeincludecaffeprotocaffe.pb.h
replace
STRICT
and PERMISSIVE
to _STRICT
and _PERMISSIVE
.run exe
- copy
C:/car_libs/caffe/bin/*.dll
dlls tobin/release
folder. - copy
Opencv
dlls tobin/release
folder.
Errors and Solutions
nvidia driver not compatible with windows 10
problem: install nvidia driver failed on windows 10
Caffe Matlab Code
solution
- download Windows10Upgrade
- run
Windows10Upgrade.exe
to upgrade windows 10 to latest. - install nvidia driver again.
- OK.
Reference
History
Caffe Matlab
- 20180413 created.
All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source kezunlin !
赏