본문 바로가기

Programming/python

python 기계학습 모듈 설치

파이썬 기계학습, 이미지 분석, 검출을 위한 준비

1. Python 3.x
a. Python 설치
b. Pip 설치 (python 설치 이후 pip 설치하라는 안내문구 출력됨)
c. Pip upgrade
i. Pip 업그레이드가 필요한경우 업그레이드 진행하라는 안내문구 및 명령어 출력됨.
2. Jupiter notebook 설치
a. Miniconda 설치 후 사용 또는 vsCode 사용
b. 주의 : anaconda를 설치해도 상관 없으나, 용량이 굉장히 많편
c. 추천 : vsCode 설치 후 python 실행
Jupiter notebook 실행 가능

3. 필요한 모듈(dependencies)
이미지 전처리 관련
a. Opencv
b. Os
c. Glob
d. Numpy
e. Matplotlib
f. Skimage

기계학습관련
g. Opencv
h. Os
i. Glob
j. Numpy
k. Matplotlib
l. Keras
m. Skimage
n. tensorflow

4. 모듈설치
설치 기본 명령어 예시
Pip3 install {모듈 이름}

a. openCV
i. 명령어
Pip3 install opencv-python
b. 결과 예시
E:\파일\Research\High resolution\super_resolution-master>pip3 install opencv-python
Collecting opencv-python
Downloading opencv_python-4.2.0.34-cp38-cp38-win_amd64.whl (33.1 MB)
|████████████████████████████████| 33.1 MB 52 kB/s
Collecting numpy>=1.17.3
Downloading numpy-1.18.4-cp38-cp38-win_amd64.whl (12.8 MB)
|████████████████████████████████| 12.8 MB 61 kB/s
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.18.4 opencv-python-4.2.0.34
iii. Opencv, numpy 설치 완료

b. Matplotlib
i. 명령어
pip3 install matplotlib
b. 결과 예시
Collecting matplotlib
Downloading matplotlib-3.2.1-cp38-cp38-win_amd64.whl (9.2 MB)
|████████████████████████████████| 9.2 MB 1.1 MB/s
Requirement already satisfied: numpy>=1.11 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from matplotlib) (1.18.4)
Collecting kiwisolver>=1.0.1
Downloading kiwisolver-1.2.0-cp38-none-win_amd64.whl (58 kB)
|████████████████████████████████| 58 kB 4.1 MB/s
Collecting cycler>=0.10
Using cached cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: six in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from cycler>=0.10->matplotlib) (1.14.0)
Could not build wheels for numpy, since package 'wheel' is not installed.
Could not build wheels for python-dateutil, since package 'wheel' is not installed.
Could not build wheels for pyparsing, since package 'wheel' is not installed.
Could not build wheels for six, since package 'wheel' is not installed.
Installing collected packages: kiwisolver, cycler, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.2.0 matplotlib-3.2.1
iii. Matplotlib 설치 완료

c. Skimage
i. 명령어
Pip3 install scikit-image
'Pip3 install skimage' 입력시 오류
b. 결과 예시
E:\ 파일\Research\High resolution\super_resolution-master>pip3 install scikit-image
Collecting scikit-image
Downloading scikit_image-0.17.2-cp38-cp38-win_amd64.whl (11.7 MB)
|████████████████████████████████| 11.7 MB 72 kB/s
Collecting networkx>=2.0
Using cached networkx-2.4-py3-none-any.whl (1.6 MB)
Collecting PyWavelets>=1.1.1
Downloading PyWavelets-1.1.1-cp38-cp38-win_amd64.whl (4.3 MB)
|████████████████████████████████| 4.3 MB 234 kB/s
Requirement already satisfied: matplotlib!=3.0.0,>=2.0.0 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from scikit-image) (3.2.1)
Requirement already satisfied: numpy>=1.15.1 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from scikit-image) (1.18.4)
Collecting scipy>=1.0.1
Downloading scipy-1.4.1-cp38-cp38-win_amd64.whl (31.0 MB)
|████████████████████████████████| 31.0 MB 1.7 MB/s
Collecting pillow!=7.1.0,!=7.1.1,>=4.3.0
Downloading Pillow-7.1.2-cp38-cp38-win_amd64.whl (2.0 MB)
|████████████████████████████████| 2.0 MB 2.2 MB/s
Collecting tifffile>=2019.7.26
Downloading tifffile-2020.5.11-py3-none-any.whl (132 kB)
|████████████████████████████████| 132 kB 2.2 MB/s
Collecting imageio>=2.3.0
Using cached imageio-2.8.0-py3-none-any.whl (3.3 MB)
Requirement already satisfied: decorator>=4.3.0 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from networkx>=2.0->scikit-image) (4.4.2)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image) (2.8.1)
Requirement already satisfied: cycler>=0.10 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image) (1.2.0)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image) (2.4.7)
Collecting imagecodecs>=2020.2.18
Downloading imagecodecs-2020.2.18-cp38-cp38-win_amd64.whl (5.2 MB)
|████████████████████████████████| 5.2 MB 1.1 MB/s
Requirement already satisfied: six>=1.5 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from python-dateutil>=2.1->matplotlib!=3.0.0,>=2.0.0->scikit-image) (1.14.0)
Could not build wheels for matplotlib, since package 'wheel' is not installed.
Could not build wheels for numpy, since package 'wheel' is not installed.
Could not build wheels for decorator, since package 'wheel' is not installed.
Could not build wheels for python-dateutil, since package 'wheel' is not installed.
Could not build wheels for cycler, since package 'wheel' is not installed.
Could not build wheels for kiwisolver, since package 'wheel' is not installed.
Could not build wheels for pyparsing, since package 'wheel' is not installed.
Could not build wheels for six, since package 'wheel' is not installed.
Installing collected packages: networkx, PyWavelets, scipy, pillow, imagecodecs, tifffile, imageio, scikit-image
Successfully installed PyWavelets-1.1.1 imagecodecs-2020.2.18 imageio-2.8.0 networkx-2.4 pillow-7.1.2 scikit-image-0.17.2 scipy-1.4.1 tifffile-2020.5.11

i. networkx, PyWavelets, scipy, pillow, imagecodecs, tifffile, imageio, scikit-image 설치 완료

iv. Keras
i. 명령어
Pip3 install keras
ii. 결과 예시
Collecting keras
Using cached Keras-2.3.1-py2.py3-none-any.whl (377 kB)
Collecting keras-applications>=1.0.6
Using cached Keras_Applications-1.0.8-py3-none-any.whl (50 kB)
Collecting pyyaml
Downloading PyYAML-5.3.1-cp38-cp38-win_amd64.whl (219 kB)
|████████████████████████████████| 219 kB 344 kB/s
Requirement already satisfied: six>=1.9.0 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from keras) (1.14.0)
Collecting keras-preprocessing>=1.0.5
Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 403 kB/s
Requirement already satisfied: scipy>=0.14 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from keras) (1.4.1)
Requirement already satisfied: numpy>=1.9.1 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from keras) (1.18.4)
Collecting h5py
Downloading h5py-2.10.0-cp38-cp38-win_amd64.whl (2.5 MB)
|████████████████████████████████| 2.5 MB 93 kB/s
Could not build wheels for six, since package 'wheel' is not installed.
Could not build wheels for scipy, since package 'wheel' is not installed.
Could not build wheels for numpy, since package 'wheel' is not installed.
Installing collected packages: h5py, keras-applications, pyyaml, keras-preprocessing, keras
Successfully installed h5py-2.10.0 keras-2.3.1 keras-applications-1.0.8 keras-preprocessing-1.1.2 pyyaml-5.3.1
iii. Keras 설치 완료

e. Tensorflow 설치
i. 명령어
Pip3 install tensorflow
b. 결과 예시
Collecting tensorflow
Downloading tensorflow-2.2.0-cp38-cp38-win_amd64.whl (459.2 MB)
|████████████████████████████████| 459.2 MB 36 kB/s
Collecting google-pasta>=0.1.8
Using cached google_pasta-0.2.0-py3-none-any.whl (57 kB)
Requirement already satisfied: keras-preprocessing>=1.1.0 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from tensorflow) (1.1.2)
Requirement already satisfied: numpy<2.0,>=1.16.0 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from tensorflow) (1.18.4)
Collecting protobuf>=3.8.0
Downloading protobuf-3.11.3-py2.py3-none-any.whl (434 kB)
|████████████████████████████████| 434 kB 6.4 MB/s
Collecting termcolor>=1.1.0
Using cached termcolor-1.1.0.tar.gz (3.9 kB)
Collecting opt-einsum>=2.3.2
Using cached opt_einsum-3.2.1-py3-none-any.whl (63 kB)
Requirement already satisfied: wrapt>=1.11.1 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from tensorflow) (1.12.1)
Collecting tensorflow-estimator<2.3.0,>=2.2.0
Using cached tensorflow_estimator-2.2.0-py2.py3-none-any.whl (454 kB)
Collecting grpcio>=1.8.6
Downloading grpcio-1.29.0-cp38-cp38-win_amd64.whl (2.4 MB)
|████████████████████████████████| 2.4 MB 1.6 MB/s
Collecting gast==0.3.3
Using cached gast-0.3.3-py2.py3-none-any.whl (9.7 kB)
Collecting absl-py>=0.7.0
Using cached absl-py-0.9.0.tar.gz (104 kB)
Collecting wheel>=0.26; python_version >= "3"
Using cached wheel-0.34.2-py2.py3-none-any.whl (26 kB)
Requirement already satisfied: scipy==1.4.1; python_version >= "3" in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from tensorflow) (1.4.1)
Collecting tensorboard<2.3.0,>=2.2.0
Using cached tensorboard-2.2.1-py3-none-any.whl (3.0 MB)
Requirement already satisfied: six>=1.12.0 in c:\users\jaehy\appdata\roaming\python\python38\site-packages (from tensorflow) (1.14.0)
Requirement already satisfied: h5py<2.11.0,>=2.10.0 in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from tensorflow) (2.10.0)
Collecting astunparse==1.6.3
Using cached astunparse-1.6.3-py2.py3-none-any.whl (12 kB)
Requirement already satisfied: setuptools in c:\users\jaehy\appdata\local\programs\python\python38\lib\site-packages (from protobuf>=3.8.0->tensorflow) (41.2.0)
Collecting google-auth-oauthlib<0.5,>=0.4.1
Using cached google_auth_oauthlib-0.4.1-py2.py3-none-any.whl (18 kB)
Collecting werkzeug>=0.11.15
Using cached Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
Collecting markdown>=2.6.8
Using cached Markdown-3.2.2-py3-none-any.whl (88 kB)
Collecting requests<3,>=2.21.0
Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Collecting google-auth<2,>=1.6.3
Downloading google_auth-1.14.3-py2.py3-none-any.whl (89 kB)
|████████████████████████████████| 89 kB ...
Collecting tensorboard-plugin-wit>=1.6.0
Using cached tensorboard_plugin_wit-1.6.0.post3-py3-none-any.whl (777 kB)
Collecting requests-oauthlib>=0.7.0
Using cached requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Using cached urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
Collecting chardet<4,>=3.0.2
Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting idna<3,>=2.5
Using cached idna-2.9-py2.py3-none-any.whl (58 kB)
Collecting certifi>=2017.4.17
Using cached certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
Collecting pyasn1-modules>=0.2.1
Using cached pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
Collecting rsa<4.1,>=3.1.4
Using cached rsa-4.0-py2.py3-none-any.whl (38 kB)
Collecting cachetools<5.0,>=2.0.0
Using cached cachetools-4.1.0-py3-none-any.whl (10 kB)
Collecting oauthlib>=3.0.0
Using cached oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
Collecting pyasn1<0.5.0,>=0.4.6
Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Could not build wheels for keras-preprocessing, since package 'wheel' is not installed.
Could not build wheels for numpy, since package 'wheel' is not installed.
Could not build wheels for termcolor, since package 'wheel' is not installed.
Could not build wheels for wrapt, since package 'wheel' is not installed.
Could not build wheels for absl-py, since package 'wheel' is not installed.
Could not build wheels for scipy, since package 'wheel' is not installed.
Could not build wheels for six, since package 'wheel' is not installed.
Could not build wheels for h5py, since package 'wheel' is not installed.
Could not build wheels for setuptools, since package 'wheel' is not installed.
Installing collected packages: google-pasta, protobuf, termcolor, opt-einsum, tensorflow-estimator, grpcio, gast, absl-py, wheel, pyasn1, pyasn1-modules, rsa, cachetools, google-auth, urllib3, chardet, idna, certifi, requests, oauthlib, requests-oauthlib, google-auth-oauthlib, werkzeug, markdown, tensorboard-plugin-wit, tensorboard, astunparse, tensorflow
Running setup.py install for termcolor ... done
Running setup.py install for absl-py ... done
Successfully installed absl-py-0.9.0 astunparse-1.6.3 cachetools-4.1.0 certifi-2020.4.5.1 chardet-3.0.4 gast-0.3.3 google-auth-1.14.3 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.29.0 idna-2.9 markdown-3.2.2 oauthlib-3.1.0 opt-einsum-3.2.1 protobuf-3.11.3 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.23.0 requests-oauthlib-1.3.0 rsa-4.0 tensorboard-2.2.1 tensorboard-plugin-wit-1.6.0.post3 tensorflow-2.2.0 tensorflow-estimator-2.2.0 termcolor-1.1.0 urllib3-1.25.9 werkzeug-1.0.1 wheel-0.34.2