pjreddie / darknet

Convolutional Neural Networks
http://pjreddie.com/darknet/
Other
25.7k stars 21.33k forks source link

Question for Mac #265

Open NguyenAiSi opened 6 years ago

NguyenAiSi commented 6 years ago

Hello

Thank you for your work Is it possible to have a tutorial to use it on MacBook Pro 13 ? I'm new with OS X

I tried to install Python and OpenCV with Homebrew but I don't know how to install CUBA ? Do I need both ? Thank you

TheMikeyR commented 6 years ago

You don't need CUDA to use YOLO, but it will significantly speed up the processing. You should set the GPU=0 in the Makefile and compile it. If you have an NVIDIA GPU you will most likely be able to use CUDA, just try to hit google with it.

NguyenAiSi commented 6 years ago

Hi Thank for your answer On 13' there is an Intel Iris Plus Graphics 650 so no CUBA ? Waiting for Xcode to end-downloading and gonna try ! thank

TheMikeyR commented 6 years ago

Yea no CUDA then

NguyenAiSi commented 6 years ago

Hi

I got this :

ld: library not found for -llibopencv_stitching.3.3.1.dylib
clang: fatal error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [libdarknet.so] Error 1

Can you help me please

TheMikeyR commented 6 years ago

I'm not experienced with OSX, but try this guide https://github.com/philipperemy/yolo-9000#mac-os

NguyenAiSi commented 6 years ago

Thank you but there is no "make your own video" for Mac user :/

TheMikeyR commented 6 years ago

Well you can save the predictions using det ./darknet valid data cfg weights command they will be saved in results/result.txt which is formatted as frame probability xmin ymin xmax ymax and then you can use make a script (e.g. python + opencv) to load the images you've used for validate, draw rectangles and save to a video.

results.txt format example

34022 0.015125 140.011703 839.720276 584.168274 1080.000000
34022 0.008560 1.000000 916.696472 812.952637 1080.000000
34022 0.006325 1.000000 408.487122 1148.099976 1080.000000
29896 0.036785 4.082747 917.808716 45.927376 1080.000000
29896 0.079733 5.316708 1006.615723 51.530296 1080.000000
29896 0.993144 1598.890259 699.325317 1793.874878 847.519409
29896 0.005473 1.000000 977.125854 117.330246 1080.000000
29896 0.006483 1211.775269 620.517334 1920.000000 1039.104736
29896 0.009766 920.593750 96.334045 1920.000000 1080.000000
42103 0.005604 9.585228 906.154907 52.833698 1080.000000
42103 0.996570 1124.616943 520.950500 1349.052734 687.091492
45742 0.994967 355.986786 332.193115 538.957520 479.927490
45742 0.973945 1.000000 619.348511 53.822556 783.967163
45742 0.005768 1426.382202 1.000000 1673.293823 -61.670311
45742 0.005023 4.242680 599.168091 114.617523 794.158325
45742 0.008773 52.132996 164.651489 977.196960 627.292847
45742 0.006842 1.000000 1.000000 1302.848267 1080.000000
45480 0.990532 1.000000 569.592773 88.009697 722.995239
45480 0.995563 344.664124 334.113251 529.469666 471.311005
NguyenAiSi commented 6 years ago

The problem is that the "make" doesn't work when I put OPENCV = 1 I got the problem of the library I quote in my previous message.... Use : OPENCV 3.3.1

TheMikeyR commented 6 years ago

You don't need OPENCV=1 for other things than showing live preview of detections as a test. The generated result files can only be made with OPENCV=0.

TheMikeyR commented 6 years ago

https://pjreddie.com/darknet/install/

Compiling With OpenCV

By default, Darknet uses stb_image.h for image loading. If you want more support for weird formats (like CMYK jpegs, thanks Obama) you can use OpenCV instead! OpenCV also allows you to view images and detections without having to save them to disk.

NguyenAiSi commented 6 years ago

All is working but I really wanted to try with my webcam so OpenCV is necessary :/ Thank for you help

TheMikeyR commented 6 years ago

As long as your OpenCV installation is not working properly it seems like you can't get it to work live, but only offline. Try to see if you can fix it with some OSX OpenCV compiling guides to install it correctly.

NguyenAiSi commented 6 years ago

I got it ! You were right it was my openCv installation

Do you know if it is possible to use OpenCL instead of CUDA ? I'm on MacBook Pro with Intel Iris

TheMikeyR commented 6 years ago

He started the project with OpenCL, but quickly transferred to CUDA since the library makes it much easier to develop and cudnn support is much faster. So unfortunately no OpenCL support.

joshholla commented 6 years ago

Hey @NguyenAiSi : do you have a good set of instructions for installing and checking the OpenCV installation on Mac? I tried to install it using homebrew, and ran into the same issues you were describing when I tried to make It would be helpful if you could point us in the right direction since you seem to have fixed this issue on your system.

NguyenAiSi commented 6 years ago

Hi @joshholla I couldn't use openCV 3 so I Installed OpenCV 2.4 and it works

sowson commented 6 years ago

Hi, I made for MacBook Pro 13 a few days ago patched version of darknet, however I am using external GPU which is AMD RX 580 (OpenCL said that) from Sonnet eGFX Breakaway Puck 570. I combined work I found for OpenCL already and currently I tested images and video with Yolo2 and Yolo9000 and also I tested training capability and it works very well and fast. I am not sure if putting here link to my blog is ok, because I am new at github and just created an account. But here it is with option to download darknet.zip (with .git folder) at http://codingbytodesign.net/2017/11/20/car-see-by-darknet-cnn-on-macbookpro-13-with-sonnet-egfx-580/ I am also planning to create repository of that work but after testing it carefully. Thanks for a great work for the authors here!

sowson commented 6 years ago

Here it is https://github.com/sowson/darknet but I am still testing this PORT.

PallawiSinghal commented 6 years ago

Hi,

I have opencv installed in my mac and I have also made the OPENCV macro = 1 ,in the makefile. But still I get the linking error. and when I try the opencv examples I get this error. please help!

screen shot 2018-01-29 at 3 06 54 pm screen shot 2018-01-29 at 3 06 06 pm
TheMikeyR commented 6 years ago

@PallawiSinghal Did you download, compile and install opencv on your mac?

PallawiSinghal commented 6 years ago

Yes sir, I have been using opencv since past 1 year for other applications.

On Jan 29, 2018 3:25 PM, "Mike Røntved" notifications@github.com wrote:

@PallawiSinghal https://github.com/pallawisinghal Did you download, compile and install opencv on your mac?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pjreddie/darknet/issues/265#issuecomment-361194331, or mute the thread https://github.com/notifications/unsubscribe-auth/APvCo71MZ5sQ5ckjq7H8LvGQLMJ2gMGGks5tPZWhgaJpZM4QGDW9 .

TheMikeyR commented 6 years ago

@PallawiSinghal How are you using OpenCV for other applications? How did you install it? Which version? From what I see the when you are compiling darknet it can't find any OpenCV functions, like it's missing from your path.

PallawiSinghal commented 6 years ago

Hello sir,

I am using cv2.version 3.3 .

and Python 2.7.10.

Thanks and regards, Pallawi

On Mon, Jan 29, 2018 at 5:29 PM, Mike Røntved notifications@github.com wrote:

@PallawiSinghal https://github.com/pallawisinghal How are you using OpenCV for other applications? How did you install it? Which version? From what I see the when you are compiling darknet it can't find any OpenCV functions, like it's missing from your path.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pjreddie/darknet/issues/265#issuecomment-361224225, or mute the thread https://github.com/notifications/unsubscribe-auth/APvCo9XwaFJ9xsBJKzzFP_BNwyFA5WZLks5tPbKtgaJpZM4QGDW9 .

PallawiSinghal commented 6 years ago

@TheMikeyR

Hello sir,

I am using cv2.version 3.3 .

and Python 2.7.10

TheMikeyR commented 6 years ago

@PallawiSinghal did you build, compile and install opencv from source or just through a python library? e.g. conda install -c conda-forge opencv You need to install the c++ opencv headers and not just for python.

I've just tried to create a new virtual machine and reinstall darknet with opencv flag, I've installed python 2.7 with opencv 3.3 which couldn't compile. I then removed the package, and installed opencv from source and can succesfully compile darknet with opencv.

I'm not experienced in osx, so everything have been tested on a fresh ubuntu 16.04. But I assume there are plenty guides on the internet on how to install opencv on osx from source.

lomnes commented 6 years ago

I had the issue with not being able to compile with openCV on mac but have resolved the issue. As @NguyenAiSi points out (and @joshholla requested details for) openCV 3 didn't work and that openCV 2.4 works. Although installing and setting the environment variables aren't as simple as a typical 'brew install xxxx'.

First uninstall installed versions of opencv $ brew uninstall opencv

Then install openCV 2.4 $ brew install opencv@2

The messages after install are: `==> Caveats This formula is keg-only, which means it was not symlinked into /usr/local, because this is an alternate version of another formula.

If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/opencv@2/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/opencv@2/lib CPPFLAGS: -I/usr/local/opt/opencv@2/include For pkg-config to find this software you may need to set: PKG_CONFIG_PATH: /usr/local/opt/opencv@2/lib/pkgconfig`

First time around I missed these messages. Instead run the following commands:

echo 'export PATH="/usr/local/opt/opencv@2/bin:$PATH"' >> ~/.bash_profile

then export LDFLAGS=-L/usr/local/opt/opencv@2/lib export CPPFLAGS=-I/usr/local/opt/opencv@2/include export PKG_CONFIG_PATH=/usr/local/opt/opencv@2/lib/pkgconfig

After that I edited the Makefile $ vi Makefile

and set OPENCV = 1

saved and then ran $ make

This created a lot of warning messages but ultimately compiled.

Then I could run the webcam demo: ./darknet detector demo cfg/coco.data cfg/yolo.cfg yolo.weights

And while this strictly speaking "worked" the frame rate was less than 1 FPS and so very slow.

With a macbook pro I don't have the option to use the onboard non-nvidia GPU to speed this up.

chitalian commented 6 years ago

@Iomnes thanks! this mostly worked for me... I came across this error and found a solution. Error ` include/darknet.h:25:14: fatal error: 'opencv2/highgui/highgui_c.h' file not found

include "opencv2/highgui/highgui_c.h"

         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated. Solution I just needed to also type in this: export CPPFLAGS=-I/usr/local/opt/opencv@2/highgui` then make again.

chitalian commented 6 years ago

At this time I got everything working except my GPU... I am getting this error and can't seem to figure out why... clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument] ld: warning: directory not found for option '-L/usr/local/cuda/lib64' ld: library not found for -lcuda clang: fatal error: linker command failed with exit code 1 (use -v to see invocation) make: *** [libdarknet.so] Error 1

cansik commented 6 years ago

@chitalian The problem is that clang is looking at the wrong place for the cuda library. I don't know the path exactly, but I think it is not lib64 anymore, but just lib.

Go to the folder and check it yourself, copy the whole folder where cuda lib is installed and rename it to lib64. Just symbolic links won't work.

crujzo commented 6 years ago

The thing is that to continuously check the performance of your model one needs better GPU**!! power which either possible by using Assembled Nvidia GPU machines or PaaS like Amazon. Model training is mostly about better GPU power. For Mac _AMD**_ follow this like: https://support.apple.com/en-in/HT208544

satorumpen commented 6 years ago

When installing opencv 3.4.0, it succeeded in recognition on webcam.

$ brew uninstall --force opencv
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/7f1c288db655084b0eee40c442dc7a722bfd40a6/Formula/opencv.rb

If you get an error with the following command,

$ opencv_version
dyld: Library not loaded: /usr/local/opt/ffmpeg/lib/libavcodec.57.dylib

Please fix some symbolic links

cd /usr/local/opt/ffmpeg/lib/
ln -s libavcodec.58.dylib libavcodec.57.dylib

Make and start up

cd darknet
make
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights
sowson commented 5 years ago

My project had some issues but now seams to the most of them have been solved at https://github.com/sowson/darknet it is Darknet in OpenCL... that works! :D. I am looking for contributor who help with pull request that add Windows setup possibility.

stevenjnovotny commented 3 years ago

Is there a way to take advantage of an M1 Mac?

RDD-1407 commented 1 month ago

While installong opencv@2 , I am getting this error 'opencv2/core/version.hpp' . Also, how to instal YOLO 4 after installing opencv@2