yu4u/noise2noise のインストールと動作確認(画像のノイズ除去)(TensorFlow 1.15.5,Python 3.7 を使用)(Windows 上)
次で配布されているソフトウェアを使ってみる手順を示す.
URL: https://github.com/yu4u/noise2noise
【目次】
利用条件等は,利用者で確認すること.
謝辞:このページで紹介するソフトウェアの作者に感謝します.
前準備
Python 3.7,Git のインストール(Windows 上)
Pythonは,プログラミング言語の1つ. Gitは,分散型のバージョン管理システム.
【手順】
- Windows で,コマンドプロンプトを管理者権限で起動する(例:Windowsキーを押し,「cmd」と入力し,「管理者として実行」を選択)
次のコマンドを実行
次のコマンドは,Python ランチャーとPython 3.7とGitをインストールし,Gitにパスを通すものである.
次のコマンドでインストールされるGitは 「git for Windows」と呼ばれるものであり, Git,MinGW などから構成されている.
winget install --scope machine Python.Launcher winget install --scope machine Python.Python.3.7 winget install --scope machine Git.Git powershell -command "$oldpath = [System.Environment]::GetEnvironmentVariable(\"Path\", \"Machine\"); $oldpath += \";c:\Program Files\Git\cmd\"; [System.Environment]::SetEnvironmentVariable(\"Path\", $oldpath, \"Machine\")"
【関連する外部ページ】
- Python の公式ページ: https://www.python.org/
- Git の公式ページ: https://git-scm.com/
【サイト内の関連ページ】
【関連項目】 Python, Git バージョン管理システム, Git の利用
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
画像のノイズ除去(yu4u/noise2noise,Python 3.7, TensorFlow 1.15.5 を使用)
Windows での手順を下に示す.Ubuntu でも同様の手順になる.
- Windows で,コマンドプロンプトを管理者として実行.
- ダウンロード
cd /d c:%HOMEPATH% rmdir /s /q noise2noise git clone https://github.com/yu4u/noise2noise cd noise2noise
- 前提パッケージのインストール
C:\venv\py37\Scripts\activate.bat python -m pip install -r requirements.txt 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
- データセットのダウンロード
https://github.com/yu4u/noise2noise の記載による
mkdir dataset cd dataset curl -O https://cv.snu.ac.kr/research/VDSR/train_data.zip curl -O https://cv.snu.ac.kr/research/VDSR/test_data.zip powershell -command "Expand-Archive -DestinationPath . -Path train_data.zip" powershell -command "Expand-Archive -DestinationPath . -Path test_data.zip" cd ..
- 学習と,動作確認
train model using (noise, noise) pairs (noise2noise)
C:\venv\py37\Scripts\activate.bat python train.py --image_dir dataset/291 --test_dir dataset/Set14 --image_size 128 --batch_size 8 --lr 0.001 --output_path gaussian python test_model.py --weight_file gaussian --image_dir dataset/Set14