Tracking-with-darkflow icon indicating copy to clipboard operation
Tracking-with-darkflow copied to clipboard

ImportError: No module named 'darkflow.cython_utils'

Open k0286 opened this issue 6 years ago • 13 comments

I installed the repo and build dependences on a clean docker container, according to the instructions in the readme.md.

When I executed the python3 run.py, I got the following error message.

Traceback (most recent call last):
  File "run.py", line 5, in <module>
    from darkflow.darkflow.net.build import TFNet
  File "/workspace/Tracking-with-darkflow/darkflow/darkflow/net/build.py", line 7, in <module>
    from .framework import create_framework
  File "/workspace/Tracking-with-darkflow/darkflow/darkflow/net/framework.py", line 1, in <module>
    from . import yolo
  File "/workspace/Tracking-with-darkflow/darkflow/darkflow/net/yolo/__init__.py", line 2, in <module>
    from . import predict
  File "/workspace/Tracking-with-darkflow/darkflow/darkflow/net/yolo/predict.py", line 9, in <module>
    from ...cython_utils.cy_yolo_findboxes import yolo_box_constructor
  File "darkflow/cython_utils/cy_yolo_findboxes.pyx", line 1, in init darkflow.cython_utils.cy_yolo_findboxes
ImportError: No module named 'darkflow.cython_utils'

I also tried to install darkflow form thtrieu directly and got the same error.

I've searched similar issues both on Google and Stack overflow, but I don't find a feasible solution.

k0286 avatar Mar 22 '18 01:03 k0286

I am getting the same error. Did you figure out ?

IAmUnbounded avatar Mar 22 '18 12:03 IAmUnbounded

@k0286 @sukhad-app seems like a bug. I've installed darkflow globally. This helped me avoid "init darkflow.cython_utils.cy_yolo_findboxes" problem

exotikh3 avatar Mar 26 '18 21:03 exotikh3

Same error here

alexanderfrey avatar Apr 04 '18 12:04 alexanderfrey

I had the same error: I found the darkflow.cython_utils where here: ./Tracking-with-darkflow/darkflow/darkflow/cython_utils ..instead of here ./Tracking-with-darkflow/darkflow/

So I copied the folder cython_utils into ./Tracking-with-darkflow/darkflow/, and that solved for me.

alexdominguez09 avatar Apr 07 '18 16:04 alexdominguez09

Instead of building darkflow inside the tracking with darkflow directly. Install darkflow globally. It would work.

IAmUnbounded avatar Apr 08 '18 05:04 IAmUnbounded

Copying the cython_utils folder did not work for me. And how do I install darkflow globally? Thanks

tonmoyborah avatar Apr 13 '18 05:04 tonmoyborah

it seems a problem about path, there is a way around with some modification :

  1. delete Tracking-with-darkflow/darkflow/init.py

  2. pip uninstall darkflow

  3. cd into Tracking-with-darkflow/darkflow, run command "python3 setup.py build_ext --inplace", if succeed, you will find .so files in darkflow/darkflow/cython_utils/

  4. mv Tracking-with-darkflow/run.py to Tracking-with-darkflow/darkflow/run.py, and modify import of run.py such that from darkflow.defaults import argHandler #Import the default arguments from darkflow.net.build import TFNet

  5. config yolo cfg, weight, disable tracker

  6. run run.py, till now the detection should work

  7. activate tracking, and set tracker to deep_sort, run and you will see some path errors, fix one by one, for example in darkflow/darkflow/net/helper.py

     if self.FLAGS.tracker == "deep_sort":
         import sys
         sys.path.insert(0,"/home/Tracking-with-darkflow")
         from deep_sort import generate_detections
    

in darkflow/darkflow/net/yolov2/predict.py

    try :
            import sys
            sys.path.insert(0,"/home/Tracking-with-darkflow")
            from deep_sort.application_util import preprocessing as prep

to make python know the path

after this detection with deep_sort tracker could work

nathangq avatar May 04 '18 09:05 nathangq

A simple, quick, and safe workaround is to copy darkflow/darkflow/cython_utils and darkflow/darkflow/utils to darkflow/cython_utils and darkflow/utils respectively.

jrkwon avatar Jun 27 '18 12:06 jrkwon

      Copying the cython_utils folder did not work for me. And how do I install darkflow globally?

Thanks

instead of use python3 setup.py build_ext --inplace you should use pip install .

Mengmeng10 avatar Oct 10 '18 08:10 Mengmeng10

simply build the module globally, it will work.

KaranFriends avatar Mar 07 '19 18:03 KaranFriends

install in dev mode pip install -e .

italojs avatar Mar 30 '19 21:03 italojs

Lookup the annotation files in your directory. See if it contains anything else except .xml files. If yes, remove it and re-run. It will work.

mujeebishaque avatar May 15 '19 23:05 mujeebishaque

I had the same problem, I was trying to import it from the Anaconda env. But then I noticed that my win10 python version and the anaconda env's was different. Just created a new env with the same python version (3.6.8) as my win10 and had a clean install of darkflow again(using 'python3 setup.py build_ext --inplace' first tried other two options but they did no good), that fixed the problem. I switched to a new env because I had nothing important in the present one and also didnt want to risk it. Maybe it will also work without installing stuff from scratch. Now I cant import it to PyCharm even though I added the darkflow dir to pycharm path, would be awesome if someone can help. Good luck.

ghost avatar May 16 '19 16:05 ghost