Thursday, February 9, 2017
Some Good documents for CNN and RNN begineers
最近一直在想给你们不熟悉深度学习的学生推荐什么资料,因为刚刚开始有很多关键词不懂,今天找了一个很好的presentation, 给你们,感觉写得很好,可以认真看一下
Wednesday, March 30, 2016
Install dense trajectory
Step1: Install the opencv correctly
Ubuntu下编译安装OpenCV 2.4.7并读取摄像头
主要参考:
开发环境:VMware下Ubuntu+OpenCV2.4.7
安装过程:
The Installation Procedure
To install and configure OpenCV 2.4.1, complete the following steps. The commands shown in each step can be copy and pasted directly into a Linux command line.
- Remove any installed versions of ffmpeg and x264.
sudo apt-get remove ffmpeg x264 libx264-dev - Get all the dependencies for x264 and ffmpeg.
sudo apt-get update
sudo apt-get install build-essential checkinstall git cmake libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev texi2html yasm zlib1g-dev - Download and install gstreamer.
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev gstreamer0.10-tools gstreamer0.10-plugins-base libgstreamer-plugins-base0.10-dev gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-ffmpeg - Download and install gtk.
sudo apt-get install libgtk2.0-0 libgtk2.0-dev - Download and install libjpeg.
sudo apt-get install libjpeg8 libjpeg8-dev - Create a directory to hold source code.
cd ~
mkdir src - Download and install install x264.
- Download a recent stable snapshot of x264 from ftp://ftp.videolan.org/pub/videolan/x264/snapshots/. The exact version does not seem to matter. To write this guide, I used version x264-snapshot-20120528-2245-stable.tar.bz2, but I have used previous versions too.
cd ~/srcwget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20120528-2245-stable.tar.bz2tar xvf x264-snapshot-20120528-2245-stable.tar.bz2cd x264-snapshot-20120528-2245-stable - Configure and build the x264 libraries.
./configure --enable-static
make
sudo make installIMPORTANT: If you are running a 64-bit version of Ubuntu, you must configure x264 as shown in the following command:./configure --enable-shared --enable-picThe -shared and -pic options might also be required when you compile for some other architectures, such as ARM. You know you need these options if you get the following error when compiling OpenCV:[ 25%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/bitstrm.cpp.o
Linking CXX shared library ../../lib/libopencv_highgui.so
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32S against `av_destruct_packet' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavcodec.a: could not read symbols: Bad value
- Download a recent stable snapshot of x264 from ftp://ftp.videolan.org/pub/videolan/x264/snapshots/. The exact version does not seem to matter. To write this guide, I used version x264-snapshot-20120528-2245-stable.tar.bz2, but I have used previous versions too.
- Download and install install ffmpeg.
- Download ffmpeg version 0.11.1 from http://ffmpeg.org/download.html.
cd ~/src
wget http://ffmpeg.org/releases/ffmpeg-0.11.1.tar.bz2
tar xvf ffmpeg-0.11.1.tar.bz2
cd ffmpeg-0.11.1 - Configure and build ffmpeg.
./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grabmake
sudo make installIMPORTANT: Just like with x264 in the previous step, you must configure ffmpeg with the -shared and -pic options if you are running a 64-bit version of Ubuntu or some other architectures, such as ARM../configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared --enable-pic
- Download ffmpeg version 0.11.1 from http://ffmpeg.org/download.html.
- Download and install install a recent version of v4l (video for linux) from http://www.linuxtv.org/downloads/v4l-utils/. For this guide I used version 0.8.8.
cd ~/srcwget http://www.linuxtv.org/downloads/v4l-utils/v4l-utils-0.8.8.tar.bz2tar xvf v4l-utils-0.8.8.tar.bz2
cd v4l-utils-0.8.8
make
sudo make install - Download and install install OpenCV 2.4.2.
- Download OpenCV version 2.4.2 from http://sourceforge.net/projects/opencvlibrary/files/
cd ~/srcwget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.2/OpenCV-2.4.2.tar.bz2tar xvf OpenCV-2.4.2.tar.bz2 - Create a new build directory and run cmake:
cd OpenCV-2.4.2/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE .. - Verify that the output of cmake includes the following text:
- found gstreamer-base-0.10
- GTK+ 2.x: YES
- FFMPEG: YES
- GStreamer: YES
- V4L/V4L2: Using libv4l
- Build and install OpenCV.
make
sudo make install
- Download OpenCV version 2.4.2 from http://sourceforge.net/projects/opencvlibrary/files/
- Configure Linux.
- Tell linux where the shared libraries for OpenCV are located by entering the following shell command:
export LD_LIBRARY_PATH=/usr/local/libAdd the command to your .bashrc file so that you don’t have to enter every time your start a new terminal. (注:我主要采用将export LD_LIBRARY_PATH=/usr/local/lib加入.bashrc file的方法,.bashrc file为隐藏文件,在主用户目录下,可用shell命令:ls -al查看)Alternatively, you can configure the system wide library search path. Using your favorite editor, add a single line containing the text/usr/local/libto the end of a file named/etc/ld.so.conf.d/opencv.conf. In the standard Ubuntu install, the opencv.conf file does not exist; you need to create it. Using vi, for example, enter the following commands:sudo vi /etc/ld.so.conf.d/opencv.conf
G
o
/usr/local/lib
<Esc>
:wq!After editing the opencv.conf file, enter the following command:sudo ldconfig /etc/ld.so.conf. - Using your favorite editor, add the following two lines to the end of /etc/bash.bashrc:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
- Tell linux where the shared libraries for OpenCV are located by entering the following shell command:
After completing the previous steps, your system should be ready to compile code that uses the OpenCV libraries. The following example shows one way to compile code for OpenCV(这里最好先进行重启):
g++ `pkg-config opencv --cflags` DenseTrack.cpp -o DenseTrack `pkg-config opencv --libs`
remember to configure the path of opencv
Friday, December 18, 2015
如何在caffe中增加layer以及caffe中triplet loss layer的实现
1.如何在caffe中增加新的layer
http://blog.csdn.net/tangwei2014/article/details/46812153
新版的caffe中增加新的layer,变得轻松多了,概括说来,分四步:
1)在./src/caffe/proto/caffe.proto 中增加 对应layer的paramter message;
2)在./include/caffe/***layers.hpp中增加该layer的类的声明,***表示有common_layers.hpp, data_layers.hpp, neuron_layers.hpp, vision_layers.hpp 和loss_layers.hpp等;
3)在./src/caffe/layers/目录下新建.cpp和.cu文件,进行类实现。
4)在./src/caffe/gtest/中增加layer的测试代码,对所写的layer前传和反传进行测试,测试还包括速度。
最后一步很多人省了,或者没意识到,但是为保证代码正确,建议还是严格进行测试,磨刀不误砍柴功。
2.caffe中实现triplet loss layer
1.caffe.proto中增加triplet loss layer的定义
首先在message LayerParameter中追加 optional TripletLossParameter triplet_loss_param = 138; 其中138是我目前LayerParameter message中现有元素的个数,具体是多少,可以看LayerParameter message上面注释中的:
Tuesday, December 15, 2015
caffe HDF5 data layer preperation
https://groups.google.com/forum/#!topic/caffe-users/HN1eaUPBKO4
https://github.com/BVLC/caffe/tree/master/matlab/hdf5creation
https://github.com/BVLC/caffe/tree/master/matlab/hdf5creation
Tuesday, December 1, 2015
Caffe define a new layer hands on
Here's roughly the process I follow.
- Add a class declaration for your layer to the appropriate one of
common_layers.hpp,data_layers.hpp,loss_layers.hpp,neuron_layers.hpp, orvision_layers.hpp. Include an inline implementation oftypeand the*Blobs()methods to specify blob number requirements. Omit the*_gpudeclarations if you'll only be implementing CPU code. - Implement your layer in
layers/your_layer.cpp.SetUpfor initialization: reading parameters, allocating buffers, etc.Forward_cpufor the function your layer computesBackward_cpufor its gradient
- (Optional) Implement the GPU versions
Forward_gpuandBackward_gpuinlayers/your_layer.cu. - Add your layer to
proto/caffe.proto, updating the next available ID. Also declare parameters, if needed, in this file. - Make your layer createable by adding it to
layer_factory.cpp. - Write tests in
test/test_your_layer.cpp. Usetest/test_gradient_check_util.hppto check that your Forward and Backward implementations are in numerical agreement.
Friday, September 4, 2015
how to debug matlab code in linxu system
x = rand(10,10);
y = rand(10,5);
z = x * y;
keyboard; % you can interactively inspect x, y, z here
z = sort(z);
To leave keyboard mode, you can type
dbquit to exit the program, or return to continue executing the program.Thursday, September 3, 2015
CloudCV: Object Detection
http://cloudcv.org/objdetect/
Benchmarks and challenges like PASCAL VOC and ImageNet have played a crucial role in advancing computer vision algorithms. However, with minor exceptions, such challenges also result in massive duplication of effort, with each research group developing its own infrastructure and code-base. In fact, warnings of fragmentation and lack of code reuse have repeatedly been among the top observations by forward-looking NSF funded workshops [1,2].
CloudCV can help unify fragmented efforts by being a unified data and code repository.
Thursday, August 27, 2015
extract features using caffe
http://www.cnblogs.com/platero/p/3967208.html
feat_helper_pb2.py
# Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='datum.proto',
package='feat_extract',
serialized_pb='\n\x0b\x64\x61tum.proto\x12\x0c\x66\x65\x61t_extract\"i\n\x05\x44\x61tum\x12\x10\n\x08\x63hannels\x18\x01 \x01(\x05\x12\x0e\n\x06height\x18\x02 \x01(\x05\x12\r\n\x05width\x18\x03 \x01(\x05\x12\x0c\n\x04\x64\x61ta\x18\x04 \x01(\x0c\x12\r\n\x05label\x18\x05 \x01(\x05\x12\x12\n\nfloat_data\x18\x06 \x03(\x02')
_DATUM = descriptor.Descriptor(
name='Datum',
full_name='feat_extract.Datum',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='channels', full_name='feat_extract.Datum.channels', index=0,
number=1, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='height', full_name='feat_extract.Datum.height', index=1,
number=2, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='width', full_name='feat_extract.Datum.width', index=2,
number=3, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='data', full_name='feat_extract.Datum.data', index=3,
number=4, type=12, cpp_type=9, label=1,
has_default_value=False, default_value="",
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='label', full_name='feat_extract.Datum.label', index=4,
number=5, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='float_data', full_name='feat_extract.Datum.float_data', index=5,
number=6, type=2, cpp_type=6, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=29,
serialized_end=134,
)
DESCRIPTOR.message_types_by_name['Datum'] = _DATUM
class Datum(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _DATUM
# @@protoc_insertion_point(class_scope:feat_extract.Datum)
# @@protoc_insertion_point(module_scope)
leveldb2mat.py
import leveldb
import feat_helper_pb2
import numpy as np
import scipy.io as sio
import time
def main(argv):
leveldb_name = sys.argv[1]
print "%s" % sys.argv[1]
batch_num = int(sys.argv[2]);
batch_size = int(sys.argv[3]);
window_num = batch_num*batch_size;
start = time.time()
if 'db' not in locals().keys():
db = leveldb.LevelDB(leveldb_name)
datum = feat_helper_pb2.Datum()
ft = np.zeros((window_num, int(sys.argv[4])))
for im_idx in range(window_num):
datum.ParseFromString(db.Get('%d' %(im_idx)))
ft[im_idx, :] = datum.float_data
print 'time 1: %f' %(time.time() - start)
sio.savemat(sys.argv[5], {'feats':ft})
print 'time 2: %f' %(time.time() - start)
print 'done!'
#leveldb.DestroyDB(leveldb_name)
if __name__ == '__main__':
import sys
main(sys.argv)
feat_helper_pb2.py
# Generated by the protocol buffer compiler. DO NOT EDIT!
from google.protobuf import descriptor
from google.protobuf import message
from google.protobuf import reflection
from google.protobuf import descriptor_pb2
# @@protoc_insertion_point(imports)
DESCRIPTOR = descriptor.FileDescriptor(
name='datum.proto',
package='feat_extract',
serialized_pb='\n\x0b\x64\x61tum.proto\x12\x0c\x66\x65\x61t_extract\"i\n\x05\x44\x61tum\x12\x10\n\x08\x63hannels\x18\x01 \x01(\x05\x12\x0e\n\x06height\x18\x02 \x01(\x05\x12\r\n\x05width\x18\x03 \x01(\x05\x12\x0c\n\x04\x64\x61ta\x18\x04 \x01(\x0c\x12\r\n\x05label\x18\x05 \x01(\x05\x12\x12\n\nfloat_data\x18\x06 \x03(\x02')
_DATUM = descriptor.Descriptor(
name='Datum',
full_name='feat_extract.Datum',
filename=None,
file=DESCRIPTOR,
containing_type=None,
fields=[
descriptor.FieldDescriptor(
name='channels', full_name='feat_extract.Datum.channels', index=0,
number=1, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='height', full_name='feat_extract.Datum.height', index=1,
number=2, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='width', full_name='feat_extract.Datum.width', index=2,
number=3, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='data', full_name='feat_extract.Datum.data', index=3,
number=4, type=12, cpp_type=9, label=1,
has_default_value=False, default_value="",
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='label', full_name='feat_extract.Datum.label', index=4,
number=5, type=5, cpp_type=1, label=1,
has_default_value=False, default_value=0,
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
descriptor.FieldDescriptor(
name='float_data', full_name='feat_extract.Datum.float_data', index=5,
number=6, type=2, cpp_type=6, label=3,
has_default_value=False, default_value=[],
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
],
extensions=[
],
nested_types=[],
enum_types=[
],
options=None,
is_extendable=False,
extension_ranges=[],
serialized_start=29,
serialized_end=134,
)
DESCRIPTOR.message_types_by_name['Datum'] = _DATUM
class Datum(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _DATUM
# @@protoc_insertion_point(class_scope:feat_extract.Datum)
# @@protoc_insertion_point(module_scope)
leveldb2mat.py
import leveldb
import feat_helper_pb2
import numpy as np
import scipy.io as sio
import time
def main(argv):
leveldb_name = sys.argv[1]
print "%s" % sys.argv[1]
batch_num = int(sys.argv[2]);
batch_size = int(sys.argv[3]);
window_num = batch_num*batch_size;
start = time.time()
if 'db' not in locals().keys():
db = leveldb.LevelDB(leveldb_name)
datum = feat_helper_pb2.Datum()
ft = np.zeros((window_num, int(sys.argv[4])))
for im_idx in range(window_num):
datum.ParseFromString(db.Get('%d' %(im_idx)))
ft[im_idx, :] = datum.float_data
print 'time 1: %f' %(time.time() - start)
sio.savemat(sys.argv[5], {'feats':ft})
print 'time 2: %f' %(time.time() - start)
print 'done!'
#leveldb.DestroyDB(leveldb_name)
if __name__ == '__main__':
import sys
main(sys.argv)
#!/usr/bin/env sh # args for EXTRACT_FEATURE TOOL=../../build/tools MODEL=../../examples/imagenet/caffe_reference_imagenet_model #下载得到的caffe model PROTOTXT=../../examples/_temp/imagenet_val.prototxt # 网络定义 LAYER=conv1 # 提取层的名字,如提取fc7等 LEVELDB=../../examples/_temp/features_conv1 # 保存的leveldb路径 BATCHSIZE=10 # args for LEVELDB to MAT DIM=290400 # 需要手工计算feature长度 OUT=../../examples/_temp/features.mat #.mat文件保存路径 BATCHNUM=1 # 有多少哥batch, 本例只有两张图, 所以只有一个batch $TOOL/extract_features.bin $MODEL $PROTOTXT $LAYER $LEVELDB $BATCHSIZE python leveldb2mat.py $LEVELDB $BATCHNUM $BATCHSIZE $DIM $OUT
caffe extract features - tool batch size and model batch size
https://github.com/BVLC/caffe/issues/585#issuecomment-51856173
Caffe operates on batches of data in GPU mode to reduce the overhead of communicating between the host and device. The feature extraction example
the tool batch size is set to 10 then it will extract 500 image features
the tool batch size is set to 20 then it will extract 1000 image features
Caffe operates on batches of data in GPU mode to reduce the overhead of communicating between the host and device. The feature extraction example
batch_size is set to 50, and when the tool is called it is given 10 iterations as its argument, so it is actually processing 500 inputs. Set the batch_size and iteration arg to both be 1 to process a single image, although that's less efficient in throughput.batch_size is set to 50the tool batch size is set to 10 then it will extract 500 image features
the tool batch size is set to 20 then it will extract 1000 image features
Thursday, August 20, 2015
decaffen Getting an error: unrecognized command line option ‘-Wl’
https://github.com/UCB-ICSI-Vision-Group/decaf-release/issues/3
Friday, June 14, 2013
Wednesday, May 16, 2012
Tuesday, May 15, 2012
Copy nodes subtree from one DOM document to another
package com.javacodegeeks.snippets.core;
import java.io.File;
import java.io.FileInputStream;
import java.io.StringWriter;
import java.io.Writer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class CopyNodesSubtreeFromOneDOMDocumentToAnother {
public static void main(String[] args) throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc1 = db.parse(new FileInputStream(new File("in1.xml")));
Document doc2 = db.parse(new FileInputStream(new File("in2.xml")));
System.out.println("Before Copy...");
prettyPrint(doc2);
NodeList list = doc1.getElementsByTagName("channel");
Element element = (Element) list.item(0);
// Imports a node from another document to this document, without altering
// or removing the source node from the original document
Node copiedNode = doc2.importNode(element, true);
// Adds the node to the end of the list of children of this node
doc2.getDocumentElement().appendChild(copiedNode);
System.out.println("After Copy...");
prettyPrint(doc2);
}
public static final void prettyPrint(Document xml) throws Exception {
Transformer tf = TransformerFactory.newInstance().newTransformer();
tf.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
tf.setOutputProperty(OutputKeys.INDENT, "yes");
Writer out = new StringWriter();
tf.transform(new DOMSource(xml), new StreamResult(out));
System.out.println(out.toString());
}
}input:
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <title>Java Tutorials and Examples 1</title> <language>en-us</language> <item> <title><![CDATA[Java Tutorials 1]]></title> <link>http://www.javacodegeeks.com/</link> </item> <item> <title><![CDATA[Java Examples 1]]></title> <link>http://examples.javacodegeeks.com/</link> </item> </channel> </rss>
Thursday, May 10, 2012
writing SWRL rules on protege 4.1 and running on pellet reasoner
1. install the
Pellet Reasoner Plug-in for Protégé 4
- Select “File | Preferences”.
- Select “Plugins” tab.
- Click the “Check for downloads now” button under the “Plugin registry” heading.
- Scroll down the “Downloads” list to find “Pellet Reasoner Plug-in” and select the checkbox next to it (See the screen shot below).
- If you agree with the licensing terms click “Install”.
- When you see the “Updates will take effect next time Protege starts” message, restart Protégé.
2. go to the "window"->views->ontology views->rules
then you can define you SWRL rules in the rule tab.
Sunday, October 30, 2011
Thursday, October 20, 2011
english words or phases
mark occasion
going lunch
see you around the traps
in the absence of good idea
farewell morning tea
going lunch
see you around the traps
in the absence of good idea
farewell morning tea
Subscribe to:
Posts (Atom)