Code Monkey home page Code Monkey logo

yolo3-4-py's Introduction

YOLO3-4-Py

PyPI Badge PyPI Badge Build Status

A Python wrapper on Darknet. Compatible with latest YOLO V3. YOLO 3.0 is an Object Detector by pjreddie.

OutputImage Image source: http://absfreepic.com/free-photos/download/crowded-cars-on-street-4032x2272_48736.html

Google Colab Demo

Refer the following link to preview YOLO3-4-Py in Google Colab: [Google Colab].

Copy the notebook to your drive and run all cells. Ensure that you are in a GPU runtime. You can change the runtime by accessing the menu Runtime/Change runtime type.

What's New?

  • 2021-02-27 - Fixed the pkg-config related issue affecting some users of Ubuntu 20.04 and later.
  • 2020-06-18 - Added a sample Google Colab notebook demonstrating functionality.
  • 2019-01-15 - Added nvidia-docker support.
  • 2018-08-04 - Option to select the preferred GPU - pydarknet.set_cuda_device(GPU_INDEX)
  • 2018-04-23 - PyPI Release of RC12

Pre-requisites

  1. Python 3.5+
  2. Python3-Dev (For Ubuntu, sudo apt-get install python3-dev)
  3. Numpy pip3 install numpy
  4. Cython pip3 install cython
  5. Optionally, OpenCV 3.x with Python bindings. (Tested on OpenCV 3.4.0)
    • You can use this script to automate Open CV 3.4 installation (Tested on Ubuntu 16.04).
    • Performance of this approach is better than not using OpenCV.
    • Installations from PyPI distributions does not use OpenCV.
NOTE: OpenCV 3.4.1 has a bug which causes Darknet to fail. Therefore this wrapper would not work with OpenCV 3.4.1.
More details are available at https://github.com/pjreddie/darknet/issues/502

Installation

Installation from PyPI distribution (as described below) is the most convenient approach if you intend to use yolo34py for your projects.

Installation of CPU Only Version

python3 -m pip install yolo34py

Installation of GPU Accelerated Version

python3 -m pip install yolo34py-gpu
NOTE: PyPI Deployments does not use OpenCV due to complexity involved in installation. 
To get best performance, it is recommended to install from source with OpenCV enabled.
NOTE: Make sure CUDA_HOME environment variable is set.

How to run demos in local machine?

  1. If you have not installed already, run python3 setup.py build_ext --inplace to install library locally.
  2. Download "yolov3" model file and config files using sh download_models.sh.
  3. Run python3 webcam_demo.py, python3 video_demo.py or python3 image_demo.py

How to run demo using docker?

  1. Navigate to docker directory.
  2. Copy sample images into the input directory. Or else run input/download_sample_images.sh
  3. Run sh run.sh or sh run-gpu.sh
  4. Observe the outputs generated in output directory.
GPU Version requires nvidia-docker

Installation from Source

  1. Set environment variables
  • To enable GPU acceleration, export GPU=1.
  • To enable OpenCV, export OPENCV=1
  1. Navigate to ./src and run pip3 install . to install library.

Using a custom version of Darknet

  1. Set environment variable DARKNET_HOME to download location of darknet.
  2. Add DARKNET_HOME to LD_LIBRARY_PATH. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$DARKNET_HOME
  3. Continue instructions for installation from source.

Having trouble?

Kindly raise your issues in the issues section of GitHub repository.

Like to contribute?

Feel free to send PRs or discuss on possible future improvements in issues section. Your contributions are most welcome!

Looking for YOLO v4?

https://github.com/AlexeyAB/darknet

yolo3-4-py's People

Contributors

akshaykulkarni07 avatar arielszabo avatar csiebler avatar madhawav avatar remilacroix-idris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yolo3-4-py's Issues

Detection time

Hi, I have installed yolo34py-gpu package through pip and tested webcam_demo.py code.

Elapsed time for results = net.detect(dark_frame) is around 9.2s.

I changed it to use yolov3-tiny (downloaded from https://pjreddie.com/darknet/yolo/) and elapsed time reduced to 0.89s. But this processing time stills high for me.

What can I do to improve performance of detection step?

Thanks.

pydarknet.cpp:583:10: fatal error: 'ios' file not found

Couldn't compile package neither from source nor from install from pip.

mac OS: 10.14.2
numpy: 1.15.2
cython: 0.28.5

$ pip install .
Processing /Users/m_nny/work/top/utils/YOLO3-4-Py
Requirement already satisfied: cython>=0.27 in /usr/local/anaconda3/envs/top/lib/python3.5/site-packages (from yolo34py==0.1rc13) (0.28.5)
Requirement already satisfied: requests in /usr/local/anaconda3/envs/top/lib/python3.5/site-packages (from yolo34py==0.1rc13) (2.21.0)
Requirement already satisfied: numpy in /usr/local/anaconda3/envs/top/lib/python3.5/site-packages (from yolo34py==0.1rc13) (1.15.2)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/anaconda3/envs/top/lib/python3.5/site-packages (from requests->yolo34py==0.1rc13) (2018.8.24)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/anaconda3/envs/top/lib/python3.5/site-packages (from requests->yolo34py==0.1rc13) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/anaconda3/envs/top/lib/python3.5/site-packages (from requests->yolo34py==0.1rc13) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/anaconda3/envs/top/lib/python3.5/site-packages (from requests->yolo34py==0.1rc13) (3.0.4)
Building wheels for collected packages: yolo34py
  Running setup.py bdist_wheel for yolo34py ... error
  Complete output from command /usr/local/anaconda3/envs/top/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/37/k7yxvg994lvbkd47tlyxby7r0000gn/T/pip-req-build-fgfk0ifb/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/37/k7yxvg994lvbkd47tlyxby7r0000gn/T/pip-wheel-3c59cci_ --python-tag cp35:
  INFO:root:Selected Darknet Branch: yolo34py-intergration-nogpu-v2 from Darknet Fork 'https://github.com/madhawav/darknet/'
  /usr/local/anaconda3/envs/top/lib/python3.5/site-packages/setuptools/dist.py:398: UserWarning: Normalizing '0.1.rc13' to '0.1rc13'
    normalized_version,
  running bdist_wheel
  running build
  INFO:root:Temp Path: /var/folders/37/k7yxvg994lvbkd47tlyxby7r0000gn/T/darknet
  INFO:root:Downloading darknet
  INFO:root:Extracting darknet
  INFO:root:Building darknet
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/gemm.c -o obj/gemm.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/utils.c -o obj/utils.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/cuda.c -o obj/cuda.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/deconvolutional_layer.c -o obj/deconvolutional_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/convolutional_layer.c -o obj/convolutional_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/list.c -o obj/list.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/image.c -o obj/image.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/activations.c -o obj/activations.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/im2col.c -o obj/im2col.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/col2im.c -o obj/col2im.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/blas.c -o obj/blas.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/crop_layer.c -o obj/crop_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/dropout_layer.c -o obj/dropout_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/maxpool_layer.c -o obj/maxpool_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/softmax_layer.c -o obj/softmax_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/data.c -o obj/data.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/matrix.c -o obj/matrix.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/network.c -o obj/network.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/connected_layer.c -o obj/connected_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/cost_layer.c -o obj/cost_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/parser.c -o obj/parser.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/option_list.c -o obj/option_list.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/detection_layer.c -o obj/detection_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/route_layer.c -o obj/route_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/upsample_layer.c -o obj/upsample_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/box.c -o obj/box.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/normalization_layer.c -o obj/normalization_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/avgpool_layer.c -o obj/avgpool_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/layer.c -o obj/layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/local_layer.c -o obj/local_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/shortcut_layer.c -o obj/shortcut_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/logistic_layer.c -o obj/logistic_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/activation_layer.c -o obj/activation_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/rnn_layer.c -o obj/rnn_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/gru_layer.c -o obj/gru_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/crnn_layer.c -o obj/crnn_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/demo.c -o obj/demo.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/batchnorm_layer.c -o obj/batchnorm_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/region_layer.c -o obj/region_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/reorg_layer.c -o obj/reorg_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/tree.c -o obj/tree.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/lstm_layer.c -o obj/lstm_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/l2norm_layer.c -o obj/l2norm_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/yolo_layer.c -o obj/yolo_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./src/iseg_layer.c -o obj/iseg_layer.o'
  INFO:root:b'gcc -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -shared obj/gemm.o obj/utils.o obj/cuda.o obj/deconvolutional_layer.o obj/convolutional_layer.o obj/list.o obj/image.o obj/activations.o obj/im2col.o obj/col2im.o obj/blas.o obj/crop_layer.o obj/dropout_layer.o obj/maxpool_layer.o obj/softmax_layer.o obj/data.o obj/matrix.o obj/network.o obj/connected_layer.o obj/cost_layer.o obj/parser.o obj/option_list.o obj/detection_layer.o obj/route_layer.o obj/upsample_layer.o obj/box.o obj/normalization_layer.o obj/avgpool_layer.o obj/layer.o obj/local_layer.o obj/shortcut_layer.o obj/logistic_layer.o obj/activation_layer.o obj/rnn_layer.o obj/gru_layer.o obj/crnn_layer.o obj/demo.o obj/batchnorm_layer.o obj/region_layer.o obj/reorg_layer.o obj/tree.o obj/lstm_layer.o obj/l2norm_layer.o obj/yolo_layer.o obj/iseg_layer.o -o libdarknet.so -lm -pthread'
  INFO:root:b'ar rcs libdarknet.a obj/gemm.o obj/utils.o obj/cuda.o obj/deconvolutional_layer.o obj/convolutional_layer.o obj/list.o obj/image.o obj/activations.o obj/im2col.o obj/col2im.o obj/blas.o obj/crop_layer.o obj/dropout_layer.o obj/maxpool_layer.o obj/softmax_layer.o obj/data.o obj/matrix.o obj/network.o obj/connected_layer.o obj/cost_layer.o obj/parser.o obj/option_list.o obj/detection_layer.o obj/route_layer.o obj/upsample_layer.o obj/box.o obj/normalization_layer.o obj/avgpool_layer.o obj/layer.o obj/local_layer.o obj/shortcut_layer.o obj/logistic_layer.o obj/activation_layer.o obj/rnn_layer.o obj/gru_layer.o obj/crnn_layer.o obj/demo.o obj/batchnorm_layer.o obj/region_layer.o obj/reorg_layer.o obj/tree.o obj/lstm_layer.o obj/l2norm_layer.o obj/yolo_layer.o obj/iseg_layer.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/captcha.c -o obj/captcha.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/lsd.c -o obj/lsd.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/super.c -o obj/super.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/art.c -o obj/art.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/tag.c -o obj/tag.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/cifar.c -o obj/cifar.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/go.c -o obj/go.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/rnn.c -o obj/rnn.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/segmenter.c -o obj/segmenter.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/regressor.c -o obj/regressor.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/classifier.c -o obj/classifier.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/coco.c -o obj/coco.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/yolo.c -o obj/yolo.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/detector.c -o obj/detector.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/nightmare.c -o obj/nightmare.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/instance-segmenter.c -o obj/instance-segmenter.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast -c ./examples/darknet.c -o obj/darknet.o'
  INFO:root:b'gcc -Iinclude/ -Isrc/ -Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC -Ofast obj/captcha.o obj/lsd.o obj/super.o obj/art.o obj/tag.o obj/cifar.o obj/go.o obj/rnn.o obj/segmenter.o obj/regressor.o obj/classifier.o obj/coco.o obj/yolo.o obj/detector.o obj/nightmare.o obj/instance-segmenter.o obj/darknet.o libdarknet.a -o darknet -lm -pthread  libdarknet.a'
  INFO:root:Darknet building successful
  INFO:root:Moving to /private/var/folders/37/k7yxvg994lvbkd47tlyxby7r0000gn/T/pip-req-build-fgfk0ifb/__libdarknet/libdarknet.so
  running build_py
  creating build
  creating build/lib.macosx-10.6-x86_64-3.5
  creating build/lib.macosx-10.6-x86_64-3.5/__libdarknet
  copying __libdarknet/__init__.py -> build/lib.macosx-10.6-x86_64-3.5/__libdarknet
  running egg_info
  creating yolo34py.egg-info
  writing yolo34py.egg-info/PKG-INFO
  writing top-level names to yolo34py.egg-info/top_level.txt
  writing requirements to yolo34py.egg-info/requires.txt
  writing dependency_links to yolo34py.egg-info/dependency_links.txt
  writing manifest file 'yolo34py.egg-info/SOURCES.txt'
  reading manifest file 'yolo34py.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching 'pydarknet.cpp'
  writing manifest file 'yolo34py.egg-info/SOURCES.txt'
  copying __libdarknet/libdarknet.so -> build/lib.macosx-10.6-x86_64-3.5/__libdarknet
  running build_ext
  cythoning pydarknet.pyx to pydarknet.cpp
  building 'pydarknet' extension
  creating build/temp.macosx-10.6-x86_64-3.5
  /usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/anaconda3/envs/top/include -arch x86_64 -I/usr/local/anaconda3/envs/top/include -arch x86_64 -DUSE_GPU=0 -DUSE_CV=0 -I/usr/local/anaconda3/envs/top/lib/python3.5/site-packages/numpy/core/include -I/var/folders/37/k7yxvg994lvbkd47tlyxby7r0000gn/T/darknet/darknet-yolo34py-intergration-nogpu-v2/include -I/var/folders/37/k7yxvg994lvbkd47tlyxby7r0000gn/T/darknet/darknet-yolo34py-intergration-nogpu-v2/src -I/usr/local/anaconda3/envs/top/include/python3.5m -c pydarknet.cpp -o build/temp.macosx-10.6-x86_64-3.5/pydarknet.o -I/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/include/python3.7m
  warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
  In file included from pydarknet.cpp:581:
  In file included from /usr/local/anaconda3/envs/top/lib/python3.5/site-packages/numpy/core/include/numpy/arrayobject.h:4:
  In file included from /usr/local/anaconda3/envs/top/lib/python3.5/site-packages/numpy/core/include/numpy/ndarrayobject.h:18:
  In file included from /usr/local/anaconda3/envs/top/lib/python3.5/site-packages/numpy/core/include/numpy/ndarraytypes.h:1823:
  /usr/local/anaconda3/envs/top/lib/python3.5/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: "Using deprecated NumPy API, disable it by "          "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
  #warning "Using deprecated NumPy API, disable it by " \
   ^
  pydarknet.cpp:583:10: fatal error: 'ios' file not found
  #include "ios"
           ^~~~~
  2 warnings and 1 error generated.
  error: command '/usr/bin/clang' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for yolo34py

Library not loaded: libdarknet.so

I tried
ython3 webcam_demo.py
but I get following error

Traceback (most recent call last):
  File "webcam_demo.py", line 3, in <module>
    from pydarknet import Detector, Image
ImportError: dlopen(/usr/local/lib/python3.6/site-packages/pydarknet.cpython-36m-darwin.so, 2): Library not loaded: libdarknet.so
  Referenced from: /usr/local/lib/python3.6/site-packages/pydarknet.cpython-36m-darwin.so
  Reason: image not found

Same error for python3 video_demo.py & python3 image_demo.py

Used following

export GPU=0
export OPENCV=1

pip3 install .

every thing goes well. Here is the out put

Requirement already satisfied: cython>=0.27 in /usr/local/lib/python3.6/site-packages (from yolo34py==0.1rc13) (0.29)
Requirement already satisfied: requests in /usr/local/lib/python3.6/site-packages (from yolo34py==0.1rc13) (2.19.1)
Requirement already satisfied: numpy in /usr/local/lib/python3.6/site-packages (from yolo34py==0.1rc13) (1.14.3)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages (from requests->yolo34py==0.1rc13) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests->yolo34py==0.1rc13) (2018.8.24)
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests->yolo34py==0.1rc13) (2.7)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests->yolo34py==0.1rc13) (1.23)
Building wheels for collected packages: yolo34py
  Running setup.py bdist_wheel for yolo34py ... done
  Stored in directory: /Users/hassan/Library/Caches/pip/wheels/ba/80/9f/dbdc9f738d39bcfc2fac53f164c193666ff9038acc658a9824
Successfully built yolo34py
Installing collected packages: yolo34py
  Found existing installation: yolo34py 0.1rc12
    Uninstalling yolo34py-0.1rc12:
      Successfully uninstalled yolo34py-0.1rc12
Successfully installed yolo34py-0.1rc13
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Setup.py -- ModuleNotFoundError: No module named 'util

Hi, I've got Python 3.7.0, Numpy and Cython installed, however when I run the script :

python3 setup.py build_ext --inplace

I keep getting "ModuleNotFoundError: No module named 'util'". Its coming from the line -
from util import build_darknet, clean_darknet, get_cflags, get_libs, find_site_packages, get_readme, find_dist_packages

Can someone please help me with this. I am running the setup.py file from within a folder.

Training

Hi, does the wrapper support training?

Thanks

Installation fails

OS: Ubuntu 16.04
Notes: I used python setup.py clean as it worked a few weeks ago. Though now it does not work.
Error:
INFO:root:Darknet building successful
INFO:root:Moving to /home/nvd/Downloads/YOLO3-4-Py/__libdarknet/libdarknet.so
skipping 'pydarknet.cpp' Cython extension (up-to-date)
building 'pydarknet' extension
gcc -pthread -B /home/nvd/anaconda3/envs/tensorflow_10/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE_GPU=0 -DUSE_CV=0 -I/home/nvd/anaconda3/envs/tensorflow_10/lib/python3.6/site-packages/numpy/core/include -I/tmp/darknet/darknet-yolo34py-intergration-nogpu-v2/include -I/tmp/darknet/darknet-yolo34py-intergration-nogpu-v2/src -I/home/nvd/anaconda3/envs/tensorflow_10/include/python3.6m -c pydarknet.cpp -o build/temp.linux-x86_64-3.6/pydarknet.o
gcc: error: : No such file or directory
error: command 'gcc' failed with exit status 1

Installing YOLO3-4-PY from source with GPU enabled.

Hello,

when I activate GPU support in setup.py and I do:
sudo pip3 install .

I get the following error in the compilation:

/bin/sh: 1: nvcc: not found
make: *** [obj/convolutional_kernels.o] Error 127

I can compile darknet from the sources, and in my .bashrc I have the path for CUDA:

export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/

I also tried to install YOLO3-4-PY with a pre-downloaded version of darknet and I get the same error.

Any idea on who I can solve that? I guess is not finding the cuda library but I'm not sure where is missing that reference.

Thanks and regards.

Tiny yolo

How can you modify the script to use tiny yolo weights instead? In the original it was: ./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg

fps really low

Hi i installed gpu version following the instructions but I get very slow fps.It seems my gpu is not being used.Please help.

Removing time.time() messes up bounding boxes

I came across this mind boggling issue. For my own yolov3 model for a custom dataset (which works absolutely fine with darknet) the bounding boxes are not plotted in place of the object when I move the object around. (Especially when the object is around the coordinates x <= 300 y <= 100 for my webcam where the opecv frame has shape (480, 640, 3) )
Your script works absolutely fine when I dont comment out the start_time = time.time() statement. Please help. This error is disturbing cause I dont understand.

I used your webcam example:

import time

from pydarknet import Detector, Image
import cv2

if __name__ == "__main__":
# Optional statement to configure preferred GPU. Available only in GPU version.
# pydarknet.set_cuda_device(0)

net = Detector(bytes("cfg/yolov3.cfg", encoding="utf-8"), bytes("weights/yolov3.weights", encoding="utf-8"), 0,
               bytes("cfg/coco.data", encoding="utf-8"))

cap = cv2.VideoCapture(0)

while True:
    r, frame = cap.read()
    if r:
        # start_time = time.time()

        # Only measure the time taken by YOLO and API Call overhead

        dark_frame = Image(frame)
        results = net.detect(dark_frame)
        del dark_frame

        # end_time = time.time()
        # print("Elapsed Time:",end_time-start_time)

        for cat, score, bounds in results:
            x, y, w, h = bounds
            cv2.rectangle(frame, (int(x-w/2),int(y-h/2)),(int(x+w/2),int(y+h/2)),(255,0,0))
            cv2.putText(frame, str(cat.decode("utf-8")), (int(x), int(y)), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 0))

        cv2.imshow("preview", frame)

    k = cv2.waitKey(1)
    if k == 0xFF & ord("q"):
        break

Commenting start_time = time.time()
screenshot from 2018-10-24 00-14-39

Uncommenting start_time = time.time()
screenshot from 2018-10-24 00-16-16

performance issue

Appreciate the python wrapper, nice work.

I am curious if there is a configuration that would improve performance.

When I invoke ./dark-net detect demo /foo/video.mp4 my setup gets around ~20 fps using yolov3-tiny.cfg and yolov3-tiny.weights on a Jetson TX2.

when I run python3 video_demo.py with the same parameters and same video it appears to be in the ~5 fps. Below is the setup

I have tried with both python3.5 and python3.6, python3.6 appears to be a bit faster.
...
net = Detector(bytes("cfg/yolov3-tiny.cfg", encoding="utf-8"), bytes("weights/yolov3-tiny.weights", encoding="utf-8"), 0,
bytes("cfg/coco.data", encoding="utf-8"))
...

Any thoughts why? Thanks in advance for your support.

AWS Lambda Implementation

Have you / anyone been able to implement this in an AWS lambda, such that when a new photo is uploaded, a lambda would run the yolo on the new image?

How can I ignore the cat I don't want to detect.

I have trained my model using Darknet yolo-tiny model and I would like to ignore the objects I don't want to detect.
Is there a way to do that?

Also, is there a way to track the object after it is detected, any suggestion would be appreciated.

Thanks

Library not loaded: libdarknet.so

After installing this library from source (setting OPENCV=1 and DARKNET_HOME to the source directory of darknet, which I cloned from the darknet repo and ran make on), when running import pydarknet, I get the following output:

>>> import pydarknet
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pydarknet.cpython-36m-darwin.so, 2): Library not loaded: libdarknet.so
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pydarknet.cpython-36m-darwin.so
  Reason: image not found

What's going on? Thanks!

importerror pydarknet

Problem: Cannot import pydarknet
Mac OS 10.13.4
Python 3.5.0

Installation by instruction


$ pip install yolo34py
Collecting yolo34py
Requirement already satisfied: requests in /anaconda3/envs/sleip/lib/python3.5/site-packages/requests-2.19.1-py3.5.egg (from yolo34py) (2.19.1)
Requirement already satisfied: numpy in /anaconda3/envs/sleip/lib/python3.5/site-packages (from yolo34py) (1.15.2)
Requirement already satisfied: cython>=0.27 in /anaconda3/envs/sleip/lib/python3.5/site-packages (from yolo34py) (0.28.5)
Requirement already satisfied: certifi>=2017.4.17 in /anaconda3/envs/sleip/lib/python3.5/site-packages (from requests->yolo34py) (2018.8.24)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /anaconda3/envs/sleip/lib/python3.5/site-packages/chardet-3.0.4-py3.5.egg (from requests->yolo34py) (3.0.4)
Requirement already satisfied: idna<2.8,>=2.5 in /anaconda3/envs/sleip/lib/python3.5/site-packages/idna-2.7-py3.5.egg (from requests->yolo34py) (2.7)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /anaconda3/envs/sleip/lib/python3.5/site-packages/urllib3-1.23-py3.5.egg (from requests->yolo34py) (1.23)
Installing collected packages: yolo34py
Successfully installed yolo34py-0.1rc12


Python


from pydarknet import Detector, Image

ImportError Traceback (most recent call last) <ipython-input-2-16743eae4a3b> in <module> ----> 1 from pydarknet import Detector, Image

ImportError: dlopen(/anaconda3/envs/sleip/lib/python3.5/site-packages/pydarknet.cpython-35m-darwin.so, 2): Library not loaded: libdarknet.so Referenced from: /anaconda3/envs/sleip/lib/python3.5/site-packages/pydarknet.cpython-35m-darwin.so Reason: image not found


Envirionment (sorry for formatting)


$ conda list
packages in environment at /anaconda3/envs/sleip:

Name Version Build Channel
absl-py 0.5.0
appnope 0.1.0
argparse 1.4.0
astor 0.7.1
backcall 0.1.0
ca-certificates 2018.03.07 0
certifi 2018.8.24 py35_1
chardet 3.0.4
cloudpickle 0.6.1
cycler 0.10.0
Cython 0.28.5
dask 0.19.4
decorator 4.3.0
dill 0.2.7.1
fire 0.1.3
gast 0.2.0
grpcio 1.15.0
h5py 2.8.0
idna 2.7
ipykernel 5.1.0
ipython 7.0.1
ipython-genutils 0.2.0
jedi 0.13.1
jupyter-client 5.2.3
jupyter-core 4.4.0
Keras-Applications 1.0.6
Keras-Preprocessing 1.0.5
kiwisolver 1.0.1
libcxx 4.0.1 h579ed51_0
libcxxabi 4.0.1 hebd6815_0
libedit 3.1.20170329 hb402a30_2
Markdown 3.0.1
matplotlib 3.0.0
msgpack 0.5.6
msgpack-numpy 0.4.4.1
ncurses 6.1 h0a44026_0
networkx 2.2
numpy 1.15.2
opencv-python 3.4.0.14
openssl 1.0.2p h1de35cc_0
parso 0.3.1
pexpect 4.6.0
pickleshare 0.7.5
Pillow 5.3.0
pip 10.0.1 py35_0
prompt-toolkit 2.0.5
protobuf 3.6.1
psutil 5.4.7
ptyprocess 0.6.0
pyarrow 0.11.0
Pygments 2.2.0
pyparsing 2.2.2
python 3.5.0 1
python-dateutil 2.7.3
PyWavelets 1.0.1
pyzmq 17.1.2
readline 6.2 2
requests 2.19.1
scikit-image 0.14.1
scipy 1.1.0
setuptools 39.1.0
setuptools 40.2.0 py35_0
simplegeneric 0.8.1
six 1.11.0
slidingwindow 0.0.13
sqlite 3.25.2 ha441bb4_0
tensorboard 1.11.0
tensorflow 1.11.0
tensorpack 0.8.9
termcolor 1.1.0
tf-pose 0.1.1
tk 8.5.18 0
toolz 0.9.0
tornado 5.1.1
tqdm 4.26.0
traitlets 4.3.2
urllib3 1.23
wcwidth 0.1.7
Werkzeug 0.14.1
wheel 0.31.1 py35_0
xz 5.0.5 1
yolo34py 0.1rc12
zlib 1.2.11 hf3cbc9b_2


Yolo9000

How could you compile this so it detects 9000 different classes?
EDIT:
I managed to do it, by downloading appropriate weights and labels. The thing is, when I run nvidia-smi:

image
I see that it uses only ~1400 out of 8110MB of GPU memory. The version with only 80 classes uses almost the whole memory. Do you know if this is normal, and if not how can it be solved?
Thanks

ImportError (library not loaded) at runtime

I get this error at runtime:

Traceback (most recent call last):
File "/Users/zulu/docs/projets/dev/python/yolo-computer-vision/YOLO3-4-Py/video_demo.py", line 3, in <module>
from pydarknet import Detector, Image
ImportError: dlopen(/usr/local/lib/python3.7/site-packages/pydarknet.cpython-37m-darwin.so, 2): Library not loaded: libdarknet.so
Referenced from: /usr/local/lib/python3.7/site-packages/pydarknet.cpython-37m-darwin.so
Reason: image not found

Environment

MacOS 10.13.5
Python 3.7
CUDA SDK 9.2 (note: I do have a nvidia GPU)
OpenCV 3.4.2

Installation

I installed from source to get OpenCV support.
Followed these steps:
pip3 install numpy
brew install opencv
export CUDA_HOME=/usr/local/cuda
export PATH=${CUDA_HOME}/bin:${PATH}
export LD_LIBRARY_PATH=${CUDA_HOME}/lib:$LD_LIBRARY_PATH
export GPU=1
export OPENCV=1
git clone https://github.com/madhawav/YOLO3-4-Py.git
cd YOLO3-4-Py/
pip3 install . --verbose

This is the full output of the install process:
Output

Problem when compiling PyDarknet

Hi,
I'm currently not being able to compile the Cython module. I followed the installation instructions, but after running the command python3 setup.py build_ext --inplace, I get the following error:

python setup.py build_ext --inplace
/home/user/anaconda3/envs/tensorflow-gpu/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'install_requires'
  warnings.warn(msg)
running build_ext
cythoning pydarknet.pyx to pydarknet.cpp
building 'pydarknet' extension
creating build
creating build/temp.linux-x86_64-3.5
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DUSE_CV=1 -I/home/user/anaconda3/envs/tensorflow-gpu/lib/python3.5/site-packages/numpy/core/include -I/home/user/darknet/include -I/home/user/darknet/src -I/home/user/anaconda3/envs/tensorflow-gpu/include/python3.5m -c pydarknet.cpp -o build/temp.linux-x86_64-3.5/pydarknet.o 
gcc: error: : No such file or directory
error: command 'gcc' failed with exit status 1

I should also mention that I'm using conda to manage the required packages. Do you have any idea of what the problem is?
Thanks in advance!

How can I count the detected objects

Hello, I'm searching how to count detected objects that cross a ROI Line (Line of interest). Have anyone do that with this Wraped YOLO application? Thanks!

pydarknet.cpp functions not declared in scope.

Hi, I keep getting the following error while trying to compile the freshly clone repo using python3 setup.py build_ext --inplace command.

 #warning "Using deprecated NumPy API, disable it by " \
  ^
pydarknet.cpp: In function ‘PyObject* __pyx_pf_9pydarknet_8Detector_2forward(__pyx_obj_9pydarknet_Detector*, __pyx_obj_9pydarknet_Image*, int)’:
pydarknet.cpp:3209:95: error: ‘network_predict_image_batch’ was not declared in this scope
   (void)(network_predict_image_batch(__pyx_v_self->net, __pyx_v_image->img, __pyx_v_batch_size));
                                                                                               ^
pydarknet.cpp: In function ‘PyObject* __pyx_pf_9pydarknet_8Detector_4get_boxes(__pyx_obj_9pydarknet_Detector*, int, float, float, float)’:
pydarknet.cpp:3465:182: error: ‘get_network_boxes_ibatch’ was not declared in this scope
   __pyx_v_dets = get_network_boxes_ibatch(__pyx_v_self->net, __pyx_v_self->im_w, __pyx_v_self->im_h, __pyx_v_thresh, __pyx_v_hier_thresh, ((int *)0), 0, __pyx_v_pnum, __pyx_v_ibatch);
                                                                                                                                                                                      ^
pydarknet.cpp: In function ‘PyObject* __pyx_pf_9pydarknet_8Detector_6get_logits(__pyx_obj_9pydarknet_Detector*)’:
pydarknet.cpp:3813:135: error: ‘get_yolo_logits’ was not declared in this scope
   __pyx_v_num = get_yolo_logits(__pyx_v_self->net, __pyx_v_pbatch, __pyx_v_pw, __pyx_v_ph, __pyx_v_pn, __pyx_v_pclassp5, __pyx_v_pdata);

according to opencv_version I get 3.4.3

Can anyone please help me out.

Suspected memory leak

Hi, thank you for sharing your python wrapper for darknet. This is very useful to us.

We are currently doing a bench-marking experiment using your library, which includes setting different input image sizes in the cfg file and finding the performance in terms of speed.

However, we seem to be observing that as we repeatedly load a new network (with a new cfg) in a for loop, the GPU memory usage steadily increase each round, even as we went from a larger input image size to a smaller one.

Here's our test script for reference:

from io import BytesIO
import numpy as np
import requests
import cv2
import time

from pydarknet import Detector, Image
from check_input_size import check_input_size_range
from set_input_size import set_input_size

im_path = 'frame0001.jpg'
img = cv2.imread(im_path)
img = Image(img)
cfg = 'yolo/cfg/yolov3.cfg'
data_file = 'yolo/cfg/coco.data'
wts = 'yolo/weights/yolov3.weights'

min_size = 40
max_size = 1000
sizes, _ = check_input_size_range(cfg, min_size, max_size)
print('Will run for {} sizes'.format(len(sizes)))
sizes = list(reversed(sizes))

repeat = 100
for size in sizes:
    set_input_size(cfg=cfg, new_cfg=cfg, size=size)
    net = Detector(bytes("yolo/cfg/yolov3.cfg", encoding="utf-8"), 
                   bytes("yolo/weights/yolov3.weights", encoding="utf-8"), 
                   1,
                   bytes("yolo/cfg/coco.data", encoding="utf-8"))
    duration = 0
    img = cv2.imread(im_path)
    img = Image(img)
    for i in range(repeat):
        print('Repeating {: >4}th time for size {: <4}'.format(i+1, size), end='\r')
        tic = time.time()
        results = net.detect(img)
        toc = time.time()
        duration = ( (toc-tic) + i * duration )/(i+1)
    with open('temp.log','a') as f:
        f.write('{}:{}\n'.format(size, duration))
    net = None
    img = None
    results = None

set_input_size is a simple function that goes into the cfg file to change the size of the input image specified there for varying sizes that are valid.

As we loop through the for loop, we observe the GPU memory usage slowly rising by around 20+MB each round. We added print statement in the .pyx file to check that the network and image variables are getting freed and they are correctly freed at the end of each round. Therefore we are not sure if its something else whose memory is not getting freed.

This is not a big issue now, but just concerned if the memory leak might be a problem in the future. Any ideas? Thank you!

Scores

Hi! I have 2 questions.

  1. What does zero mean in this line?

    net = Detector(bytes("cfg/yolov3.cfg", encoding="utf-8"), bytes("weights/yolov3.weights", encoding="utf-8"), 0,
    bytes("cfg/coco.data", encoding="utf-8"))

  2. How I can only detect object with score>n (f.e. 0.7)

Thanks!

error with build_ext

Hi,
I installed all the dependencies and opencv 3.4.0. When I tried to build using the command 'python3 setup.py build_ext --inplace ', I got the following error:

running build_ext
skipping 'pydarknet.cpp' Cython extension (up-to-date)
building 'pydarknet' extension
gcc -pthread -B /home/paperspace/anaconda3/envs/fastai/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/numpy/core/include -I/home/paperspace/Desktop/Yolo/darknet_pjreddie/include -I/home/paperspace/Desktop/Yolo/darknet_pjreddie/src -I/home/paperspace/anaconda3/envs/fastai/include/python3.6m -c pydarknet.cpp -o build/temp.linux-x86_64-3.6/pydarknet.o -I/usr/include/opencv -I/usr/include/python3.5m -I/usr/include/x86_64-linux-gnu/python3.5m
cc1plus: warning: command line option \u2018-Wstrict-prototypes\u2019 is valid for C/ObjC but not for C++
In file included from /home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1809:0,
from /home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
from /home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from pydarknet.cpp:499:
/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by "
^
gcc -pthread -B /home/paperspace/anaconda3/envs/fastai/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/paperspace/anaconda3/envs/fastai/lib/python3.6/site-packages/numpy/core/include -I/home/paperspace/Desktop/Yolo/darknet_pjreddie/include -I/home/paperspace/Desktop/Yolo/darknet_pjreddie/src -I/home/paperspace/anaconda3/envs/fastai/include/python3.6m -c bridge.cpp -o build/temp.linux-x86_64-3.6/bridge.o -I/usr/include/opencv -I/usr/include/python3.5m -I/usr/include/x86_64-linux-gnu/python3.5m
cc1plus: warning: command line option \u2018-Wstrict-prototypes\u2019 is valid for C/ObjC but not for C++
g++ -pthread -shared -B /home/paperspace/anaconda3/envs/fastai/compiler_compat -L/home/paperspace/anaconda3/envs/fastai/lib -Wl,-rpath=/home/paperspace/anaconda3/envs/fastai/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.6/pydarknet.o build/temp.linux-x86_64-3.6/bridge.o -L/home/paperspace/Desktop/Yolo/darknet_pjreddie/ -ldarknet -lm -lpthread -o /home/paperspace/Desktop/Yolo/YOLO3-4-Py/pydarknet.cpython-36m-x86_64-linux-gnu.so /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so -lopencv_calib3d /usr/lib/x86_64-linux-gnu/libopencv_contrib.so -lopencv_contrib /usr/lib/x86_64-linux-gnu/libopencv_core.so -lopencv_core /usr/lib/x86_64-linux-gnu/libopencv_features2d.so -lopencv_features2d /usr/lib/x86_64-linux-gnu/libopencv_flann.so -lopencv_flann /usr/lib/x86_64-linux-gnu/libopencv_gpu.so -lopencv_gpu /usr/lib/x86_64-linux-gnu/libopencv_highgui.so -lopencv_highgui /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so -lopencv_imgproc /usr/lib/x86_64-linux-gnu/libopencv_legacy.so -lopencv_legacy /usr/lib/x86_64-linux-gnu/libopencv_ml.so -lopencv_ml /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so -lopencv_objdetect /usr/lib/x86_64-linux-gnu/libopencv_ocl.so -lopencv_ocl /usr/lib/x86_64-linux-gnu/libopencv_photo.so -lopencv_photo /usr/lib/x86_64-linux-gnu/libopencv_stitching.so -lopencv_stitching /usr/lib/x86_64-linux-gnu/libopencv_superres.so -lopencv_superres /usr/lib/x86_64-linux-gnu/libopencv_ts.so -lopencv_ts /usr/lib/x86_64-linux-gnu/libopencv_video.so -lopencv_video /usr/lib/x86_64-linux-gnu/libopencv_videostab.so -lopencv_videostab -lpython3.5m
g++: error: /usr/lib/x86_64-linux-gnu/libopencv_calib3d.so -lopencv_calib3d /usr/lib/x86_64-linux-gnu/libopencv_contrib.so -lopencv_contrib /usr/lib/x86_64-linux-gnu/libopencv_core.so -lopencv_core /usr/lib/x86_64-linux-gnu/libopencv_features2d.so -lopencv_features2d /usr/lib/x86_64-linux-gnu/libopencv_flann.so -lopencv_flann /usr/lib/x86_64-linux-gnu/libopencv_gpu.so -lopencv_gpu /usr/lib/x86_64-linux-gnu/libopencv_highgui.so -lopencv_highgui /usr/lib/x86_64-linux-gnu/libopencv_imgproc.so -lopencv_imgproc /usr/lib/x86_64-linux-gnu/libopencv_legacy.so -lopencv_legacy /usr/lib/x86_64-linux-gnu/libopencv_ml.so -lopencv_ml /usr/lib/x86_64-linux-gnu/libopencv_objdetect.so -lopencv_objdetect /usr/lib/x86_64-linux-gnu/libopencv_ocl.so -lopencv_ocl /usr/lib/x86_64-linux-gnu/libopencv_photo.so -lopencv_photo /usr/lib/x86_64-linux-gnu/libopencv_stitching.so -lopencv_stitching /usr/lib/x86_64-linux-gnu/libopencv_superres.so -lopencv_superres /usr/lib/x86_64-linux-gnu/libopencv_ts.so -lopencv_ts /usr/lib/x86_64-linux-gnu/libopencv_video.so -lopencv_video /usr/lib/x86_64-linux-gnu/libopencv_videostab.so -lopencv_videostab: No such file or directory
/home/paperspace/anaconda3/envs/fastai/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
error: command 'g++' failed with exit status 1

I didn't understand which file exactly it couldn't find

issue of show_image declaration

when i build project with the command "python3 setup.py install", I have following error

pydarknet.cpp:2164:46: error: too few arguments to function ‘int show_image(image, const char*, int)’
show_image(__pyx_v_self->img, __pyx_v_title);
screenshot from 2018-08-27 08-02-16

BTW, my OS is Ubuntu 18.04

Build fails due to change to `show_image` function in darknet

This change was made 15 days ago:

pjreddie/darknet@b13f67b#diff-06d7eaa529ff0d43e382b4b216f391c0L708

which leads to:

Step #0 - "yolo-3-4": pydarknet.cpp: In function 'PyObject* __pyx_pf_9pydarknet_5Image_2show_image(__pyx_obj_9pydarknet_Image*, char*)':
Step #0 - "yolo-3-4": pydarknet.cpp:2233:46: error: too few arguments to function 'int show_image(image, const char*, int)'
Step #0 - "yolo-3-4": show_image(__pyx_v_self->img, __pyx_v_title);
Step #0 - "yolo-3-4": ^
Step #0 - "yolo-3-4": In file included from bridge.h:9:0,
Step #0 - "yolo-3-4": from pydarknet.cpp:587:
Step #0 - "yolo-3-4": /darknet/include/darknet.h:713:5: note: declared here
Step #0 - "yolo-3-4": int show_image(image p, const char *name, int ms);
Step #0 - "yolo-3-4": ^
Step #0 - "yolo-3-4": error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Step #0 - "yolo-3-4": The command '/bin/sh -c python3 setup.py build_ext --inplace' returned a non-zero code: 1
Finished Step #0 - "yolo-3-4"
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: exit status 1
Step #0 - "yolo-3-4":

gcc: error: : No such file or directory

Hey,

I successfully compiled it a few days ago but due to ubuntu issues I had to repair it and that removed this library, so now I'm trying to install it again. But now I'm getting this:

ss

I've looked in the other issue as well and I also tried setting pkgconfig path but that didn't fix my issue. I tried installing the branch without opencv but same error occurred. When I try to install it through PyPi I get the same error. Can you please help me in figuring this out.

Thanks.

EDIT: Never mind. I didn't source the profile. Okay but now I'm getting a different error.

  • When I compile with Pjreddie's Darknet:
    ss2

  • When I compile with AlexeyAB's Darknet:
    ss3

Unable to import pydarknet

Hi I am getting following error

`>>> import pydarknet
Traceback (most recent call last):
File "", line 1, in
ImportError: /home/ntweat/Desktop/yolo/PyYOLOV3/pydarknet.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZN2cv8fastFreeEPv

`

Thanks for the wrapper

Error while installing yolo34py-gpu

I am having this error when installing via:
pip3 install yolo34py-gpu

Collecting yolo34py-gpu' 'Downloading' 'https://files.pythonhosted.org/packages/dc/a3/12c668e54109c5469a8312d757b357dda0b2efc2150043b76b58f6ba75c3/yolo34py-gpu-0.1rc12.tar.gz (66kB)' ' 100% |################################| 71kB 1.1MB/s' ' Complete output from command python setup.py egg_info:' ' Traceback (most recent call last):' 'File "", line 1, in ' 'File "C:\Users\Yuliia\AppData\Local\Temp\pip-install-v3jjunpq\yolo34py-gpu\setup.py", line 47, in ' ' if USE_CV & (get_libs("opencv") == '' or get_cflags("opencv") == ''):' 'File "C:\Users\Yuliia\AppData\Local\Temp\pip-install-v3jjunpq\yolo34py-gpu\util.py", line 85, in get_libs' ' proc = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE)' ' File "c:\program files\python 3.5\lib\subprocess.py", line 950, in init restore_signals, start_new_session)' ' File "c:\program files\python 3.5\lib\subprocess.py", line 1220, in _execute_child startupinfo)' ' FileNotFoundError: [WinError 2] The system cannot find the file specified'

SIGSEGV when creating a Detector

Hi !
First, thank you for your work !

I was first using the darknet python script, but with really poor performances. As yours seems better I am trying to use it but get a segfault each time I try to instantiate a Detector.

I have first installed your lib through PyPi, but it did not work. Then building it from source with my own build of Darknet, was successful when installing, but not working on execution, with always a segfault error. Apparently after running valgrind it may concern memory allocation ...

 Access not within mapped region at address 0x0
==18723==    at 0x16254939: free_network (in /home/pbreton/.local/lib/python3.6/site-packages/__libdarknet/libdarknet.so)
==18723==    by 0x15FE2FF8: __pyx_pf_9pydarknet_8Detector_6__dealloc__ (pydarknet.cpp:3157)
==18723==    by 0x15FE2FF8: __pyx_pw_9pydarknet_8Detector_7__dealloc__ (pydarknet.cpp:3142)
==18723==    by 0x15FE2FF8: __pyx_tp_dealloc_9pydarknet_Detector(_object*) (pydarknet.cpp:5861)
==18723==    by 0x15FE6FC7: __pyx_tp_new_9pydarknet_Detector(_typeobject*, _object*, _object*) (pydarknet.cpp:5847)
==18723==    by 0x5591FD4: ??? (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x558A64B: _PyObject_FastCallDict (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x5552B41: ??? (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x5522859: _PyEval_EvalFrameDefault (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x5552FC7: PyEval_EvalCodeEx (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x552240B: PyEval_EvalCode (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x55F2213: ??? (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x55F50AD: PyRun_FileExFlags (in /usr/lib/libpython3.6m.so.1.0)
==18723==    by 0x55F5294: PyRun_SimpleFileExFlags (in /usr/lib/libpython3.6m.so.1.0)

Do you have any idea ...?

Also, when building I always have the error (no matter the way I build, seems logical) from ld :
/usr/bin/ld: cannot find -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_photo -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann -lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto -lopencv_imgproc -lopencv_core

while all of my opencv libs are correct and accessible (just compiled darknet manually with it). However, when I enter myself the command line to compile it works. Do you know if python has any problems with rights or paths in order to link C libs ?

Thank you ...

GPU install fails

Hello,

I've been using this for a few weeks in CPU mode, and I really want to thank you, this is a wonderful project.

I just got a GPU and wanted to try it. I used pip3 install yolo34py-gpu per the README, but it failed. I got the same error when building from source as also suggested in the README. I'm not new to Python but I rarely encounter anything that uses compiled extensions, so I'm sort of at a loss for what's going wrong here...

# pip3 install yolo34py-gpu
Collecting yolo34py-gpu
  Downloading https://files.pythonhosted.org/packages/dc/a3/12c668e54109c5469a8312d757b357dda0b2efc2150043b76b58f6ba75c3/yolo34py-gpu-0.1rc12.tar.gz (66kB)
    100% |████████████████████████████████| 71kB 2.2MB/s 
Requirement already satisfied: cython>=0.27 in /usr/local/lib/python3.6/dist-packages (from yolo34py-gpu)
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from yolo34py-gpu)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from yolo34py-gpu)
Building wheels for collected packages: yolo34py-gpu
  Running setup.py bdist_wheel for yolo34py-gpu ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r4u4hlkr/yolo34py-gpu/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpstmf2ftlpip-wheel- --python-tag cp36:
  INFO:root:Selected Darknet Branch: yolo34py-intergration-nocv from Darknet Fork 'https://github.com/madhawav/darknet/'
  /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
    warnings.warn(msg)
  /usr/lib/python3/dist-packages/setuptools/dist.py:388: UserWarning: Normalizing '0.1.rc12' to '0.1rc12'
    normalized_version,
  running bdist_wheel
  running build
  INFO:root:Temp Path: /tmp/darknet
  INFO:root:Downloading darknet
  INFO:root:Extracting darknet
  INFO:root:Building darknet
  ERROR: No supported gcc/g++ host compiler found, but clang-3.8 is available.
         Use 'nvcc -ccbin clang-3.8' to use that instead.
  make: *** [obj/convolutional_kernels.o] Error 1
  running build_py
  INFO:root:Generating grammar tables from /usr/lib/python3.6/lib2to3/Grammar.txt
  INFO:root:Generating grammar tables from /usr/lib/python3.6/lib2to3/PatternGrammar.txt
  creating build
  creating build/lib.linux-x86_64-3.6
  creating build/lib.linux-x86_64-3.6/__libdarknet
  copying __libdarknet/__init__.py -> build/lib.linux-x86_64-3.6/__libdarknet
  running egg_info
  writing yolo34py_gpu.egg-info/PKG-INFO
  writing dependency_links to yolo34py_gpu.egg-info/dependency_links.txt
  writing requirements to yolo34py_gpu.egg-info/requires.txt
  writing top-level names to yolo34py_gpu.egg-info/top_level.txt
  reading manifest file 'yolo34py_gpu.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching '__libdarknet/libdarknet.so'
  writing manifest file 'yolo34py_gpu.egg-info/SOURCES.txt'
  running build_ext
  skipping 'pydarknet.cpp' Cython extension (up-to-date)
  building 'pydarknet' extension
  creating build/temp.linux-x86_64-3.6
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE_CV=0 -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/tmp/darknet/darknet-yolo34py-intergration-nocv/include -I/tmp/darknet/darknet-yolo34py-intergration-nocv/src -I/usr/include/python3.6m -c pydarknet.cpp -o build/temp.linux-x86_64-3.6/pydarknet.o -I/usr/include/python3.6m -I/usr/include/x86_64-linux-gnu/python3.6m
  In file included from /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1816:0,
                   from /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                   from /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                   from pydarknet.cpp:580:
  /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
   #warning "Using deprecated NumPy API, disable it by " \
    ^~~~~~~
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE_CV=0 -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/tmp/darknet/darknet-yolo34py-intergration-nocv/include -I/tmp/darknet/darknet-yolo34py-intergration-nocv/src -I/usr/include/python3.6m -c bridge.cpp -o build/temp.linux-x86_64-3.6/bridge.o -I/usr/include/python3.6m -I/usr/include/x86_64-linux-gnu/python3.6m
  x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/pydarknet.o build/temp.linux-x86_64-3.6/bridge.o -L. -L./__libdarknet -ldarknet -lm -lpthread -o build/lib.linux-x86_64-3.6/pydarknet.cpython-36m-x86_64-linux-gnu.so -lpython3.6m -Wl,-rpath,/usr/local/lib/python3.6/dist-packages/__libdarknet -Wl,-rpath,/usr/lib/python3/dist-packages/__libdarknet
  /usr/bin/ld: cannot find -ldarknet
  collect2: error: ld returned 1 exit status
  error: command 'x86_64-linux-gnu-g++' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for yolo34py-gpu
  Running setup.py clean for yolo34py-gpu
Failed to build yolo34py-gpu
Installing collected packages: yolo34py-gpu
  Running setup.py install for yolo34py-gpu ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r4u4hlkr/yolo34py-gpu/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v841beba-record/install-record.txt --single-version-externally-managed --compile:
    INFO:root:Selected Darknet Branch: yolo34py-intergration-nocv from Darknet Fork 'https://github.com/madhawav/darknet/'
    /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    /usr/lib/python3/dist-packages/setuptools/dist.py:388: UserWarning: Normalizing '0.1.rc12' to '0.1rc12'
      normalized_version,
    running install
    running build
    INFO:root:Temp Path: /tmp/darknet
    INFO:root:Downloading darknet
    INFO:root:Extracting darknet
    INFO:root:Building darknet
    ERROR: No supported gcc/g++ host compiler found, but clang-3.8 is available.
           Use 'nvcc -ccbin clang-3.8' to use that instead.
    make: *** [obj/convolutional_kernels.o] Error 1
    running build_py
    INFO:root:Generating grammar tables from /usr/lib/python3.6/lib2to3/Grammar.txt
    INFO:root:Generating grammar tables from /usr/lib/python3.6/lib2to3/PatternGrammar.txt
    creating build
    creating build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/__libdarknet
    copying __libdarknet/__init__.py -> build/lib.linux-x86_64-3.6/__libdarknet
    running egg_info
    writing yolo34py_gpu.egg-info/PKG-INFO
    writing dependency_links to yolo34py_gpu.egg-info/dependency_links.txt
    writing requirements to yolo34py_gpu.egg-info/requires.txt
    writing top-level names to yolo34py_gpu.egg-info/top_level.txt
    reading manifest file 'yolo34py_gpu.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching '__libdarknet/libdarknet.so'
    warning: no files found matching 'pydarknet.cpp'
    writing manifest file 'yolo34py_gpu.egg-info/SOURCES.txt'
    running build_ext
    cythoning pydarknet.pyx to pydarknet.cpp
    building 'pydarknet' extension
    creating build/temp.linux-x86_64-3.6
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE_CV=0 -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/tmp/darknet/darknet-yolo34py-intergration-nocv/include -I/tmp/darknet/darknet-yolo34py-intergration-nocv/src -I/usr/include/python3.6m -c pydarknet.cpp -o build/temp.linux-x86_64-3.6/pydarknet.o -I/usr/include/python3.6m -I/usr/include/x86_64-linux-gnu/python3.6m
    In file included from /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1816:0,
                     from /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                     from /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
                     from pydarknet.cpp:581:
    /usr/local/lib/python3.6/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it by " \
      ^~~~~~~
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE_CV=0 -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/tmp/darknet/darknet-yolo34py-intergration-nocv/include -I/tmp/darknet/darknet-yolo34py-intergration-nocv/src -I/usr/include/python3.6m -c bridge.cpp -o build/temp.linux-x86_64-3.6/bridge.o -I/usr/include/python3.6m -I/usr/include/x86_64-linux-gnu/python3.6m
    x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/pydarknet.o build/temp.linux-x86_64-3.6/bridge.o -L. -L./__libdarknet -ldarknet -lm -lpthread -o build/lib.linux-x86_64-3.6/pydarknet.cpython-36m-x86_64-linux-gnu.so -lpython3.6m -Wl,-rpath,/usr/local/lib/python3.6/dist-packages/__libdarknet -Wl,-rpath,/usr/lib/python3/dist-packages/__libdarknet
    /usr/bin/ld: cannot find -ldarknet
    collect2: error: ld returned 1 exit status
    error: command 'x86_64-linux-gnu-g++' failed with exit status 1
    
    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-r4u4hlkr/yolo34py-gpu/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-v841beba-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-r4u4hlkr/yolo34py-gpu/

I'm on Debian 9.4 with Python 3.6.6rc1

Very Low FPS

When running webcam_demo.py and video_demo.py I am getting very low fps.
The output stream freezes and runs in like 10 seconds of interval.
Webcam output is frozen.

Any possible fix?

Note: I followed the guide and installed the CPU version. Running Ubuntu 16.04 VMWare 8 GB ram

yolo34py-gpu

Hi

I am having a problem with yolo34py-gpu. I wanted to process a video using the GPU version. However, when I run the algorithm, it says there:

layer filters size input output
0 CUDA Error: unknown error
python: ./src/cuda.c:36: check_error: Assertion `0' failed.
Aborted (core dumped)

What I did is to install yolo34py. So, what I have right now is the cpu and the gpu versions. What happens is that when I run the algorithm, it works fine but very slow. This is due to the cpu version. Why is that the GPU version producing such error as shown above? Thank you!

How to create yolo model with custom dataset?

Hi, firstly i thank you @madhawav for providing a very simple and easily understandable repo. Seriously i've been looking for some days for codes that support video, webcam and image with yolo model. finally found this repo. I admire your work.

Now coming to my issue- Hi, I'm trying to create a custom Yolo model in v2( or v3) to detect certain objects in my custom dataset. I tried so many times on this task, but i'm failing. i hope you can help me. Let me clearly mention my issue below:-

Hi i'm trying to do training on custom dataset as per the https://pjreddie.com/darknet/yolov2/ .

I have an image dataset of 9 objects in train(69K) and test(10K) folder. i also have annotation files for all these images in another separate folders train(69K) and test(10K). The Annotation files have same name as that of image with .txt format.


eg of an annotation file is and see the its format below-:
2 0.398 0.451 0.026 0.036
8 0.331 0.451 0.047 0.062
2 0.170 0.459 0.075 0.081
class_no xmin_yolo ymin xmax_yolo ymax_yolo

where - class_no is the classnumber of object(starting from 0, 1, 2, 3, 4.....8, assigned to each object as their unique identifier)
xmin_yolo = float((float((xmax-xmin)/2) + xmin)/width)
ymin_yolo = float((float((ymax-ymin)/2) + ymin)/height)
xmax_yolo = float((xmax-xmin)/width)
ymax_yolo = float((ymax-ymin)/height)

In above equation- xmin, ymin is the x1, y1 coordinates of the bounding box. xmax, ymax is the x2, y2 coordinates of the bounding box
for example, xmin=393, ymin=302, xmax=453, ymax=347, height=720 , width=1280
gives this - 8 0.331 0.451 0.047 0.062, where 8 is the class number


Next created a train.txt, and test.txt file which has path to all images in text and test folders. train.txt looks like:-
/Image-dataset/images/val/ca4071a6-6fa1a1c8.jpg
/Image-dataset/images/val/ca40ddd3-102f3b02.jpg


I created a objects.names file and added these:-

bike
book
car
table
person
woman
trafficlight
trafficsign
truck

Then i created a objects.data file and added these:-

classes= 9
train  = /new-dataset/Image-dataset/trainval.txt
valid  = /new-dataset/Image-dataset/testval.txt
names = /Yolo/darknet/cfg/objects.names
backup = backup

And the objects.cfg file is this which is yolov2-voc.cfg, modified with classnumber and filter only:-

[net]
batch=20
subdivisions=10
height=416
width=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 80200
policy=steps
steps=40000,60000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky


#######

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[route]
layers=-9

[convolutional]
batch_normalize=1
size=1
stride=1
pad=1
filters=64
activation=leaky

[reorg]
stride=2

[route]
layers=-1,-4

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=70
activation=linear


[region]
anchors =  1.3221, 1.73145, 3.19275, 4.00944, 5.05587, 8.09892, 9.47112, 4.84053, 11.2364, 10.0071
bias_match=1
classes=9
coords=4
num=5
softmax=1
jitter=.3
rescore=1

object_scale=5
noobject_scale=1
class_scale=1
coord_scale=1

absolute=1
thresh = .6
random=1

I also downloaded a pre-trained model - darknet19_448.conv.23


Now i enter the command - ./darknet detector train cfg/objects.data cfg/objects.cfg darknet19_448.conv.23 .

After so many hours i the iteration where completed successfully without any errors(memory errors was cleared) and got inside backup folder. Next i tried the the testing with this command:-
./darknet detector demo cfg/objects.data cfg/objects.cfg backup/vehicles-yolov2-voc_80000.weights '/Test-data/Driving.mp4'

  • where vehicles-yolov2-voc_80000.weights is a the model created during iterations.
  • and Driving.mp4 is the video

But im not getting any results. also tried with image and webcam. i tried this in command - -thresh 0 . still no results. Do i need to make any change in objects.cfg or any files?

or should i replace any pretrained model or .cfg file with anything else?
i have simply looked into AlexeyAB . still no luck

@madhawav Please help me

Trouble installation from source

Hi,
I'm following your instructions for installing from sources.

The only difference is that I'm using ubuntu 14.04 and a virtual env.

I got this error message while execute the command:
pip3 install .

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -DUSE_GPU=0 -DUSE_CV=0 -I/home/rani-ubuntu/python-environments/darknet-python/lib/python3.5/site-packages/numpy/core/include -I/home/rani-ubuntu/Projects/yolo/darknet/include -I/home/rani-ubuntu/Projects/yolo/darknet/src -I/usr/include/python3.5m -I/home/rani-ubuntu/python-environments/darknet-python/include/python3.5m -c pydarknet.cpp -o build/temp.linux-x86_64-3.5/pydarknet.o

x86_64-linux-gnu-gcc: error: : No such file or directory

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I have checked and all the path and files in the command exists.

any advice ?

Error while installing GPU Version

I am having this error when installing via:
pip3 install yolo34py-gpu

Collecting yolo34py-gpu' 'Downloading' 'https://files.pythonhosted.org/packages/dc/a3/12c668e54109c5469a8312d757b357dda0b2efc2150043b76b58f6ba75c3/yolo34py-gpu-0.1rc12.tar.gz (66kB)' ' 100% |################################| 71kB 1.1MB/s' ' Complete output from command python setup.py egg_info:' ' Traceback (most recent call last):' 'File "<string>", line 1, in <module>' 'File "C:\Users\Yuliia\AppData\Local\Temp\pip-install-v3jjunpq\yolo34py-gpu\setup.py", line 47, in <module>' ' if USE_CV & (get_libs("opencv") == '' or get_cflags("opencv") == ''):' 'File "C:\Users\Yuliia\AppData\Local\Temp\pip-install-v3jjunpq\yolo34py-gpu\util.py", line 85, in get_libs' ' proc = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE)' ' File "c:\program files\python 3.5\lib\subprocess.py", line 950, in __init__ restore_signals, start_new_session)' ' File "c:\program files\python 3.5\lib\subprocess.py", line 1220, in _execute_child startupinfo)' ' FileNotFoundError: [WinError 2] The system cannot find the file specified'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.