AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.65k stars 7.96k forks source link

Installation of Darknet not working in Ubuntu with Anaconda #6358

Open ropinheiro opened 4 years ago

ropinheiro commented 4 years ago

I'm running Ubuntu (20.04, focal) and just cloned the AlexeyAB's Darnet repository.

I have already installed cmake (3.16.13), OpenCV (4.3.0), CuDNN (7.6.5) and CUDA Compilation Tools (10.1).

I have a NVIDIA GEFORCE GTX 950M.

I successfully built it with cmake as described in the documentation, generating a libdarknet.so, with the Makefile configured this way:

GPU=1 CUDNN=1 CUDNN_HALF=0 OPENCV=1 AVX=0 OPENMP=0 LIBSO=1 ZED_CAMERA=0 ZED_CAMERA_v2_8=0

Now I try to execute it from a Python script, and I'm unable to.

What I tried:

1. Using import in a command line running Python from the same path where libdarknet.so was built:

(base) xxx@xxx:~/work/darknetAlexeyAB$ python3
Python 3.7.7 (default, May  7 2020, 21:25:33) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import darknet
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rmp/work/darknetAlexeyAB/darknet.py", line 131, in <module>
    lib = CDLL("./libdarknet.so", RTLD_GLOBAL)
  File "/home/rmp/anaconda3/lib/python3.7/ctypes/__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/x86_64-linux-gnu/librsvg-2.so.2: undefined symbol: cairo_tag_end
>>> 

As you can see, I get "undefined symbol: cairo_tag_end" error.

2. Running a Python script from Spyder:

The script I'm trying to run is this one:

https://github.com/augmentedstartups/YOLOv4-Tutorials/blob/master/3.%20YOLOv4%20Video%20and%20Webcam/darknet_video_mod.py

It appears to correctly import darknet, but then when using the darknet.load_net_custom method, it throws an error: AttributeError: module 'darknet' has no attribute 'load_net_custom'

image

I spent some hours researching these problems, with lots of installs and upgrades of packages and libraries, and so far it was not solved.

Nonetheless, I'm able to run the standalone executable. E.g. this works properly:

/darknet detector test ./cfg/coco.data ./cfg/yolov4.cfg ./yolov4.weights

But I would really like to have this working in a Python script. Do you have any hints I could try?

Thank you!

luca-medeiros commented 4 years ago

Check your pathings. Adding full path for ./libdarknet.so inside darknet.py might help.

sfleisch314 commented 4 years ago

Yeah, that isn't going to work - API change. I created a fork with the minimal changes needed to make it work.

As for the undefined symbol error, try installing libcairo packages. This is what I have installed:

StephanPan commented 3 years ago

@ropinheiro i met the same problem, did you solve it ?