LeeCreation! Media & Robot  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'전체보기'에 해당하는 글(749)
2017.01.24   utf-8 <-> CString
2017.01.24   JAVA, Eclipse 설치
2017.01.14   Google Cloud Vision 윈도우에서 사용하기 (얼굴 감지 위주)
2016.11.01   matplotlib 설치 (python3)
2016.10.31   Tensorflow Installation


utf-8 <-> CString

utf-8 (char*) -> CString



CString -> utf-8 (char*) 이건 코드가 너무 없더라 ㅠㅠ 고생 좀 했음





JAVA, Eclipse 설치

자바 다운로드 링크: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html


JAVA 설치 과정 설명: http://blog.naver.com/rrhcrudns/220877641911


Eclipse 설치 과정 설명: http://blog.naver.com/siren258/220398165589


Eclipse 한글 설정: http://blog.naver.com/cyon24/220908573304


+ 한글 UTF-8 설정 (한글 UTF-8 설정을 위해, project -> preference -> resource -> text and encoding -> others -> UTF-8 선택)


Eclipse neon에서는 위 설정만 해줘도 그냥 바로 한글 텍스트 사용이 가능했다.


라이브러리 추가 방법: http://mainia.tistory.com/2273





Google Cloud Vision 윈도우에서 사용하기 (얼굴 감지 위주)

환경:

- Windows 7 64bits

- Python 3.4

(당연한 말이지만 python 윈도우 환경 변수 설정도 필요하다. 다음 링크의 초반부 확인: http://leestation.tistory.com/750)

- 얼굴 감지 (및 약간의 감정, 몇몇 위치 정보 등의 추가 정보) 위주로 설명. Cloud Vision의 다른 기능 활용도 비슷할듯.



- 공식 문서: https://cloud.google.com/vision/docs/


목차

1) 구글 Cloud Vision 사용 자격증 받기

2) 필요 자료 설치 및 코드 실행



1) 구글 Cloud Vision 사용 자격증 받기

- 사실 이 과정이 은근(?) 귀찮다.


- https://cloud.google.com/vision/docs/quickstart

- 위 링크에서 프로젝트 생성, 결제 방법 실행(무료 사용을 원해도 일단 결제가 되는 수단인지 확인하기 위해 결제가 되었다가 취소되는 과정이 있다.), API 활성화를 한다.


- 공식 설명: https://cloud.google.com/vision/docs/common/auth

- 한글 블로그: http://www.hardcopyworld.com/ngine/aduino/index.php/archives/2736

- 위 참고링크를 그대로 따라 .json 파일을 다운 받는다.

- 환경변수에 GOOGLE_APPLICATION_CREDENTIALS을 [파일 위치][이름].json으로 설정 

(환경 변수 중에서 system variables에 추가했다.)

(리눅스였다면 $ export GOOGLE_APPLICATION_CREDENTIALS=[파일 위치][이름].json 실행이면 될 것을 윈도우니까 다른 작업이 필요한 것)

(setx 명령으로 cmd 창에서 할 수도 있을듯..)



2) 필요 자료 설치 및 코드 실행

https://cloud.google.com/vision/docs/face-tutorial

- 걍 위 그대로 수행


- 그래도 우리 말로 한 번 정리하면...

- 파이선 설치

- pip 설치 https://pip.pypa.io/en/latest/installing/

- Google API Python client 설치

pip install --upgrade google-api-python-client

- Python Imaging Library 설치

pip install Pillow

(공식 깃허브 페이지에서 샘플 코드를 받으면 설치하는 게 자동으로 될 거라는데 난 그냥 샘플 코드 받아서 안하고 위 과정으로 설치했음)


- 작업할 위치에 [파일이름].py 파일 하나 만들고 앞서 링크에 설명된 코드들을 다 포함시킨다. import 하는 애들 빼먹지 말고..

- Create the Service Object (자격증 받아오는 코드)

- Send a Face Detection Request (사진 보내고 결과 받아오는 코드)

- Process the Response (결과 사진 얼굴 위치에 박스 그려주는 식의 코드, 필수는 아님)

- Put It All Together (수행될 코드)


- python에서 코드를 수행시키려면

import faces

faces.main("사진위치\이름.jpg", "출력할사진위치\이름.jpg", 검출될얼굴의최대수)

위와 같이 수행시키면 된다.


위 코드에서는 얼굴 정보 결과를 따로 출력하지는 않는다.

코드 상에서 faces라는 애가 사진의 annotation 정보를 갖고 있으니

print('headwear: {}'.format(face['headwearLikelihood']))

위와 같이 보고 싶은 내용을 출력시켜서 보면 된다.


JSON 파일 형태로 저장도 할 수 있을텐데 아직 거기까지는 안 해봤다.

Annotation에 어떤 정보들이 들어있는지 알고 싶다면, 아래 링크 확인

https://cloud.google.com/vision/reference/rest/v1/images/annotate



matplotlib 설치 (python3)

ubuntu 14.04, python3.4.3


python3에 matplotlib를 설치하는데 애를 좀 먹었다.


기본적으로 다음 링크에 따라서 진행했다. python3에 맞도록..

http://matplotlib.org/faq/installing_faq.html


git clone git://github.com/matplotlib/matplotlib.git
> cd matplotlib
> python3 setup.py install
> python3 setup.py develop
> git pull


그런데 설치 후 파이선을 실행하여 matplotlib.pyplot을 import하려면 꼭 다음과 같은 에러가 났다.


"The Gtk3Agg backend is known to not work on Python 3.x with pycairo."


찾아보니 아래 링크에 솔루션이 있었고

http://stackoverflow.com/questions/33329921/plots-are-not-visible-using-matplotlib-plt-show


sudo apt-get install python3-dev
sudo apt-get install libffi-dev

위 동작 수행 후에


pip3 install cairocffi

위 명령으로 cairocffi를 설치하고 나니


python3에서 문제 없이 matplotlib.pyplot이 import되었다.



Tensorflow Installation

My computuer specifications

- ubuntu 14.04

- 64bit CPU (Intel i7)

- GPU (NVIDIA gtx960)



- python3.4

- cuda toolkit 8.0

- cudnn 5.1

- pip installation method
- gpu enabled version of Tensorflow




Tensorflow download and setup official website

https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html





1) Cuda installation (GPU use only)

https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#optional-install-cuda-gpus-on-linux


- To install cuda, we need to turn off x service.

ctrl + alt + f1 (Swtich to a console mode)

$ sudo stop lightdm (x service off and no loger GUI use)

$ sudo lightdm (will turn on the GUI use again)


- If the console mode is just a blank screen, refer following link. (matter of monitor resolution)

http://askubuntu.com/questions/162535/why-does-switching-to-the-tty-give-me-a-blank-screen

$ sudo sed -i -e 's/#GRUB_TERMINAL/GRUB_TERMINAL/g' /etc/default/grub

$ sudo update-grub

$ sudo reboot


- If the GUI appear not properly after reboot, just switch screen ctrl + alt + f1 and turn back (ctrl + alt + f7).


- cuda toolkit 8.0

https://developer.nvidia.com/cuda-downloads

(the link takes us to the website for the newest version of cuda)

linux, x86_64, ubuntu, 14.04, dev(local)

Move to the folder where the file is downloaded.

$ sudo dpkg -i cuda-repo-ubuntu1404-8-0-local_8.0.44-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get install cuda

This autometically creates a folder e.g. /usr/local/cuda-8.0/

and also creates /usr/local/cuda/ which directs above folder so that we can also consider the cuda toolkit is installed in /usr/local/cuda/ as well.


- cudnn 5.1

https://developer.nvidia.com/cudnn

To download files, registration is needed.

Download cuDNN v5.1, for CUDA 8.0, cuDNN v5.1 Library for Linux

Move to the folder where the file is downloaded.

$ tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz
$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*






2) Tensorflow Installation

I followed 'pip install'

https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#pip-installation


pip preparation

$ sudo apt-get install python3-pip python3-dev (for python 3.4)


# Ubuntu/Linux 64-bit, GPU enabled, Python 3.4
# Requires CUDA toolkit 8.0 and CuDNN v5. For other versions, see "Install from sources" below.
$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc2-cp34-cp34m-linux_x86_64.whl


$ sudo pip3 install --upgrade $TF_BINARY_URL


- to update

first, delete previous tensorflow

$ sudo pip3 uninstall tensorflow

and follow the installation flow again.






3) Installation Test

https://www.tensorflow.org/versions/r0.11/get_started/os_setup.html#test-the-tensorflow-installation


Before running python3

$ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
$ export CUDA_HOME=/usr/local/cuda


- if "Couldn't open CUDA library libcudnn.so. LD_LIBRARY_PATH" error appears, check the version of cuda toolkit and cudnn; and make sure that the version of tensorflow installed is correct.








etc.) Tensorflow study materials



한국말로 설명된 설치법 (아나콘다 환경 등등을 고려한 설치)

http://yeramee.tistory.com/1


Basic of tensorflow

http://learningtensorflow.com/


한글자료

https://gist.github.com/haje01/202ac276bace4b25dd3f


최성준님의 강의자료

https://github.com/sjchoi86/Tensorflow-101



BLOG main image
미디어와 로봇에 관심이 많은 아이 그 영역을 넓혀보려 합니다. '영상 제작'과 '감정 로봇'이 블로그의 주소재입니다. 자유로운 답글 환영합니다!
 Notice
 Category
전체보기 (749)
내가 사랑하는 MJ (0)
아이가 생긴다면 (4)
Media (98)
Robot (447)
타인과 약자를 위한 (81)
Etc. (118)
 TAGS
연구
 Calendar
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
 Recent Entries
 Recent Comments
 Recent Trackbacks
 Archive
 Link Site
LeeCreation! Media & Robot
 Visitor Statistics
Total :
Today :
Yesterday :
rss