jmiller656/EDSR-TensorFlow のインストールと動作確認(超解像)(Python 3.7,TensorFlow 1.15.5, scipy 1.1.0 を使用)(Windows 上)
手順の要点: 前準備として,NVIDIA CUDA 10.0, NVIDIA cuDNN 7.6.5, Python 3.7, TensorFlow 1.15.5 等をインストール.
ソフトウェア等の利用条件等は,利用者で確認すること.
謝辞:ソフトウェアの作者に感謝します
前準備
Python 3.7 のインストール(Windows 上) [クリックして展開]
以下のいずれかの方法で Python 3.7 をインストールする。Python がインストール済みの場合、この手順は不要である。
方法1:winget によるインストール
管理者権限のコマンドプロンプトで以下を実行する。管理者権限のコマンドプロンプトを起動するには、Windows キーまたはスタートメニューから「cmd」と入力し、表示された「コマンドプロンプト」を右クリックして「管理者として実行」を選択する。
winget install -e --id Python.Python.3.7 --scope machine --silent --accept-source-agreements --accept-package-agreements --override "/quiet InstallAllUsers=1 PrependPath=1 AssociateFiles=1 InstallLauncherAllUsers=1"
--scope machine を指定することで、システム全体(全ユーザー向け)にインストールされる。このオプションの実行には管理者権限が必要である。インストール完了後、コマンドプロンプトを再起動すると PATH が自動的に設定される。
方法2:インストーラーによるインストール
- Python 公式サイト(https://www.python.org/downloads/)にアクセスし、「Download Python 3.x.x」ボタンから Windows 用インストーラーをダウンロードする。
- ダウンロードしたインストーラーを実行する。
- 初期画面の下部に表示される「Add python.exe to PATH」に必ずチェックを入れてから「Customize installation」を選択する。このチェックを入れ忘れると、コマンドプロンプトから
pythonコマンドを実行できない。 - 「Install Python 3.xx for all users」にチェックを入れ、「Install」をクリックする。
インストールの確認
コマンドプロンプトで以下を実行する。
python --version
バージョン番号(例:Python 3.7.x)が表示されればインストール成功である。「'python' は、内部コマンドまたは外部コマンドとして認識されていません。」と表示される場合は、インストールが正常に完了していない。
Git のインストール(Windows 上) [クリックして展開]
管理者権限のコマンドプロンプトで以下を実行する.管理者権限は,winget の --scope machine オプションでシステム全体にインストールするために必要となる.
REM Git をシステム領域にインストール
winget install --scope machine --id Git.Git -e --silent --disable-interactivity --force --accept-source-agreements --accept-package-agreements --override "/VERYSILENT /NORESTART /NOCANCEL /SP- /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /COMPONENTS=""icons,ext\reg\shellhere,assoc,assoc_sh"" /o:PathOption=Cmd /o:CRLFOption=CRLFCommitAsIs /o:BashTerminalOption=MinTTY /o:DefaultBranchOption=main /o:EditorOption=VIM /o:SSHOption=OpenSSH /o:UseCredentialManager=Enabled /o:PerformanceTweaksFSCache=Enabled /o:EnableSymlinks=Disabled /o:EnableFSMonitor=Disabled"
TensorFlow 1.15.5, Keras 2.3.1 のインストール
C:\venv\py37\Scripts\activate.bat
python -m pip uninstall -y tensorflow tensorflow-cpu tensorflow-gpu tensorflow-intel tensorflow-text tensorflow-estimator tf-models-official tf_slim tensorflow_datasets tensorflow-hub keras keras-tuner keras-visualizer scipy pandas matplotlib
# TensorFlow 1.15.5 のため numpy, protobuf の古いバージョンを使用.エラーが出にくいと考えられる numpy 1.16.2, protobuf 3.19.4 を使用
python -m pip install -U numpy==1.16.2 protobuf==3.19.4 tensorflow-gpu==1.15.5 keras==2.3.1 scipy==1.5.4
このページで説明のために使用する画像
画像ファイル fruits.jpg, home.jpg のダウンロード
画像ファイル fruits.jpg, home.jpg のダウンロードは, Windows でコマンドプロンプトを管理者として開き 次のコマンドを実行する.
mkdir c:\image
cd c:\image
curl -L https://github.com/opencv/opencv/blob/master/samples/data/fruits.jpg?raw=true -o fruits.jpg
curl -L https://github.com/opencv/opencv/blob/master/samples/data/home.jpg?raw=true -o home.jpg
上のコマンドがうまく
Windows での手順を下に示す.Ubuntu でも同様の手順になる.
Windows での手順を下に示す.Ubuntu でも同様の手順になる.
scipy はバージョン 1.1.0 のものを使う.
次のページの説明に従い,事前学習済みモデルを取得.
URL: https://github.com/jmiller656/EDSR-TensorFlow
ファイルは,%HOMEPATH%\EDSR-TensorFlow\saved_models に置く
まず,ディレクトリの移動
実行してみる.「fruits.jpg」のところは,画像ファイル名を指定すること.
結果は「out」の下に残る.
元画像は次の通り
出来た画像は次の通り
顔識別(jmiller656/EDSR-TensorFlow, Python 3.7, TensorFlow 1.15.5 を使用)
cd /d c:%HOMEPATH%
rmdir /s /q EDSR-TensorFlow
git clone https://github.com/jmiller656/EDSR-TensorFlow
cd EDSR-TensorFlow
C:\venv\py37\Scripts\activate.bat
python -m pip install -U numpy==1.16.2 scipy==1.1.0 scikit-image==0.17.2 tqdm argparse
py -3.7 "C:\Program Files\Python37\Tools\scripts\2to3.py" -w test.py
py -3.7 "C:\Program Files\Python37\Tools\scripts\2to3.py" -w data.py
cd /d c:%HOMEPATH%
cd EDSR-TensorFlow
copy c:\image\fruits.jpg .
C:\venv\py37\Scripts\activate.bat
python test.py --image fruits.jpg --scale 2