yu4u/noise2noise のインストールと動作確認(画像のノイズ除去)(TensorFlow 1.15.5,Python 3.7 を使用)(Windows 上)

次で配布されているソフトウェアを使ってみる手順を示す.

URL: https://github.com/yu4u/noise2noise

目次

  1. 前準備
  2. 画像のノイズ除去(yu4u/noise2noise,Python 3.7, TensorFlow 1.15.5)

利用条件等は,利用者で確認すること.

謝辞:このページで紹介するソフトウェアの作者に感謝します.

前準備

Python 3.7,Git のインストール(Windows 上)

Pythonは,プログラミング言語の1つ. Gitは,分散型のバージョン管理システム.

手順

  1. Windows で,コマンドプロンプト管理者権限で起動する(例:Windowsキーを押し,「cmd」と入力し,「管理者として実行」を選択)

    次のコマンドを実行

    次のコマンドは,Python ランチャーとPython 3.7Gitをインストールし,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, 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 でも同様の手順になる.

  1. Windows で,コマンドプロンプト管理者として実行
  2. ダウンロード
    cd /d c:%HOMEPATH%
    rmdir /s /q noise2noise
    git clone https://github.com/yu4u/noise2noise
    cd noise2noise
    
  3. 前提パッケージのインストール
    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
    
  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 ..
    
  5. 学習と,動作確認

    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