Skip to content

Instantly share code, notes, and snippets.

@jgwill
Last active June 12, 2023 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgwill/77178d1ab8499af65cc88ed4dec39b4d to your computer and use it in GitHub Desktop.
Save jgwill/77178d1ab8499af65cc88ed4dec39b4d to your computer and use it in GitHub Desktop.
gia-upscayler-env-setup @stcgoal Experimental attempt to package a Generative Adversarial Networking to Uprez Images

Installation

Env

conda create -n py310ESRGAN python=3.10 anacond

Activate

conda activate py310ESRGAN

Modules

# Install basicsr - https://github.com/xinntao/BasicSR
# We use BasicSR for both training and inference
pip install basicsr
# facexlib and gfpgan are for face enhancement
pip install facexlib
pip install gfpgan
pip install -r requirements.txt
python setup.py develop

CPU or GPU Torch

  • Require to uninstall and install a new
pip uninstall torch
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
  • Easy access to Cuda ENV in VSCode

Easy access to Cuda ENV in VSCode

Conda Env in VSCODE (settings.json section terminal...)

"Conda PS 7 py310ESRGAN": {
      "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
      "args": ["-NoExit","-Command"," C:\\usr\\local\\anaconda\\shell\\condabin\\conda-hook.ps1 ; conda activate py310ESRGAN"]
    },

Execution of the Python using GPU

# Torch CPU has to be removed and GPU has to be installed

On WSL

nvcc --version
# OUTPUT >>
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Thu_Nov_18_09:45:30_PST_2021
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0
REPO_DIR=/mnt/c/usr/src/_giar/giar-Real-ESRGAN
sudo apt install nvidia-cuda-toolkit -y
conda update conda
conda create -n py310ESRGAN python=3.10 anaconda
conda activate py310ESRGAN
conda update conda
# Install basicsr - https://github.com/xinntao/BasicSR
# We use BasicSR for both training and inference
pip install basicsr
# facexlib and gfpgan are for face enhancement
pip install facexlib
pip install gfpgan
pip install -r requirements.txt
python setup.py develop
# Do some of what is said in : https://github.com/GuillaumeAI/giar-Real-ESRGAN#installation
cd $REPO_DIR && \
curl --insecure \
https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.2.4/RealESRGAN_x4plus_anime_6B.pth \
--output weights/RealESRGAN_x4plus_anime_6B.pth
# Possibly Docker...
docker pull pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime

Document the running of the Python Lib REALEsGAN

conda activate py310ESRGAN

cd "C:\Users\jeang\iCloudDrive\_ai\_test_Upscayl\inputs_to_UPSCALE\Ellia\36var2"

python C:\usr\src\_giar\giar-Real-ESRGAN\inference_realesrgan.py  -n RealESRGAN_x4plus_anime_6B -i 03x   -o _out2 --tile 100

See : anaconda.org/guillaumeai/py310esrgan environment.yml

docker pull docker.io/jgwill/ubuntu:cuda_11.5.r11.5

Some Command generated in BASH.WSL

  • The idea is to try running using CMD.exe from WSL
C:\usr\local\giar-upscayl\resources\bin\upscayl-realesrgan.exe -i C:\Users\jeang\iCloudDrive\_ai\_test_Upscayl\inputs_to_UPSCALE\Ellia\36var2\03x\Ellia_no_36var2b04__2178014a-818c-4bfd-b7f2-5f56b442648e.png -o C:\Users\jeang\iCloudDrive\_ai\_test_Upscayl\inputs_to_UPSCALE\Ellia\36var2\_out\Ellia_no_36var2b04__2178014a-818c-4bfd-b7f2-5f56b442648e__u4x.png

generator (see $binroot/gia-pto-batch-rename-idug-2-seq-230611.sh)

#!/bin/bash

#@STCGoal do Renamo Variation of a sequence of file with Idug in PNG

if [ "$1" == "--help" ];then
        echo "usage: $0 Ellia_no_36var2a jpg 0 \"50d1ce11-d32c-4e1c-a4a5-7f8624eff938\""
else
fname="Ellia_no_36var2a"
i=0
ext=png
if [ "$1" != "" ];then
        fname=$1
fi
if [ "$2" != "" ];then
        ext=$2
fi
if [ "$3" != "" ];then
        i=$3
fi
if [ "$4" != "" ];then
        _idug="$4"
fi

for f in $(ls *.$ext)
        do
                if [ "$_idug" == "" ];then   #might be specified
                        idug=$(echo $f  | tr "." " "| awk '//{print $2}' | sed -e 's/_//g' )
                else
                        idug=$_idug
                fi
                echo "$idug"
                i=$((i+1))
                foo=$(printf "%02d" $i)
                fout=$fname$foo'__'$idug'.'$ext
                echo $fout

                #Do the work
                mv "$f" "$fout"
        done

fi

--@STCIssue Weight not accessible (Downloading to current folder !!)

[see repo](

Github repo: GuillaumeAI/giar-Real-ESRGAN )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment