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

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

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

前準備

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

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

手順

  1. Windows で,コマンドプロンプト管理者権限で起動する(手順:Windowsキーまたはスタートメニュー,「cmd」と入力,右クリックメニューなどで「管理者として実行」を選択)

    次のコマンドを実行

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

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

    reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v LongPathsEnabled /t REG_DWORD /d 1 /f
    REM Python, Git をシステム領域にインストール
    winget install --scope machine --id Python.Python.3.12 --id Python.Launcher --id Git.Git -e --silent
    REM Python のパス
    set "INSTALL_PATH=C:\Program Files\Python312"
    echo %PATH% | find /i "%INSTALL_PATH%" >nul
    if errorlevel 1 setx PATH "%PATH%;%INSTALL_PATH%" /M >nul
    echo %PATH% | find /i "%INSTALL_PATH%\Scripts" >nul
    if errorlevel 1 setx PATH "%PATH%;%INSTALL_PATH%\Scripts" /M >nul
    REM Git のパス
    set "NEW_PATH=C:\Program Files\Git\cmd"
    if exist "%NEW_PATH%" echo %PATH% | find /i "%NEW_PATH%" >nul
    if exist "%NEW_PATH%" if errorlevel 1 setx PATH "%PATH%;%NEW_PATH%" /M >nul
    

関連する外部ページ

サイト内の関連ページ

関連項目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 で超高解像度を行って得られた画像

      下は,メガネ部分の拡大