shamangary's Blog

一起來雲端深度學習:Torch7(Caffe)+AWS EC2+bitfusion.io. A tutorial for cloud based deep learning without buying a GPU computer.

| Comments

最近因為越來越多人在跑deep learning,身為一個做descriptor的人也務必要跟上時代,
然而自己使用的桌電或筆電都沒有GPU,唯一有的又是windows,也不能裝torch7,
已經困擾自己一陣子,今天終於下定決心使用AWS雲端,外加bitfusion.io所做好的instance,
也就是下面連結,第一次看到也許會覺得有些複雜,但是其實相較於買一台新的電腦來裝GPU,
這點小事還是要克服的。
Torch7+EC2+bitfusion:
https://aws.amazon.com/marketplace/pp/B01B4ZSX5S
Caffe+EC2+bitfusion:
https://aws.amazon.com/marketplace/pp/B01B52CMSO
在執行這動作之前,確保你先有亞馬遜的帳號,以及信用卡已經登記上去了,
而且記得去產生一個金鑰,為了安全需要,而且待會需要用到。
這當然是要付錢的,但是如果你跟我一樣剛好沒有GPU,又只有少部分的需要,我會覺得很方便。

喔!還有很重要的一點,他把Torch7或Caffe都安裝好了,所以一旦你設定完,就可以開始用了,操方便!

一步一步來:


雖然好像很多選項,但是其實一開始你只需要先按Single AMI,然後按continue就可以了。

進去裡面後按一下Custom Lanuch會看到以上畫面,稍微改一下Region看你想在哪就在哪,
通常會選離自己比較近的,然後再往下拉

其實右邊那個一長條你也不用看,待會我會說為什麼,你只要注意左邊的Single AMI下面的
Launch,找到你喜歡的地區,按下Launch with EC2 Console繼續下面動作。
到了下一頁,乍看之下好像很多選擇,但是我們使用的前提是需要GPU,所以你的選擇其實很少,

往下滑,選了最便宜的g2.2xlarge

其實中間還有很多步驟,但是如果你跟我一樣很懶而且你覺得沒人會想偷你的程式,我們就直接按
Review and Launch

你會發現兩到三個警告,大概是說你的安全協定不夠好,或是你採用的不是免費的範圍,
還有可能是你的金鑰沒有設定好,如果你現在還沒有金鑰,需要回去AWS產生,
我們去AWS的網頁

按左上角的EC2,然後下一頁左邊一堆選項選擇較下面的Key pairs

然後按Create Key Pairs,自己命名後按下產生就會出現一個金鑰,可以自己下載下來,之後會需要用到。

然後回去剛剛的地方,你就可以按下Lanuch後他會要你選擇已經存在的金鑰,
你就選擇你剛剛設定好的金鑰名稱,我們就安裝完成了。
安裝完之後我們可以去AWS的instance看,應該就會有一個東西在跑了。

基本上的設定就是這樣,接著記得我們來處理一下剛剛的金鑰,因為金鑰下載下來是任何人都可以編輯的,
我們需要改變它的權限讓他變得更安全,不然亞馬遜不讓你用它連線,我們現在假設你把金鑰key.pem放在桌面。
如果你是mac,進入terminal,打入下面指令:chmod 400 ~/Desktop/key.pem
如此一來就只有使用者(也就是有該電腦密碼的你)才能編輯,接著我們來連線雲端吧。

在terminal打入:ssh -i ~/Desktop/key.pem ubuntu@ec2-11-111-11-11.ap-northeast-1.compute.amazonaws.com
第三項是你金鑰的所在位置,第四項是你雲端的位置,也就是剛剛連線後,Public DNS的位置,
不知道在哪的話回去instance那個網頁看一下Public DNS的字,記得打命令的時候前面要加上ubuntu@

然後你應該就能享受在雲端使用torch7+GPU惹!!!這樣才能用cudnn這個該死的library!!!

[CVPR16] Accumulated Stability Voting: A Robust Descriptor from Descriptors of Multiple Scales

| Comments

Figure 1. Comparisons of descriptors in terms of both storage requirement and matchiing performance.

Abstract

This paper proposes a novel local descriptor through accumulated stability voting (ASV). The stability of feature dimensions is measured by their differences across scales. To be more robust to noise, stability is further quantized by thresholding. The principle of maximum entropy is utilized for determining the best thresholds for optimizing discriminant power of the resultant descriptor. Accumulating stability renders a real-valued descriptor and it can be converted into a binary descriptor by an additional thresholding. The real-valued descriptor attains high matching accuracy while the binary descriptor makes a good compromise between storage and accuracy. Our descriptors are simple yet effective, and also very easy to implement. In addition, our descriptors require no training. Experiments on popular benchmark demonstrate the effectiveness of our descriptors and superiority to the state-of-the-art descriptors.


ASV framework


Figure 2. Two-stage thresholding.



Figure 3. Head-to-head comparisons.

Paper

https://drive.google.com/open?id=0B_q2Q4O-rzP6bmlxTzFyMGJfaWs

Poster

https://drive.google.com/file/d/0B_q2Q4O-rzP6aTVFTGJqRkVJZVU/view?usp=sharing

Code

Github
https://github.com/shamangary/ASV
(I suggest you run the Oxford dataset first since the number of the image pairs are 40 while Fischer dataset contains 400 pairs.)

Folder arrangement:
unzipped folder----------Oxford
         |
         ------Fischer
         |
         ------vlfeat-0.9.18
         |
         ------README.md
         |
         ------LICENSE

2015 AI final project 行人偵測

| Comments

2015 AI Final project分配: 楊存毅

  1. Deep leaning for pedestrian detection:許洸睿
  2. Head pose detection:余鑑桓
  3. Connection between every program:蘇建今
  4. Phone UI and demo and system optimization:楊存毅

目的:我們希望用手機的相機模擬行車上的相機,藉由上傳手機的影像到各種server,可以即時達到不同的目的來偵測危險,行人偵測和頭部角度偵測主要是來判斷人的危險程度。整個系統希望是real time的,上傳的只有圖片,傳回來的值希望是偵測到的長方形,還有頭部的角度,互相溝通的方法要簡單易懂讓大家都能迅速接軌,最後通通結果顯示在手機上。最後poster的時候希望能夠把手機直接demo給大家看。

https://github.com/Likisee/AI2015_TERM_PROJECT

LogoMatch Presentation

| Comments

我們使用ORB feature matching和SCSM作為rank的基準,這個系統完全實作在手機上,對於user可以高度自定化,但是時間對於dataset的大小是線性成長,若是想要完全實作在手機上,開啟程式時在手機的記憶體儲存hash table可能也會耗費時間,這可能是想用單純的手機實作的問題。

Android讀取外部sdcard圖片

| Comments

參考 http://android-deve.blogspot.tw/2012/11/file-access.html

在預設的情況下,App 具有讀取 (沒有寫入) 外部儲存體的權限,不過這個權限在未來的 Android 版本可能會做調整,因此,若 App 有讀取外部儲存體的需求,最好還是在 AndroidManifest.xml 檔案中宣告 READ_EXTERNAL_STORAGE 的權限會比較保險

加在AndroidManifest.xml
<uses-permission 
     android:name="android.permission.READ_EXTERNAL_STORAGE" />

好像在Kitkat後之後就必須要加這行權限允許。

然後我在其他.java檔把圖片讀取成Mat檔

ComputeFeature.java之中
String imageFile = "/sdcard/LogoMatch/1.jpg";
Mat datasetImg = Highgui.imread(imageFile);

Android上使用Opencv manager的注意事項

| Comments

為了方便起見,我們想在一個package中放兩個.java檔就好,

一個是負責Android介面的(稱為MainActivity.java),另一個是負責feature matching的(稱為ComputeFeature.java),

概念上是在MainActivity.java的部份我們"盡量"不使用opencv的東西,只傳遞拍照後的結果到ComputeFeature.java,

之後再由ComputeFeature.java擷取出ORB特徵,然後再去執行和template logo dataset的ORB feature matching,

但是因為我們必須使用到Opencv manager,所以我們必須在MainActivity.java就讀取所謂的opencv manager才可以,

讀取好了之後,ComputeFeature.java就不用再讀取一次,但是兩個.java檔都要記得import一些有的沒有的東西喔(opencv和android都要)。

方法其實很單純(但也讓我搞了很久...),只需要在MainActivity下輸入下面的code就可以了

為了啟用opencv manager所需加入的code

MainActivity.java
public class MainActivity extends Activity {

  
  
  //------------------------------------------------------------------------------
  //注意要先load opencv,別忘了onResume的部份
    private static final String TAG = "OCVSample::Activity";
    private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
        @Override
        public void onManagerConnected(int status) {
            switch (status) {
            case LoaderCallbackInterface.SUCCESS: {
                Log.i(TAG, "OpenCV loaded successfully");
            }
                break;
            default: {
                super.onManagerConnected(status);
            }
                break;
            }
        }
    };
  
  @Override
    public void onResume()
    {
        super.onResume();
        //注意要先load opencv
        OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_7, this, mLoaderCallback);
    }
  //------------------------------------------------------------------------------
    
    
    
    
    ...}

Mobile real time logo detection and recognition using ORB feature

| Comments

NTU MMAI 2014 final project
D03922016 楊存毅 D03922003 許洸睿

Motivation
Logo is very common in every social media or real world product. If we can take a picture of the logo by our smartphone and retrieve the information of the logo on the internet, we can determine whether to buy the product or not. Since the contaminated food problem is become more and more serious in Taiwan, we want to build a mobile system to recognize these products and avoid to buy them.

Implementation
We try to build a real time logo detection and recognition system. The feature we choose is ORB feature [1] which is fast and rotation invariant. We have online and offline process.
1. Offline: Collect our template logo dataset for the recognition system. We save the ORB features of each template logo set on the phone. We also collect the information of the logo from the internet, and define the rate of unscrupulousness (RU) for the logo.
2. Online: Take a picture by your phone from the real world. We extract the ORB feature from the picture you just take and match with each template logo set. After that, we adopt spatial verification step using SCSM [2] and remove the outlier correspondences. Not only we can know the best match template logo type, but also we can localize the location of the logo from the picture you take. If the logo is retrieved, the system will show the logo picture and RU for the logo.

Framework

Reference
[1] ORB: an efficient alternative to SIFT or SURF https://willowgarage.com/sites/default/files/orb_final.pdf
[2] Object retrieval and localization with spatially-constrained similarity measure and k-NN re-ranking http://www.eng.tau.ac.il/~avidan/papers/SCSMKNN_CVPR12.pdf
[3] OpenCV学习笔记[5]FLANN特征匹配 http://blog.csdn.net/shuzhe66/article/details/40824883

Hello World

| Comments

Hi, This a demo post of Logdown.

Logdown use Markdown as main syntax, you can find more example by reading this document on Wikipedia

Logdown also support drag & drop image uploading. The picture syntax is like this:

Bloging with code snippet:

inline code

Plain Code

puts "Hello World!"

Code with Language

puts "Hello World!"

Code with Title

hello_world.rb
puts "Hello World!"

MathJax Example

Mathjax

Inline Mathjax

The answser is .

Table Example

Tables Are Cool
col 1 Hello $1600
col 2 Hello $12
col 3 Hello $1