Sunday, December 22, 2024

How to run HMA single image super resolution on Windows 11 computer

Prerequisites

Windows 11 PC with 64GB+ memory

Nvidia GPU with 24GB+ VRAM

Setup HMA


Install Cuda 11.8.0 https://developer.nvidia.com/cuda-toolkit-archive
Install cudnn 9.4.0 https://developer.nvidia.com/cudnn-archive

Install miniforge https://github.com/conda-forge/miniforge/releases/download/24.7.1-0/Miniforge3-24.7.1-0-Windows-x86_64.exe

Download HMA zip from https://github.com/korouuuuu/HMA 

   press code → Download ZIP onto C:\work\HMA

Fix bug of C:\work\HMA\hma\data\paired_imagenet_dataset.py according to https://github.com/korouuuuu/HMA/pull/5/files


Run Miniforge prompt and type following commands


conda update -y -n base -c defaults conda

conda update -y --all

cd C:\work\HMA

conda create -y -n HMA python=3.9

conda activate HMA

conda install -y pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia

 pip install "numpy==1.23.0" "ipython==7.21.0" "opencv-python==4.5.4.58" "einops==0.4.1"

pip install -r requirements.txt

python setup.py develop

          


Download pretrained model file HMA_SRx2_pretrain.pth from

https://drive.google.com/drive/folders/13Bxt_BXtWgwwcO7tjfoL6zYZAUY1v3zi


Save it as

C:\work\HMA\experiments\pretrained_models\HMA_SRx2_pretrain.pth


Dataset preparation


(Dataset used is https://github.com/XPixelGroup/BasicSR/blob/master/docs/DatasetPreparation.md )


Download Set5 Set14 BSD100 Urban100 MANGA109

from https://drive.google.com/drive/folders/1gt5eT293esqY0yr1Anbm36EdnxWW_5oH


Unzip and arrange Set5 Set14 directories as

C:\work\HMA\datasets\Set5\LRbicx2

C:\work\HMA\datasets\Set5\GTmod2 (renamed from GTmod12)

C:\work\HMA\datasets\Set14\LRbicx2

C:\work\HMA\datasets\Set14\GTmod2( renamed from GTmod12)


Edit C:\work\HMA\options\test\HMA_SRx2.yml to delete test_3 test_4 test_5, leave Set5 Set14 as it is


Run test

On the Miniforge prompt

conda activate HMA

python hma/test.py -opt options/test/HMA_SRx2.yml


Suprer-esolution result images are written onto C:\work\HMA\results\HMA_test_X2\visualization


Saturday, September 14, 2024

How to run RealBasicVSR on Windows 11

Prerequisites

Windows 11 PC with 64GB+ memory

Nvidia GPU with 12GB+ VRAM

mp4 video file of short duration (30 seconds or less) as input.mp4

Setup and run RealBasicVSR


Install Cuda 11.8.0 https://developer.nvidia.com/cuda-toolkit-archive
Install cudnn 9.4.0 https://developer.nvidia.com/cudnn-archive

Install miniforge https://github.com/conda-forge/miniforge/releases/download/24.7.1-0/Miniforge3-24.7.1-0-Windows-x86_64.exe

Install Visual Studio 2022 Professional
add C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.41.34120\bin\Hostx64\x64 to environment PATH
(I think it is possible to use Visual Studio 2022 Community edition instead)

Run Miniforge prompt and type following commands


conda update -y -n base -c defaults conda
conda update -y --all

conda env remove -y -n realbasicvsr

conda create -y -n realbasicvsr python=3.9

conda activate  realbasicvsr 

conda install -y pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.8 -c pytorch -c nvidia
conda install -y fsspec==2024.9.0 openmim==0.3.7 ninja==1.12.1 albumentations==1.4.14

mim install mmcv==2.1
mim install mmengine==0.10.4
mim install mmagic==1.2.0
conda install -y numpy==1.26
conda install -y platformdirs==4.3.2
conda install -y diffusers==0.28

Download mmagic=1.2.0 as zip https://github.com/open-mmlab/mmagic/archive/refs/tags/v1.2.0.zip
extract it
cd mmagic-1.2.0



python demo/mmagic_inference_demo.py --model-name real_basicvsr --video ./input.mp4 --result-out-dir ./out/out.mp4


It runs. The result is not convincing. Maybe something is wrong.