plemeri / transparent-background

This is a background removing tool powered by InSPyReNet (ACCV 2022)
MIT License
605 stars 63 forks source link

NameError: name 'Loader' is not defined #62

Closed doskebaby closed 3 weeks ago

doskebaby commented 1 month ago

Thank you for your excellent and user-friendly project. I’m reporting an error that occurred in my environment. While it works fine with images, an error occurs when trying to make the video GreenBack. The path to FFmpeg is set correctly.

Windows 10 Home 22H2 19045.4412 NVIDIA-SMI 531.61 Driver Version: 531.61 CUDA Version: 12.1 Python 3.10.11

K:\>transparent-background --source K:\a.mkv --type green
Settings -> Mode=base, Device=cuda:0, Torchscript=disabled
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\lawra\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\lawra\AppData\Local\Programs\Python\Python310\Scripts\transparent-background.exe\__main__.py", line 7, in <module>
  File "C:\Users\lawra\AppData\Local\Programs\Python\Python310\lib\site-packages\transparent_background\Remover.py", line 264, in console
    loader = eval(_format + "Loader")(args.source)
  File "<string>", line 1, in <module>
NameError: name 'Loader' is not defined

K:>transparent-background --source K:\a.mkv Settings -> Mode=base, Device=cuda:0, Torchscript=disabled Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\user0\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\user0\AppData\Local\Programs\Python\Python310\Scripts\transparent-background.exe__main__.py", line 7, in File "C:\Users\user0\AppData\Local\Programs\Python\Python310\lib\site-packages\transparent_background\Remover.py", line 264, in console loader = eval(_format + "Loader")(args.source) File "", line 1, in NameError: name 'Loader' is not defined

K:\>ffmpeg -version
ffmpeg version N-115371-g62397bcf6a-20240524 Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 13.2.0 (crosstool-NG 1.26.0.65_ecc5e41)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-fontconfig --enable-libharfbuzz --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --enable-libdvdread --enable-libdvdnav --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libaribcaption --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-libs=-lgomp --extra-ldflags=-pthread --extra-ldexeflags= --cc=x86_64-w64-mingw32-gcc --cxx=x86_64-w64-mingw32-g++ --ar=x86_64-w64-mingw32-gcc-ar --ranlib=x86_64-w64-mingw32-gcc-ranlib --nm=x86_64-w64-mingw32-gcc-nm --extra-version=20240524
libavutil      59. 20.100 / 59. 20.100
libavcodec     61.  5.104 / 61.  5.104
libavformat    61.  3.104 / 61.  3.104
libavdevice    61.  2.100 / 61.  2.100
libavfilter    10.  2.102 / 10.  2.102
libswscale      8.  2.100 /  8.  2.100
libswresample   5.  2.100 /  5.  2.100
libpostproc    58.  2.100 / 58.  2.100
plemeri commented 1 month ago

Hi @doskebaby, the error happens because of the mkv extension which is currently not supported. I think it may work by just renaming the file such as a.mp4 since opencv would accept mkv files, but not sure about it.

Please refer to the source code down below for supported video formats https://github.com/plemeri/transparent-background/blob/22ab534b252b5c032b2b60eb9ec12a18ac4364d8/transparent_background/utils.py#L46

plemeri commented 3 weeks ago

I guess your problem has been resolved since there's no further question. Closing the issue.