Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to execute realsr-ncnn from another directory #37

Open
FalconSN opened this issue Sep 23, 2023 · 4 comments
Open

Unable to execute realsr-ncnn from another directory #37

FalconSN opened this issue Sep 23, 2023 · 4 comments

Comments

@FalconSN
Copy link

FalconSN commented Sep 23, 2023

Hello, and thank you for making this software. I appreciate it.

I've been trying to use realsr-ncnn in a script along with gallery-dl, but I cannot execute it unless I'm in it's directory. For example, executing ./realsr/realsr-ncnn in Termux home directory throws this error:

CANNOT LINK EXECUTABLE "realsr-ncnn": library "libncnn.so" not found: needed by main executable

realsr directory content:

total 25060
-rwxrw---- 1 u0_a176 u0_a176     1411 May 30  2022 colors.xml
-rwxrw---- 1 u0_a176 u0_a176    10063 May 30  2022 delegates.xml
-rwxrw---- 1 u0_a176 u0_a176  1014664 May 22 06:43 libc++_shared.so
-rwxrw---- 1 u0_a176 u0_a176 10492512 May 17 06:57 libncnn.so
-rwxrw---- 1 u0_a176 u0_a176   960096 Jul 31  2021 libomp.so
-rwxrw---- 1 u0_a176 u0_a176  8078360 May 22 06:43 magick
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-Real-ESRGAN
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-Real-ESRGAN-SourceBook
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-Real-ESRGAN-anime
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-Real-ESRGANv2-anime
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-Real-ESRGANv3-anime
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-nose
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-pro
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-se
drwxrwx--- 2 u0_a176 u0_a176     3488 Sep 23 16:29 models-srmd
-rwxrw---- 1 u0_a176 u0_a176  1301560 Dec 16  2022 realcugan-ncnn
-rwxrw---- 1 u0_a176 u0_a176   954520 Jun 10 14:30 realsr-ncnn
-rwxrw---- 1 u0_a176 u0_a176   849400 Jun 10 14:50 resize-ncnn
-rwxrw---- 1 u0_a176 u0_a176   979472 Dec 16  2022 srmd-ncnn
-rwxrw---- 1 u0_a176 u0_a176   945384 Dec 16  2022 waifu2x-ncnn

After this error, I've tried making a script that will execute realsr-ncnn in it's directory:

$cat ../usr/bin/realsr
#!/data/data/com.termux/files/usr/bin/bash
HOME=/data/data/com.termux/files/home
cd $HOME/realsr
./realsr-ncnn "$@"

With realsr, it shows the usage, which means it works. But when trying to upscale an image this way, this error is occuring (verbose output):

finding model: models-Real-ESRGANv3-anime/x4.bin
[0 Adreno (TM) 610]  queueC=0[3]  queueG=0[3]  queueT=0[3]
[0 Adreno (TM) 610]  bugsbn1=1  bugbilz=0  bugcopc=0  bugihfa=0
[0 Adreno (TM) 610]  fp16-p/s/a=1/0/0  int8-p/s/a=1/0/1
[0 Adreno (TM) 610]  subgroup=64  basic=1  vote=1  ballot=1  shuffle=1
init heap_budget, use_gpu_count=1
init gpu tilesize 0/1 = 100
init realsr
fopen failed
decode image image.jpg failed
init save_threads 0
init save_threads 1
Total use time: 2.256

This same picture is being upscaled only if I go into the directory where realsr-ncnn resides and execute from there in terminal.
Tried copying libncnn.so to usr/lib/ and this didn't work either. What would be the best approach to this?

Edit: My workaround is the realsr script in /data/data/com.termux/files/usr/bin.
Content:

#!/data/data/com.termux/files/usr/bin/bash
if ! compgen -G "$1" ; 
then 
file=$(realpath "$1") ; 
else 
file="$1" ;
fi
output=$(realpath "$2") ;
HOME=/data/data/com.termux/files/home ;
cd $HOME/realsr ;
cp "$file" . ;
./realsr-ncnn -m "models-Real-ESRGANv3-anime" -s 4 -i "${file##*/}" -o "$output" ;
rm "${file##*/}"
@tumuyan
Copy link
Owner

tumuyan commented Sep 24, 2023

it prints “decode image image.jpg failed”, I
think the image has a jpg suffix but it is not a real jpg file. you could use mediainfo to see its real format, or change input file.

@FalconSN
Copy link
Author

FalconSN commented Sep 24, 2023

Okay, this has gotten weird. Looked at the image format with mediainfo as you said, and it was JPEG. Then used the first script which had threw fopen failed and decode image failed errors earlier, on the very same picture but this time in /sdcard/Pictures directory, and it just worked. First attempt was in Termux home directory, and wanted to see if it will still print the same errors. Copied the file to Termux home, and guess what? Same errors. I don't really mind about this issue, however; realsr-ncnn being uncallable from another directory still persists.

@tumuyan
Copy link
Owner

tumuyan commented Sep 26, 2023

Sorry, I'm not good with Linux shells or termux, using a sh script is a good way.
I guess if you add export LD_LIBRARY_PATH= 'your ncnn.so path' ; to the command might be useful

@FalconSN
Copy link
Author

I guess if you add export LD_LIBRARY_PATH= 'your ncnn.so path' ; to the command might be useful

Yeah... I didn't know anything about this environment variable. It does help, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants