Python の URL: http://www.python.org/
インストール手順の詳細は: 別ページで説明している.
コマンドプロンプトを管理者として実行し,次のコマンドを実行.
python -m pip install -U pip setuptools python -m pip install -U jupyterlab jupyter jupyter-console jupytext spyder
システム Python を使用(インストール操作は不要)
次のコマンドを実行.
sudo apt -yV install python3-dev python3-pip python3-setuptools sudo apt -yV install jupyter-qtconsole jupyter-notebook python3-jupyter-client python3-jupyter-console python3-spyder spyder3
sudo apt -yV install git
python -m pip install -U opencv-python
※ mtcnn については https://github.com/open-face/mtcnn
mkdir c:\pytools cd c:\pytools rmdir /s /q imutils rmdir /s /q mtcnn
cd c:\pytools git clone https://github.com/jrosebr1/imutils cd imutils python setup.py build python setup.py install cd c:\pytools git clone https://github.com/ipazc/mtcnn cd mtcnn python setup.py build python setup.py install
pip install -U tqdm
※ Windows での展開(解凍)のためのソフトには,「7-Zip」などがある.
この .zip ファイルは,D:\keras-deeplab-v3-plus-master\keras-deeplab-v3-plus-master に展開(解凍)したものとして,説明を続けるので,適切に読み替えてください.
jupyter qtconsole
Python プログラムを動かして,結果を見たい.
Jupyter Qt Console, spyder, PyCharm, PyScripter が便利である. Windows では,スタートメニューの「IDLE (Python ...)」も便利である.
※ 「jupyter qtconsole」を入れたのに,jupyter qtconsole が起動しない という場合には,次の操作で,インストールを行ってから,もう一度試してみる.
※ Windows では「python」,Ubuntu では「sudo python3 -m pip」
python -m pip install -U jupyterlab jupyter jupyter-console jupytext spyder
cd D:\keras-deeplab-v3-plus-master\keras-deeplab-v3-plus-master
run -i extract_weights.py run -i load_weights.py
https://github.com/bonlime/keras-deeplab-v3-plus に記載のプログラムを実行
from matplotlib import pyplot as plt
import cv2 # used for resize. if you dont have it, use anything else
import numpy as np
from model import Deeplabv3
deeplab_model = Deeplabv3()
img = plt.imread("imgs/image1.jpg")
w, h, _ = img.shape
ratio = 512. / np.max([w,h])
resized = cv2.resize(img,(int(ratio*h),int(ratio*w)))
resized = resized / 127.5 - 1.
pad_x = int(512 - resized.shape[0])
resized2 = np.pad(resized,((0,pad_x),(0,0),(0,0)),mode='constant')
res = deeplab_model.predict(np.expand_dims(resized2,0))
labels = np.argmax(res.squeeze(),-1)
plt.imshow(labels[:-pad_x])
本サイトは金子邦彦研究室のWebページです.サイトマップは,サイトマップのページをご覧下さい. 本サイト内の検索は,サイト内検索のページをご利用下さい.
問い合わせ先: 金子邦彦(かねこ くにひこ) ![]()