obendidi / Tracking-with-darkflow

Real-time people Multitracker using YOLO v2 and deep_sort with tensorflow
GNU General Public License v3.0
524 stars 174 forks source link

numpy/arrayobject.h' file not found #1

Closed arevel190 closed 7 years ago

arevel190 commented 7 years ago

Hi bendidi,

First of all thanks for sharing this implementation. I followed your instructions but I got the following error when I run the 'run.py' script:

_/Users/pedareva1/.pyxbld/temp.macosx-10.6-intel-3.6/pyrex/darkflow/darkflow/cython_utils/cy_yolo_findboxes.c:475:10: fatal error: 'numpy/arrayobject.h' file not found

include "numpy/arrayobject.h"

     ^

1 error generated. Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile extra_postargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/ccompiler.py", line 909, in spawn spawn(cmd, dry_run=self.dry_run) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/spawn.py", line 36, in spawn _spawn_posix(cmd, search_path, dry_run=dry_run) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix % (cmd, exit_status)) distutils.errors.DistutilsExecError: command '/usr/bin/clang' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/pyximport/pyximport.py", line 215, in load_module inplace=build_inplace, language_level=language_level) File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/pyximport/pyximport.py", line 191, in build_module reload_support=pyxargs.reload_support) File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll dist.run_commands() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands self.run_command(cmd) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run _build_ext.build_ext.run(self) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/build_ext.py", line 339, in run self.build_extensions() File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions self.build_extension(ext) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension depends=ext.depends) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/ccompiler.py", line 574, in compile self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile raise CompileError(msg) distutils.errors.CompileError: command '/usr/bin/clang' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "run.py", line 3, in from darkflow.darkflow.net.build import TFNet File "/Users/pedareva1/Tracking-with-darkflow/darkflow/darkflow/net/build.py", line 7, in from .framework import create_framework File "/Users/pedareva1/Tracking-with-darkflow/darkflow/darkflow/net/framework.py", line 1, in from . import yolo File "/Users/pedareva1/Tracking-with-darkflow/darkflow/darkflow/net/yolo/init.py", line 2, in from . import predict File "/Users/pedareva1/Tracking-with-darkflow/darkflow/darkflow/net/yolo/predict.py", line 9, in from ...cython_utils.cy_yolo_findboxes import yolo_box_constructor File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/pyximport/pyximport.py", line 458, in load_module language_level=self.language_level) File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/pyximport/pyximport.py", line 231, in load_module raise exc.with_traceback(tb) File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/pyximport/pyximport.py", line 215, in load_module inplace=build_inplace, language_level=language_level) File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/pyximport/pyximport.py", line 191, in build_module reload_support=pyxargs.reload_support) File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll dist.run_commands() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands self.run_command(cmd) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command cmd_obj.run() File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run _build_ext.build_ext.run(self) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/build_ext.py", line 339, in run self.build_extensions() File "/Users/pedareva1/envs/cv2/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions self.build_extension(ext) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension depends=ext.depends) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/ccompiler.py", line 574, in compile self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile raise CompileError(msg) ImportError: Building module darkflow.darkflow.cython_utils.cy_yolofindboxes failed: ["distutils.errors.CompileError: command '/usr/bin/clang' failed with exit status 1\n"]

I would really appreciate if you could help me detect what is causing the error.

Thanks!

obendidi commented 7 years ago

I think it is likely a Mac python issue, a simple search showed that osx setup does not pass numpy include_dirs any more and a workaround for this would be to try adding NumPy headers to CFLAGS :

export CFLAGS="-I /usr/local/lib/python3.6/site-packages/numpy/core/include $CFLAGS"

you can find the path to your numpy include with :

>>> import numpy as np
>>> np.get_include()

or you can simply build cython extension inside darkflow (they added Mac support in their latest commit ) (more info in here) :

python3 setup.py build_ext --inplace

arevel190 commented 7 years ago

@bendidi Thanks, that solved this problem. Now I'm getting this error when I try to run the program using the camera FLAG:

_Traceback (most recent call last): File "run.py", line 26, in tfnet.camera() File "/Users/pedareva1/Tracking-with-darkflow/darkflow/darkflow/net/help.py", line 116, in camera fps = 1 / self._get_fps(frame) File "/Users/pedareva1/Tracking-with-darkflow/darkflow/darkflow/net/help.py", line 65, in _get_fps processed = self.framework.postprocess(net_out, frame, False) File "/Users/pedareva1/Tracking-with-darkflow/darkflow/darkflow/net/yolov2/predict.py", line 98, in postprocess detections = detections + extract_boxes(mask) File "/Users/pedareva1/Tracking-with-darkflow/darkflow/darkflow/net/yolov2/predict.py", line 38, in extract_boxes new_im=newim.astype(np.uint8) AttributeError: 'NoneType' object has no attribute 'astype'

Thanks a lot for your help!

obendidi commented 7 years ago

this means that opencv isn't capturing camera output, make sure that you're camera works with opencv before running the script, here is a simple script to test if your camera is running : Display the webcam in Python using OpenCV (cv2)

alternatively you can also try it with a video file , it should work in that case, if not then you have a problem with the installation of opencv

PS : it's better to set FLAGS.BK_MOG to False as it will give too many random boxes that can mess up detection ( I only added it when I was testing on very low quality images where YOLO can detect nothing )

arevel190 commented 7 years ago

@bendidi Thanks. Setting FLAGS.BK_MOG to False helped a lot with the accuracy of detection in videos. Regarding the opencv installation I am already running YOLO in Darkflow using my camera so I think that may not be the problem. I'll check with another VE.

Thanks.