idealo/image-super-resolution のインストールと超解像の実行(超解像)(Python,TensorFlow を使用)(Windows 上)

ISR は超解像の機能を持つソフトウケア

https://idealo.github.io/image-super-resolution/

前準備

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

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

手順

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

    次のコマンドを実行

    次のコマンドは,Python ランチャーとPython 3.10とGitをインストールし,Gitパスを通すものである.

    次のコマンドでインストールされるGitは 「git for Windows」と呼ばれるものであり, Git,MinGW などから構成されている.

    winget install --scope machine Python.Launcher
    winget install --scope machine Python.Python.3.10
    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,Keras のインストール

Windows での TensorFlowKeras のインストール: 別ページ »で説明

(このページで,Build Tools for Visual Studio 2022,NVIDIA ドライバ, NVIDIA CUDA ツールキットNVIDIA cuDNNのインストールも説明している.)

ISR のインストール

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

    *python -m pip install ...」は,Python パッケージをインストールするためのコマンド.

    python -m pip install cython pyyaml
    git clone https://github.com/idealo/image-super-resolution
    cd image-super-resolution
    python setup.py install
    
  3. 画像ファイル a.png を準備
  4. 動作確認のため,Python プログラムを実行する

    Python プログラムの実行: 別ページ »で説明

    Python のまとめ: 別ページ »にまとめ

    https://github.com/idealo/image-super-resolutionで公開されているプログラムを書き替えて使用.

    import numpy as np
    from PIL import Image
    
    img = Image.open('a.png')
    lr_img = np.array(img)
    
    from ISR.models import RDN
    
    rdn = RDN(weights='psnr-small')
    sr_img = rdn.predict(lr_img, by_patch_of_size=50)
    result = Image.fromarray(sr_img)
    result.save('result.png')
    
  5. 実行の結果,result.png ができる.

    結果を確認.

    • 下は元画像.

      下は,メガネ部分の拡大

    • 下は,いま ISR で超高解像度を行って得られた画像

      下は,メガネ部分の拡大