SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
第1回次世代脳型人工知能研究会
深層学習チュートリアル
「ChainerCVとOpenCVではじめる物体検出」
のための事前準備
国立研究開発法人 情報通信研究機構
脳情報通信融合研究センター
篠崎隆志
あらまし
• 2017年9月19日に開催される第1回 次世代脳型人
工知能研究会での深層学習チュートリアル
「ChainerCVとOpenCVではじめる物体検出」に
参加するにあたっての準備の説明です
• チュートリアルでは学習済みのFasterRCNNの転
移学習で、目的とする対象の物体検出を実現す
るための手法を解説します
• 大きなファイルのダウンロードが多数あるので、
セットアップは事前に行っておいてください
必要な環境
• WindowsもしくはMacのノートPC
• CPUのみを使うため、NVIDIAのGPUを搭載する
必要はありません。
• Linuxの場合の環境構築はおまかせします
• virtualenvの利用をお勧めします
• ウェブカメラ
• 最近のノートPCであれば標準でついています
• ついていない場合は別途ご用意ください
• 少数であれば用意できますのでご相談下さい
作業の流れ
• Pythonのインストール
• コンパイラのインストール
• Pythonのパッケージのインストール
• OpenCVのインストール
• Chainerのインストール
• ChainerCVのインストール
• tqdmのインストール
• その他
Pythonのインストール
• Continuum	Analytics社製のAnacondaを利用
• https://www.continuum.io/downloads
• Python	2.7	versionを選択
• 実行にはSpyderを利用
• Pythonのための(matlabのような)総合開発環境
• Windowsの場合はスタートメニュー →	
Anaconda2	→	Spyder を実行
• Macの場合はターミナルから以下を実行
• spyder &
Jupyter QTConsole
• Spyderのコンソール部分
• Windowsの場合はスタートメニュー →	
Anaconda2	→	Jupyter QTConsole を実行
• Macの場合はターミナルから以下を実行
• jupyter qtconsole &
• ここでは省略してJupyterと呼びます
• インストール後のチェックなどに使います
コンパイラのインストール
• Windowsの場合
• Visual	C++	Compiler	for	Python	2.7をインストール
• http://www.microsoft.com/en-
us/download/details.aspx?id=44266
• stdint.hを追加でインストール
• https://github.com/mattn/gntp-
send/blob/master/include/msinttypes/stdint.h
• 以下のディレクトリにコピー
• %USERPROFILE%¥AppData¥Local¥Programs¥Common¥Micros
oft¥Visual C++ for Python¥9.0¥VC¥include
• Macの場合
• App	StoreからXcodeをインストール
OpenCVのインストール
• Anacondaのパッケージ管理ツールcondaを利用
• Windowsの場合はスタートメニュー →	Anaconda	
→	Anaconda	Promptを起動
• Macの場合はターミナルを起動
• 以下のコマンドを実行
• conda install –c menpo opencv
• (エラーの場合は LANG=en_US.UTF-8 conda install
–c menpo opencv で試してみて下さい)
• インストール後、Jupyterから
import cv2 を実行してエラーがでないかを確認
Chainerのインストール
• Python標準のパッケージ管理ツールpipを利用
• Windowsの場合はスタートメニュー →	Anaconda	
→	Anaconda	Promptを起動
• Macの場合はターミナルを起動
• 以下のコマンドを実行
• pip install chainer
• インストール後、Jupyterから
import chainer を実行してエラーがでないか確認
ChainerCVのインストール
• Chainerと同様にpipでインストール
• 以下のコマンドを実行
• pip install chainercv
• インストール後、Jupyterから以下の2行を実行
し、学習済みモデルをダウンロード
• from chainercv.links import FasterRCNNVGG16
FasterRCNNVGG16(20, 'voc07')
• 20分ほどかかります
• 1回ダウンロードするとキャッシュされ、次回
からはダウンロードせずに使えます
ChainerCVのテスト
• Gitからサンプルスクリプトがダウンロード可能
• https://raw.githubusercontent.com/chainer/ch
ainercv/master/examples/faster_rcnn/demo.py
• サンプル画像もダウンロード可能
• https://cloud.githubusercontent.com/assets/2
062128/26187667/9cb236da-3bd5-11e7-8bcf-
7dbd4302e2dc.jpg
• Jupyterから「run demo.py 画像.jpg」
• run demo.py 9cb236da-3bd5-11e7-8bcf-7dbd4302e2dc.jpg
• お好きな画像を試してみて下さい
tqdmのインストール
• 便利で使いやすい進捗表示バー
• 自前での学習の進捗表示などで便利
• condaでインストール
• WindowsではAnaconda	Prompt、Macではターミナ
ルから以下を実行
• conda install tqdm
• (エラーの場合は LANG=en_US.UTF-8 conda install
tqdm で試してみて下さい)
その他
Proxyの設定
• condaでの設定
• Windowsでは「%USERPROFILE%¥.condarc」
• Macでは「$HOME/.condarc」
• 以下の記述を追加
• proxy_servers:
http: http://proxy.hoge.net:8080
https: https://proxy.hoge.net:8080
• pipでの設定
• pip install -–proxy=proxy.hoge.net:8080 tqdm
JupyterでのPythonの設定
• Jupyter QTConsoleで以下を実行
• get_ipython().profile_dir.location
• 出力された場所の「startup」ディレクトリにて
• 適当なファイル(50-mystartup.py など)を作成
• 以下の内容を記述
• import numpy as np
import matplotlib.pyplot as plt
• 起動の度のimportが不要に
Jupyterでの表示の設定
• まず設定ファイルが必要
• ターミナルから以下を実行
• 「jupyter qtconsole –-generate-config」
• 「.jupyter/jupyter_qtconsole_config.py」が生成
• 生成されたファイルを編集
• フォント変更
• 「c.ConsoleWidget.font_family = ‘Times New
Roman’」
• フォントサイズ変更
• 「c.ConsoleWidget.font_size = 12」
Anacondaのアップデート
• WindowsではAnaconda	Prompt、Macではターミ
ナルから以下を実行
• パッケージ管理ツールの更新
• conda update conda
• Anaconda自体の更新
• conda update anaconda
• condaは他にもpythonバージョンやvirtualenvのよ
うな環境の切り替えも可能
Anacondaでの環境の切り替え
• すでにPython	3.6	versionなどが入っている時に
Python	2.7	versionの環境を構築
• conda create –n py27 python=2.7 anaconda
• 環境の切り替え
• Windowsの場合:	スタートメニューで (py27)と
表示のある項目(Anaconda	Prompt等)を利用
• Macの場合:		以下のコマンドを実行後にそれぞ
れのコマンド(conda,	pip,	spyder等)を利用
• source activate py27
Chainerのアップデート
• Chainerのバージョンは2系列を想定
• バージョン1系列から多数の変更
• https://docs.chainer.org/en/stable/upgrade.html
• WindowsではAnaconda	Prompt、Macではターミナル
から以下を実行
• pip uninstall chainer
pip install chainer
• 一度アンインストールした方が安全

Weitere ähnliche Inhalte

Empfohlen

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

「ChainerCVとOpenCVではじめる物体検出」のための事前準備