LoginSignup
5
8

More than 5 years have passed since last update.

[Tensorflowを使って画像を分類したい ](1)環境を作ろう

Posted at

はじめに

HDD内に大量にあふれた画像ファイルを整理したいけど、数万枚にのファイルを手動で整理はしたくないと友人に相談したら「プログラム作れよ。ほら、AIとかディープラーニングとやらを使えばいいんじゃね。」と貴重なアドバイスをもらったのでやってみることにした。
友人よ…ディープラーニングってなんだよ…。インフラ屋さんだからプログラムは畑違いなんだよ…。

ディープラーニングってなに?何ができるの?

まずはQiitaで検索してみて予備知識を仕込む。
ディープラーニング≒機械学習なのか。
なるほどわからん…。機械学習って何さ…。
この辺を見て勉強するか。

機械学習はじめの一歩に役立つ記事のまとめ
DNN(ディープラーニング)ライブラリ : chainerとTensorFlowの比較 (1)
各機械学習ライブラリの比較をまとめる

TensorFlowを使うことにする

どのライブラリを使うかを選ばないといけない。
色々わからない。違いもわからない

Qiitaの投稿数を比較
よし、とりあえず技術ドキュメントの多いTensorFlowを使おう

(2016/08/21現在)

ライブラリ名 件数
TensorFlow 339
Chainer 205
Caffe 56

環境を準備する

さすがQiita。知りたいことが出てくる。
UbuntuにTensorFlowをインストール

何度も使いそうなので、vagrantで作ることにした。
検証環境はWindows10 + Vritualbox + Vagrant
仮想マシンはUbuntu14.04

[Vagrantfile]

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|

  config.cache.scope = :box

  config.vm.define :TensorFlow do |node|
    node.cache.scope = :box
    node.vm.box = "ubuntu/trusty64"
    node.vm.hostname = "TensorFlow"
    #node.vm.network :forwarded_port, guest: 22, host: 2001, id: "ssh"
    node.vm.network :private_network, ip: "192.168.33.40"
    node.vm.provider "virtualbox" do |vb|
     # Customize the amount of memory on the VM:
     vb.memory = "4096"
     vb.gui = false
     vb.cpus = "2"
    end    
    node.vm.provision "shell", inline: <<-SHELL
      sudo apt-get update
      sudo apt-get install -y wget curl git vim libxml2-dev libxslt1-dev 
      sudo apt-get install -y python-pip python-dev python-virtualenv
      sudo apt-get install -y build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev python-pip libcairomm-1.0-1 libjson-glib-1.0-0
      mkdir tensorflow
      virtualenv --system-site-packages ~/tensorflow
      cd ~/tensorflow
      source bin/activate
      pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl

    SHELL
  end
end

vagrant upで仮想マシン起動


E:\vagrant\TensorFlow>vagrant up

Vagrantで作った環境へログインし
TensorFlowを入れたvirtualenvをactivateする


root@tensorflow:~#
root@tensorflow:~# source tensorflow/bin/activate
(tensorflow)root@tensorflow:~#

今回はここまで。

5
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
8