yu4u/noise2noise のインストールと動作確認(画像のノイズ除去)(TensorFlow 1.15.5,Python 3.7 を使用)(Windows 上)
次で配布されているソフトウェアを使ってみる手順を示す.
URL: https://github.com/yu4u/noise2noise
【目次】
利用条件等は,利用者で確認すること.
謝辞:このページで紹介するソフトウェアの作者に感謝します.
前準備
Python 3.7 のインストール(Windows 上)
Pythonは,プログラミング言語の1つ.
【手順】
- Windows で,管理者権限でコマンドプロンプトを起動(手順:Windowsキーまたはスタートメニュー >
cmd
と入力 > 右クリック > 「管理者として実行」)。次のコマンドを実行
winget install --scope machine Python.Python.3.7
AI エディタ Windsurf のインストール
Pythonプログラムの編集・実行には、AI エディタの利用を推奨する。ここでは,Windsurfのインストールを説明する。
管理者権限でコマンドプロンプトを起動(手順:Windowsキーまたはスタートメニュー > cmd と入力 > 右クリック > 「管理者として実行」)し、以下を実行して、Windsurfをシステム全体にインストールする。管理者権限は、wingetの--scope machineオプションでシステム全体にソフトウェアをインストールするために必要となる。
winget install --scope machine Codeium.Windsurf -e --silent
【関連する外部ページ】
Windsurf の公式ページ: https://windsurf.com/
Gitのインストール
管理者権限でコマンドプロンプトを起動(手順:Windowsキーまたはスタートメニュー > cmd と入力 > 右クリック > 「管理者として実行」)し、以下を実行する。管理者権限は、wingetの--scope machineオプションでシステム全体にソフトウェアをインストールするために必要となる。
REM Git をシステム領域にインストール
winget install --scope machine --id Git.Git -e --silent
REM Git のパス設定
set "GIT_PATH=C:\Program Files\Git\cmd"
if exist "%GIT_PATH%" (
echo "%PATH%" | find /i "%GIT_PATH%" >nul
if errorlevel 1 setx PATH "%PATH%;%GIT_PATH%" /M >nul
)
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