KugaMaxx / cuke-emlb

A benchmark for event-based denoising.
MIT License
32 stars 4 forks source link

Running EDnCNN and MLPF: import error #12

Open MohamadHalwani opened 1 day ago

MohamadHalwani commented 1 day ago

Hi,

I'm facing an issue related to importing the pretrained models. I downloaded the files and added them to ./modules/net. I also built the package again using CC=gcc-10 CXX=g++-10 cmake .. -DEMLB_ENABLE_PYTHON=ON -DTORCH_DIR=/home/mohamadhalwani/anaconda3/envs/emlb/lib/python3.8/site-packages/torch/share/cmake/Torch The output of the build was:


-- EMLB_ENABLE_PYTHON ON
-- EMLB_ENABLE_MODULES ON
-- EMLB_ENABLE_SAMPLES 
-- EMLB_ENABLE_LIBTORCH OFF
CMake Warning at /usr/share/cmake-3.22/Modules/FindBoost.cmake:1369 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:1492 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:2102 (_Boost_MISSING_DEPENDENCIES)
  /usr/lib/x86_64-linux-gnu/cmake/dv-processing/dv-processing-config.cmake:29 (FIND_PACKAGE)
  /usr/lib/x86_64-linux-gnu/cmake/dv/dv-config.cmake:19 (FIND_PACKAGE)
  CMakeLists.txt:53 (find_package)

-- Linker flag --as-needed enabled
-- Project name is: cuke-emlb
-- Project version is: 1.0.0
-- Build type is: RELEASE
-- Compiler is Clang: FALSE
-- Compiler is GCC: TRUE
-- Compiler is IntelCC: FALSE
-- Compiler is MS VisualC: FALSE
-- OS is Unix: TRUE
-- OS is Linux: TRUE
-- OS is MacOS: FALSE
-- OS is Windows: FALSE
-- System is big-endian: 0
-- Thread support is PThreads: TRUE
-- Thread support is Win32 Threads: FALSE
-- Thread support libraries: -lpthread
-- Current C flags are: 
-- Current CXX flags are:   -Ofast -march=native
-- Final install bindir is: /usr/local/bin
-- Final install libdir is: /usr/local/lib
-- Final install includedir is: /usr/local/include
CMake Warning at /usr/share/cmake-3.22/Modules/FindBoost.cmake:1369 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:1492 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:2102 (_Boost_MISSING_DEPENDENCIES)
  /usr/lib/x86_64-linux-gnu/cmake/dv/dv-config.cmake:22 (FIND_PACKAGE)
  CMakeLists.txt:53 (find_package)

CMake Warning at /usr/share/cmake-3.22/Modules/FindBoost.cmake:1369 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:1492 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:2102 (_Boost_MISSING_DEPENDENCIES)
  /usr/lib/x86_64-linux-gnu/cmake/dv/dv-config.cmake:22 (FIND_PACKAGE)
  CMakeLists.txt:53 (find_package)

-- Found Boost: /opt/inivation/boost/include (found suitable version "1.80.0", minimum required is "1.76") found components: nowide filesystem 
-- Filesystem modules installation directory is: /usr/local/share/dv/modules
-- Actual modules installation directory is: /usr/local/share/dv/modules
-- DV_LIBRARIES set to: dv::sdk
-- Found Boost: /opt/inivation/boost/include (found version "1.80.0")  
-- TOOLKIT_ENABLE_SAMPLES OFF
-- TOOLKIT_ENABLE_PYTHON OFF
CMake Warning at /usr/share/cmake-3.22/Modules/FindBoost.cmake:1369 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:1492 (_Boost_COMPONENT_DEPENDENCIES)
  /usr/share/cmake-3.22/Modules/FindBoost.cmake:2102 (_Boost_MISSING_DEPENDENCIES)
  /usr/lib/x86_64-linux-gnu/cmake/dv-processing/dv-processing-config.cmake:29 (FIND_PACKAGE)
  external/dv-toolkit/CMakeLists.txt:28 (find_package)

-- Found Boost: /opt/inivation/boost/include (found suitable version "1.80.0", minimum required is "1.76") found components: nowide 
-- pybind11 v2.11.1 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mohamadhalwani/denoising/src/cuke-emlb/build

Then when trying to run the code, I'm getting an import error as follows:

edncnn     Traceback (most recent call last):
  File "denoiser.py", line 97, in <module>
    model = Denoisor(denoisor, resolution)
  File "/home/mohamadhalwani/denoising/src/cuke-emlb/configs/denoisors.py", line 142, in Denoisor
    return model(resolution, modified_params)
  File "/home/mohamadhalwani/denoising/src/cuke-emlb/configs/denoisors.py", line 48, in __init__
    from modules.python import event_denoise_convolution_network as module
ImportError: cannot import name 'event_denoise_convolution_network' from 'modules.python' (unknown location)
MohamadHalwani commented 1 day ago

I can't find the module under modules/python.

KugaMaxx commented 1 day ago

I see some cmake warning, it seems that you not installed successfully so you may not find any module under modules/python. Maybe fix this issue first:

CMake Warning at /usr/share/cmake-3.22/Modules/FindBoost.cmake:1369 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
MohamadHalwani commented 23 hours ago

Thanks for your prompt response.

I fixed the build issue by re-installing libboost

sudo apt-get install libboost1.76-all-dev

Now running the following gave me no warnings or errors. CC=gcc-10 CXX=g++-10 cmake .. -DEMLB_ENABLE_PYTHON=ON -DTORCH_DIR=home/mohamadhalwani/anaconda3/envs/emlb/lib/python3.8/site-packages/torch/share/cmake/Torch

output:

-- EMLB_ENABLE_PYTHON ON
-- EMLB_ENABLE_MODULES ON
-- EMLB_ENABLE_SAMPLES 
-- EMLB_ENABLE_LIBTORCH OFF
-- Linker flag --as-needed enabled
-- Project name is: cuke-emlb
-- Project version is: 1.0.0
-- Build type is: RELEASE
-- Compiler is Clang: FALSE
-- Compiler is GCC: TRUE
-- Compiler is IntelCC: FALSE
-- Compiler is MS VisualC: FALSE
-- OS is Unix: TRUE
-- OS is Linux: TRUE
-- OS is MacOS: FALSE
-- OS is Windows: FALSE
-- System is big-endian: 0
-- Thread support is PThreads: TRUE
-- Thread support is Win32 Threads: FALSE
-- Thread support libraries: -lpthread
-- Current C flags are: 
-- Current CXX flags are:   -Ofast -march=native
-- Final install bindir is: /usr/local/bin
-- Final install libdir is: /usr/local/lib
-- Final install includedir is: /usr/local/include
-- Found Boost: /usr/local/include (found suitable version "1.76.0", minimum required is "1.76") found components: nowide filesystem 
-- Filesystem modules installation directory is: /usr/local/share/dv/modules
-- Actual modules installation directory is: /usr/local/share/dv/modules
-- DV_LIBRARIES set to: dv::sdk
-- Found Boost: /usr/local/include (found version "1.76.0")  
-- TOOLKIT_ENABLE_SAMPLES OFF
-- TOOLKIT_ENABLE_PYTHON OFF
-- Found Boost: /usr/local/include (found suitable version "1.76.0", minimum required is "1.76") found components: nowide 
-- pybind11 v2.11.1 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mohamadhalwani/denoising/src/cuke-emlb/build

Then I built the package using: cmake --build . --config Release

The output

Consolidate compiler generated dependencies of target double_window_filter
[  4%] Building CXX object python/src/denoisors/CMakeFiles/double_window_filter.dir/double_window_filter.cpp.o
[  8%] Linking CXX shared module ../../../../modules/python/double_window_filter.cpython-38-x86_64-linux-gnu.so
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
[  8%] Built target double_window_filter
Consolidate compiler generated dependencies of target event_flow
[ 12%] Building CXX object python/src/denoisors/CMakeFiles/event_flow.dir/event_flow.cpp.o
[ 16%] Linking CXX shared module ../../../../modules/python/event_flow.cpython-38-x86_64-linux-gnu.so
lto-wrapper: warning: using serial compilation of 5 LTRANS jobs
[ 16%] Built target event_flow
Consolidate compiler generated dependencies of target khodamoradi_noise
[ 20%] Building CXX object python/src/denoisors/CMakeFiles/khodamoradi_noise.dir/khodamoradi_noise.cpp.o
[ 25%] Linking CXX shared module ../../../../modules/python/khodamoradi_noise.cpython-38-x86_64-linux-gnu.so
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
[ 25%] Built target khodamoradi_noise
Consolidate compiler generated dependencies of target reclusive_event_denoisor
[ 29%] Building CXX object python/src/denoisors/CMakeFiles/reclusive_event_denoisor.dir/reclusive_event_denoisor.cpp.o
[ 33%] Linking CXX shared module ../../../../modules/python/reclusive_event_denoisor.cpython-38-x86_64-linux-gnu.so
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
[ 33%] Built target reclusive_event_denoisor
Consolidate compiler generated dependencies of target time_surface
[ 37%] Building CXX object python/src/denoisors/CMakeFiles/time_surface.dir/time_surface.cpp.o
[ 41%] Linking CXX shared module ../../../../modules/python/time_surface.cpython-38-x86_64-linux-gnu.so
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
[ 41%] Built target time_surface
Consolidate compiler generated dependencies of target yang_noise
[ 45%] Building CXX object python/src/denoisors/CMakeFiles/yang_noise.dir/yang_noise.cpp.o
[ 50%] Linking CXX shared module ../../../../modules/python/yang_noise.cpython-38-x86_64-linux-gnu.so
lto-wrapper: warning: using serial compilation of 3 LTRANS jobs
[ 50%] Built target yang_noise
Consolidate compiler generated dependencies of target m_double_window_filter
[ 54%] Building CXX object src/denoisors/CMakeFiles/m_double_window_filter.dir/double_window_filter.cpp.o
[ 58%] Linking CXX shared library ../../../modules/Km_double_window_filter.so
[ 58%] Built target m_double_window_filter
Consolidate compiler generated dependencies of target m_event_flow
[ 62%] Building CXX object src/denoisors/CMakeFiles/m_event_flow.dir/event_flow.cpp.o
[ 66%] Linking CXX shared library ../../../modules/Km_event_flow.so
[ 66%] Built target m_event_flow
Consolidate compiler generated dependencies of target m_khodamoradi_noise
[ 70%] Building CXX object src/denoisors/CMakeFiles/m_khodamoradi_noise.dir/khodamoradi_noise.cpp.o
[ 75%] Linking CXX shared library ../../../modules/Km_khodamoradi_noise.so
[ 75%] Built target m_khodamoradi_noise
Consolidate compiler generated dependencies of target m_reclusive_event_denoisor
[ 79%] Building CXX object src/denoisors/CMakeFiles/m_reclusive_event_denoisor.dir/reclusive_event_denoisor.cpp.o
[ 83%] Linking CXX shared library ../../../modules/Km_reclusive_event_denoisor.so
[ 83%] Built target m_reclusive_event_denoisor
Consolidate compiler generated dependencies of target m_time_surface
[ 87%] Building CXX object src/denoisors/CMakeFiles/m_time_surface.dir/time_surface.cpp.o
[ 91%] Linking CXX shared library ../../../modules/Km_time_surface.so
[ 91%] Built target m_time_surface
Consolidate compiler generated dependencies of target m_yang_noise
[ 95%] Building CXX object src/denoisors/CMakeFiles/m_yang_noise.dir/yang_noise.cpp.o
[100%] Linking CXX shared library ../../../modules/Km_yang_noise.so
[100%] Built target m_yang_noise

Am I doing something wrong ? because I can't see EDnCNN or MLPF during the building process

I wonder why its showing -- EMLB_ENABLE_LIBTORCH OFF

KugaMaxx commented 23 hours ago

Great, It's almost done. I notice that the -DTORCH_DIR you use makes a mistake. You need to download libtorch rather than pytorch at https://pytorch.org/, where the former one is designed for C++. Once you download, just unzip it and no installation required. Also pay attention to downloading the correct CUDA version.

libtorch

MohamadHalwani commented 22 hours ago

I did this step already, but for some reason I'm getting the following warning. Even though I'm sure of the path for libtorch:

(emlb) mohamadhalwani@mohamadhalwani-ASUS-TUF-Gaming-F15-FX506HM-FX506HM:~/denoising/src/cuke-emlb/build$ CC=gcc-10 CXX=g++-10 cmake .. -DEMLB_ENABLE_PYTHON=ON -DTORCH_DIR=home/mohamadhalwani/anaconda3/envs/emlb/lib/python3.8/site-packages/libtorch/share/cmake/Torch
-- EMLB_ENABLE_PYTHON ON
-- EMLB_ENABLE_MODULES ON
-- EMLB_ENABLE_SAMPLES 
-- EMLB_ENABLE_LIBTORCH OFF
-- Linker flag --as-needed enabled
-- Project name is: cuke-emlb
-- Project version is: 1.0.0
-- Build type is: RELEASE
-- Compiler is Clang: FALSE
-- Compiler is GCC: TRUE
-- Compiler is IntelCC: FALSE
-- Compiler is MS VisualC: FALSE
-- OS is Unix: TRUE
-- OS is Linux: TRUE
-- OS is MacOS: FALSE
-- OS is Windows: FALSE
-- System is big-endian: 0
-- Thread support is PThreads: TRUE
-- Thread support is Win32 Threads: FALSE
-- Thread support libraries: -lpthread
-- Current C flags are: 
-- Current CXX flags are:   -Ofast -march=native
-- Final install bindir is: /usr/local/bin
-- Final install libdir is: /usr/local/lib
-- Final install includedir is: /usr/local/include
-- Found Boost: /usr/local/include (found suitable version "1.76.0", minimum required is "1.76") found components: nowide filesystem 
-- Filesystem modules installation directory is: /usr/local/share/dv/modules
-- Actual modules installation directory is: /usr/local/share/dv/modules
-- DV_LIBRARIES set to: dv::sdk
-- Found Boost: /usr/local/include (found version "1.76.0")  
-- TOOLKIT_ENABLE_SAMPLES OFF
-- TOOLKIT_ENABLE_PYTHON OFF
-- Found Boost: /usr/local/include (found suitable version "1.76.0", minimum required is "1.76") found components: nowide 
-- pybind11 v2.11.1 
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    TORCH_DIR

-- Build files have been written to: /home/mohamadhalwani/denoising/src/cuke-emlb/build

image

KugaMaxx commented 21 hours ago

How about rm -rf ~/denoising/src/cuke-emlb/build and redo it again?