Mais conteúdo relacionado Semelhante a Jubatus Casual Talks #2: 大量映像・画像のための異常値検知とクラス分類 (20) Jubatus Casual Talks #2: 大量映像・画像のための異常値検知とクラス分類2. 自己紹介
• 小川 宏高
• Twitter ID: @ogawa
• 所属: 産総研 / AIST
• 専門
• 大規模データ処理
• 並列分散処理
• クラウド技術、グリッド技術
• JavaのJust-in-timeコンパイラ
• 最近オープンデータとか言わされて
結構困っているらしい
画像はイメージです。
5. Jubatus+AIST: custom_types拡張
• センサや応用のバラエティをサポートするためのインタフェース拡
張
• fv_converterに対する魔改造
• RAWデータの支援
• データに対する「前処理」を含めてJubatusのモジュールとして実行
• 他言語向け外部インタフェースの支援
• センサデータに対する前処理、特徴抽出を外部サーバにオフロード
• 応用エンジニアは、外部サーバ用の前処理モジュールをPython, Ruby,
Java等で記述可能
多値分類・線形回帰・異常値検知等
特徴抽出M
特徴抽出M
特徴抽出M
特徴抽出
特徴抽出RPC
前処理M
前処理M
前処理M
前処理
特徴抽出
前処理RPC
Javaコンテナ
Pythonコンテナ
Rubyコンテナ
外部RPCサーバ
構造データ
RAWデータ
RAWデータ
6. custom_typesで動的ライブラリを呼
ぶ
{
"converter" : {
"string_filter_types" : {},
"string_filter_rules" : [],
"num_filter_types" : {
},
"num_filter_rules" : [],
"custom_filter_types" : {
"custom": {
"method": "dynamic",
"path": "/Users/foo/libcustom_filter.dylib",
"function": "create",
"alpha": "0.01",
"beta": "0.03",
"gamma": "0.05"
}
},
"custom_filter_rules" : [
{ "key" : "*", "type" : "custom", "suffix": "-dummy" }
],
"string_rules" : [
{ "key" : "*", "type" : "str", "sample_weight" :
"bin", "global_weight" : "bin" }
],
"num_types" : {},
"num_rules" : [
{ "key" : "a*", "type" : "num" }
],
"custom_types" : {},
"custom_rules" : [
]
},
"parameter" : {
"nearest_neighbor_num" : 10,
"reverse_nearest_neighbor_num" : 30,
"method" : "euclid_lsh",
"parameter" : {
"lsh_num" : 64,
"table_num" : 4,
"seed" : 1091,
"probe_num" : 64,
"bin_width" : 100,
"retain_projection" : false
}
},
"method" : "lof"
}
8. custom_typesで外部モジュールを呼ぶ
{
"converter" : {
"string_filter_types": {},
"string_filter_rules":[],
"num_filter_types": {},
"num_filter_rules": [],
"custom_filter_types" : {},
"custom_filter_rules" : [],
"string_types": {},
"string_rules":[],
"num_types": {},
"num_rules": [
{"key" : "*", "type" : "num"}
],
"custom_types" : {
"word_count": {
"method": "external",
"hostname": "localhost",
"port": "18800",
"timeout": "30.0"
}
},
"custom_rules" : [
{ "key" : "*", "type" : "word_count" }
]
},
"parameter" : {
"hash_num" : 64,
"table_num" : 4,
"seed" : 1091,
"probe_num" : 64,
"bin_width" : 100,
"retain_projection" : false
},
"method": "euclid_lsh"
}
9. string_typesをPythonで変換
import msgpackrpc
import re
word = re.compile('S+')
class WordSplitterServer(object):
# TODO: string encoding?
def split(self, value):
s=0
value = value.decode()
result = []
while s < len(value):
m = word.search(value, s)
if m is None:
break
result.append( (m.start(), m.end() - m.start()) )
s = m.end()
return result
if __name__ == '__main__':
(snipped)
10. string_typesで外部モジュールを呼ぶ
{
"converter" : {
"string_filter_types": {},
"string_filter_rules":[],
"num_filter_types": {},
"num_filter_rules": [],
"custom_filter_types" : {},
"custom_filter_rules" : [],
"string_types": {
"splitter": {
"method": "external",
"hostname": "localhost",
"port": "18800",
"timeout": "30.0"
}
},
"string_rules":[
{"key" : "*", "type" : "splitter",
"sample_weight":"tf", "global_weight" : "bin"}
],
"num_types": {},
"num_rules": [
{"key" : "*", "type" : "num"}
],
"custom_types" : {},
"custom_rules" : [ ]
},
"parameter" : {
"hash_num" : 64,
"table_num" : 4,
"seed" : 1091,
"probe_num" : 64,
"bin_width" : 100,
"retain_projection" : false
},
"method": "euclid_lsh"
}
12. Jubatus+AIST: メディアデータの特徴抽
出
• OpenCVの提供する特徴抽出器を用いた特徴抽出
• 誰でもやってる
• BoVW4J: Bag of Visual Words for Jubatus
• Spatial Pyramid Method (SPM)、ScSPM
• LLC: Locality-constrained Linear Coding for Image Classification
(CVPR ’10) 等の手法を参考に実装
• AIST謹製手法を用いた特徴抽出
• 高次局所自己相関特徴法(HLAC)
• (X, Y) 空間における相関パタンの出現頻度を特徴として使用
• 立体高次局所自己相関特徴法(CHLAC)
• (X, Y, t) 空間における相関パタンの出現頻度を特徴として使用
• 音響情報に対する特徴抽出
• FLAC
• (Mel-Freq, t) 空間における相関パタンの出現頻度を特徴として使用
16. レスポンス時間
• add (学習+検知)
• 1フレーム学習するのに要する時間
• calc_score (検知)
• 1,000フレーム学習した状態で、1
フレームの検知に要する時間
• 前処理・特徴抽出
• クライアント側で実施
• サーバ側(custom_types)で実施
•
80"
calc_score
– レスポンス時間8〜10msec
– 100〜125FPSで動画像の前処理、
特徴抽出、外れ値検知のリアルタイ
ム処理を行うだけの処理能力がある
70"
60"
50"
•
40"
add
– 学習したデータ数にほぼ比例した処
理時間
– 検知は高速であることから学習自体
に時間を要することが分かる
30"
20"
10"
•
0"
0"
100"
200"
learning"
300"
400"
500"
learning"(plugin)"
600"
700"
detec: on"
800"
900" 1000"
detec: on"(plugin)"
custom_typesのオーバーヘッド
– 平均1〜2msec
18. レスポンス時間に関する考察 (続き)
• JubatusのLOFの実装
• nn_engine->decode_row()
• すでに登録された点かどうかの判定
• nn_engine->update_row()
• 対象点をLSH (Locality Sensitive Hash)に格納
• collect_neighbors(1)
• LSHから対象点の擬似近傍点を取得
• collect_neighbors(2)
• LSHから擬似近傍点の擬似近傍点を取得
• update_kdist_with_neighbors()
• k距離の計算
• update_lrd_with_neighbors()
• LRD (Local Reachability Density)の計算
• 擬似近傍点をn個取得
⇒LSHの中で擬似近傍点の候補を対象点のハッシュ値から求め、それらを対象
点との距離でソートし、近いものからn個選択
• ハッシュ値が同じ点が非常に多い場合、時間を要する
• 実際、動きの少ない動画像で試したところ、10,000フレーム分追加した時点で7,041
フレームが同一のハッシュ値