digitalbrain79 / pyyolo Goto Github PK
View Code? Open in Web Editor NEWSimple python wrapper for YOLO.
Simple python wrapper for YOLO.
For a image with a size of 640*480, in my GPU 1070,the c interface ouputs 0.02s,but when i use the pyyolo interference, i get a value of 0.08s for one image. So the python interface takes three times bigger than the original c interface function. What's the reason?
I was trying to import the pyyolo wrapper from a parent directory.
However, I encounter this error
File ".../pyyolo/body_detector.py", line 18, in __init__ pyyolo.init(datacfg, cfgfile, weightfile)
AttributeError: 'module' object has no attribute 'init'
I am aware that some path was set by the setup.py, which causing the "pyyolo" module can only be import properly within the directory.
I also used the "imp" module and found that the module outside the directory looks like
>>> imp.find_module('pyyolo') (None, 'pyyolo', ('', '', 5))
While inside the directory look like
(<open file '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyyolo.so', mode 'rb' at 0x1005d4a50>, '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyyolo.so', ('.so', 'rb', 3))
However, even I tried to use the "imp" module to import it with the path above still nth happens. Its there any other way I can use/import the wrapper from parent directory????
Thanks a lot!!!
Looks like there are some subtle model changes. Will anyone take a look at the new C changes for the conversion?
`detection_info **yolo_detect(yolo_handle handle, image im, float thresh, float hier_thresh, int *num)
{
yolo_obj *obj = (yolo_obj *)handle;
image sized = letterbox_image(im, obj->net->w, obj->net->h);
float *X = sized.data;
clock_t time;
time=clock();
network_predict(obj->net, X);
printf("Cam frame predicted in %f seconds.\n", sec(clock()-time));
layer l = obj->net->layers[obj->net->n-1];
int nboxes = 0;
detection *dets = get_network_boxes(obj->net, im.w, im.h, thresh, hier_thresh, 0, 1, &nboxes);
if (obj->nms) do_nms_sort(dets, nboxes, l.classes, obj->nms);
list *output = make_list();
get_detection_info(im, nboxes, thresh, dets, l.classes, obj->names, output);
detection_info **info = (detection_info **)list_to_array(output);
*num = output->size;
free_list(output);
free_image(sized);
//Add this line to fix the memory leak issue
free_detections(dets, nboxes);
return info;
}`
When I run python setup.py build
it ends up with the error
running build
running build_ext
building 'pyyolo' extension
creating build
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/lib/python2.7/dist-packages/numpy/core/include -I./darknet/include -I/usr/include/python2.7 -c module.c -o build/temp.linux-x86_64-2.7/module.o
In file included from ./darknet/src/box.h:3:0,
from ./darknet/src/image.h:9,
from libyolo.h:3,
from module.c:5:
./darknet/include/darknet.h:727:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
double what_time_is_it_now();
^
./darknet/include/darknet.h:731:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
data load_all_cifar10();
^
./darknet/include/darknet.h:737:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
image **load_alphabet();
^
./darknet/include/darknet.h:796:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
size_t rand_size_t();
^
./darknet/include/darknet.h:797:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
float rand_normal();
^
In file included from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:27:0,
from /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
from module.c:3:
/usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/__multiarray_api.h:1463:1: warning: '_import_array' defined but not used [-Wunused-function]
_import_array(void)
^
creating build/lib.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/module.o -L. -lyolo -o build/lib.linux-x86_64-2.7/pyyolo.so
/usr/bin/ld: cannot find -lyolo
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
This issue is created to help those who are facing issues I faced with the program exiting because no exception handling was done in the code.
I have uploaded the Readme.md file to help those who would like to use this repo on a folder of images.
Rename the below file to example.py:
example.txt
I don't have any GPU.
Is it possible to use your wrapper ?
I cannot compile it (missing cuda files)
I think pyyolo is currently build for python2.
As I wanted to use it with python3, I had to make a few changes.
I'm not really used to git-pull-request I simply paste my changes here. Maybe it helps someone.
I just added this in module.c (instead of initpyyolo):
static struct PyModuleDef cModPyYolo =
{
PyModuleDef_HEAD_INIT,
"pyyolo",
"",
-1,
PyyoloMethods
};
PyMODINIT_FUNC PyInit_pyyolo(void)
{
return PyModule_Create(&cModPyYolo);
}
libyolo.c:103:2: error: incompatible type for argument 6 of 'get_region_boxes'
get_region_boxes(l, 1, 1, thresh, obj->probs, obj->boxes, 0, 0, hier_thresh);
Hi, I got the following errors when I run "make", any one knows how to solve it?? Thanks.
[pyyolo-master]$ make
gcc -DGPU -I/usr/local/cuda/include/ -DCUDNN -Wall -Wfatal-errors -Wno-unused-result -fPIC -I./darknet/src -I./darknet/include -Ofast -DGPU -DCUDNN -c libyolo.c -o obj/libyolo.o
libyolo.c:5:21: fatal error: darknet.h: No such file or directory
#include "darknet.h"
^
compilation terminated.
make: *** [obj/libyolo.o] Error 1
Just a warning, if you want to use pyyolo with GPU support, make sure CUDNN=0 in the makefile.
Also, make sure that line 13 in the makefile is commented out.
Otherwise, pyyolo works well, even on the latest version of darknet code, as long as you add lstm_layer.o to the makefile objects.
Also, thank you for making pyyolo.
Hi,
I got the same run time with/out GPU+CUDNN flag ("Predicted in 20.788111 seconds")
Can you advice how to enable the GPU or what went wrong?
Thanks
Hi,
Somehow the detection is not working for me, when I try a model trained on the current up to date Darknet library. I trained a model 2 months ago, with it works fine, but yesterday I trained a model with the up-to-date one and the detection runs but does not return result.
Tried exchanging the Darknet subdirectory but it does not help. Probably somehow the python wrapper part is broken, because when I try with the compiled one everything is fine.
Please help me!
Hi, I make with GPU=1, CUDNN=1, but when I run the example I get:
----- test original C using a file
CUDA Error: invalid device function
python: ./darknet/src/cuda.c:36: check_error: Assertion `0' failed.
Aborted (core dumped)
The original Darknet works fine for me, when I set the ARCH to --gpu-architecture=compute_35 --gpu-code=compute_35. Unfortunatelly here this does not seem to work.
I got following error when using make to install the project:
/bin/sh: 1: nvcc: not found
Makefile:66: recipe for target 'obj/convolutional_kernels.o' failed
make: *** [obj/convolutional_kernels.o] Error 127
cam2@Precision-tower-7910:~/alex/pyyolo$ logout
Connection to ee220cpc4.ecn.purdue.edu closed.
Hi, it seems like it does not work with the weights yolo9000?
datacfg = 'cfg/combine9k.data'
cfgfile = 'cfg/darknet9000.cfg'
weightfile = '../yolo9000.weights'
filename = 'data/person.jpg'
is what I put in the example.py file.
I just get an empty prediction. Has anyone tries this?
I'm trying to run darknet in multiprocessing by preloading the weights in the parent process. But there is a following error, with what it can be connected?
CUDA Error: initialization error
python: ./darknet/src/cuda.c:36: check_error: Assertion 0 failed.
@digitalbrain79 @jasrk11 @oulutan @rayhou0710
I followed the instructions as follow:
git clone --recursive [email protected]:rayhou0710/pyyolo.git
make
rm -rf build
python setup_gpu.py build
sudo python setup_gpu.py install
Test
python example.py
Error here:
Traceback (most recent call last):
File "example.py", line 1, in
import pyyolo
ModuleNotFoundError: No module named 'pyyolo'
Any clue on how this error is made, Thanks.
I have all options set to 0 at the top of the Makefile (GPU, CUDNN, OpenCV), and when I try to run make I get the following error:
gcc -Wall -Wfatal-errors -Wno-unused-result -fPIC -I./darknet/src -I./darknet/include -Ofast -c libyolo.c -o obj/libyolo.o
libyolo.c:5:10: fatal error: option_list.h: No such file or directory
#include "option_list.h"
^~~~~~~~~~~~~~~
compilation terminated.
Makefile:63: recipe for target 'obj/libyolo.o' failed
make: *** [obj/libyolo.o] Error 1
Hi!
git clone --recursive [email protected]:rayhou0710/pyyolo.git
Cloning into 'pyyolo'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
When running example.py got error:
layer filters size input output
0 Cuda malloc failed
: File exists
python: ./darknet/src/utils.c:216: error: Assertion `0' failed.
Aborted (core dumped)
Hello, in order to classify all classes from yolo9000 to create an inherit tree, i need to know exactly what classes are included in it. Could you provided me the labels of all classes?
Hi , I'm hitting an undefined symbol :
root@ac2601861c3a:~/pyyolo# python example.py
Traceback (most recent call last):
File "example.py", line 1, in <module>
import pyyolo
ImportError: /usr/local/lib/python2.7/dist-packages/pyyolo.so: undefined symbol: cudnnSetConvolutionGroupCount
if i want to change something in libyolo.c or libyolo.h , how do i recompile the .a library file so things go into effect
When tested the example.py code with a large input image it throws segmentation fault.
3200x2120 pixels seems to be enough to reproduce the issue.
Here's the output:
False
layer filters size input output
0 conv 16 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 16
1 max 2 x 2 / 2 416 x 416 x 16 -> 208 x 208 x 16
2 conv 32 3 x 3 / 1 208 x 208 x 16 -> 208 x 208 x 32
3 max 2 x 2 / 2 208 x 208 x 32 -> 104 x 104 x 32
4 conv 64 3 x 3 / 1 104 x 104 x 32 -> 104 x 104 x 64
5 max 2 x 2 / 2 104 x 104 x 64 -> 52 x 52 x 64
6 conv 128 3 x 3 / 1 52 x 52 x 64 -> 52 x 52 x 128
7 max 2 x 2 / 2 52 x 52 x 128 -> 26 x 26 x 128
8 conv 256 3 x 3 / 1 26 x 26 x 128 -> 26 x 26 x 256
9 max 2 x 2 / 2 26 x 26 x 256 -> 13 x 13 x 256
10 conv 512 3 x 3 / 1 13 x 13 x 256 -> 13 x 13 x 512
11 max 2 x 2 / 1 13 x 13 x 512 -> 13 x 13 x 512
12 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024
13 conv 1024 3 x 3 / 1 13 x 13 x1024 -> 13 x 13 x1024
14 conv 425 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 425
15 detection
mask_scale: Using default '1.000000'
Loading weights from ../tiny-yolo.weights...Done!
----- test original C using a file
./darknet/data/person_big.jpg: Predicted in 2.637989 seconds.
{'right': 1358, 'class': 'person', 'prob': 0.5922545194625854, 'top': 543, 'bottom': 1696, 'left': 930}
{'right': 952, 'class': 'dog', 'prob': 0.7985455989837646, 'top': 1321, 'bottom': 1750, 'left': 392}
{'right': 2960, 'class': 'horse', 'prob': 0.6815794110298157, 'top': 531, 'bottom': 1730, 'left': 2062}
----- test python API using a file
Segmentation fault (core dumped)
pi@raspberrypi:~/pyyolo $ uname -a
Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU/Linux
pi@raspberrypi:/pyyolo $ python example.py
Traceback (most recent call last):
File "example.py", line 1, in
import pyyolo
ImportError: /usr/local/lib/python2.7/dist-packages/pyyolo.so: undefined symbol: make_iseg_layer
pi@raspberrypi:/pyyolo $
The Makefile.zip is attached.
Makefile.zip
Thank you in anticipation of your help!
Thanks for sharing the wrapper code!
I am wondering if by any chance there could be a function of detecting objects using camera.
Hi all,
I am trying to install pyyolo but I found the below error when I run "python setup.py build". Please note that I already have gcc installed.
"module.c:152:17: error: non-void function 'PyInit_pyyolo' should return a value [-Wreturn-type]
if (m == NULL) return;
^
1 error generated.
error: command 'gcc' failed with exit status 1"
Thanks.
I try to install with GPU + OpenCV + CUDNN + OpenMP (Darknet is built with GPU + OpenCV + CUDNN + OpenMP as well)
install script (it is running in a docker container as root so no need for sudo):
#!/bin/bash
rm -rf build
rm /usr/local/lib/python3.5/dist-packages/pyyolo*
make
python3 setup_gpu.py build
python3 setup_gpu.py install
python3 -c "import pyyolo;"
I get the following after running it:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: /usr/local/lib/python3.5/dist-packages/pyyolo.cpython-35m-x86_64-linux-gnu.so: undefined symbol: load_image_cv
This is the MakeFile:
GPU=1
CUDNN=1
DEBUG=0
OPENCV=1
# ARCH= -gencode arch=compute_20,code=[sm_20,sm_21] \
# -gencode arch=compute_30,code=sm_30 \
# -gencode arch=compute_35,code=sm_35 \
# -gencode arch=compute_50,code=[sm_50,compute_50] \
# -gencode arch=compute_52,code=[sm_52,compute_52]
# This is what I use, uncomment if you know your arch and want to specify
ARCH= -gencode arch=compute_61,code=compute_61 # 1080 TI
# ARCH= -gencode arch=compute_61,code=compute_61 # Tegra TX2
VPATH=./darknet/src/:./darknet/examples
LIB=libyolo.a
OBJDIR=./obj/
CC=gcc -fopenmp -lm -lmvec -lpthread `pkg-config --libs opencv` -lstdc++
AR=ar
NVCC=nvcc
OPTS=-Ofast
COMMON=
CFLAGS=-Wall -Wfatal-errors -Wno-unused-result -fPIC
CFLAGS+=-I./darknet/src -I./darknet/include
ifeq ($(DEBUG), 1)
OPTS=-O0 -g
endif
CFLAGS+=$(OPTS)
ifeq ($(OPENCV), 1)
COMMON+= -DOPENCV
CFLAGS+= -DOPENCV
COMMON+= `pkg-config --libs --cflags opencv` -lstdc++
endif
ifeq ($(GPU), 1)
COMMON+= -DGPU -I/usr/local/cuda/include/
CFLAGS+= -DGPU
endif
ifeq ($(CUDNN), 1)
COMMON+= -DCUDNN
CFLAGS+= -DCUDNN
endif
OBJ=libyolo.o gemm.o utils.o cuda.o deconvolutional_layer.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o
OBJ+=detection_layer.o route_layer.o upsample_layer.o box.o normalization_layer.o avgpool_layer.o layer.o local_layer.o shortcut_layer.o logistic_layer.o activation_layer.o rnn_layer.o gru_layer.o crnn_layer.o demo.o batchnorm_layer.o region_layer.o reorg_layer.o tree.o lstm_layer.o l2norm_layer.o yolo_layer.o
OBJ+=captcha.o lsd.o super.o art.o tag.o cifar.o go.o rnn.o segmenter.o regressor.o classifier.o coco.o yolo.o detector.o nightmare.o darknet.o
ifeq ($(GPU), 1)
OBJ+=convolutional_kernels.o deconvolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o avgpool_layer_kernels.o # network_kernels.o
endif
OBJS = $(addprefix $(OBJDIR), $(OBJ))
DEPS = $(wildcard src/*.h) Makefile
all: obj $(LIB)
$(LIB): $(OBJS)
$(AR) rcs $@ $^
$(OBJDIR)%.o: %.c $(DEPS)
$(CC) $(COMMON) $(CFLAGS) -c $< -o $@
$(OBJDIR)%.o: %.cu $(DEPS)
$(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $@
obj:
mkdir -p obj
.PHONY: clean
clean:
rm -rf $(OBJS) $(LIB)
setup_gpu.py:
from distutils.core import setup, Extension
import numpy
module = Extension('pyyolo',
library_dirs=['.', '/usr/local/cuda/lib64', '/usr/local/'],
libraries=['yolo', 'cuda', 'cudart', 'cublas', 'curand', 'cudnn'],
include_dirs=[numpy.get_include(), './darknet/include'],
sources = ['module.c'],
extra_compile_args=['-fopenmp'],
extra_link_args=['-lgomp', '-lm', '-lmvec', '-lpthread', '-lstdc++'])
setup (name = 'pyyolo',
version = '0.1',
description = 'YOLO wrapper',
ext_modules = [module])
I built OpenCV 3.4.3 from source.
cuDNN v7
Python 3.5
CUDA 9.0
Thank you very much.
In libyolo.c
's yolo_init
function here, the code is doing a chdir
to the darknet directory. This massively impacts the calling code that assumes its working directory is actually the directory it is started in. Is there a way to not change the directory?
Hello my friends, I have the following problem
Traceback (most recent call last): File "example.py", line 1, in <module> import pyyolo ImportError: /usr/local/lib/python2.7/dist-packages/pyyolo.so: undefined symbol: _ZGVbN2vv___pow_finite
I installed it on another computer and it worked, but this is experiencing this problem after following the tutorial installation
When i use make command for makefile in yolomex, i got the error below.
gcc -DGPU -I/"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0/include" -Wall -Wfatal-errors -Wno-unused-result -fPIC -I./yolomex/darknet/src -I./yolomex/darknet/include -Ofast -DGPU -c libyolo.c -o obj/libyolo.o
libyolo.c:5:10: fatal error: option_list.h: No such file or directory
#include "option_list.h"
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [obj/libyolo.o]
What should i do to solve this error i have no idea.
C:\Program Files\MATLAB\R2018a\bin\yolomex>make
i'm not sure about this statement in makefile: -I/"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0/include" is it right?
is it right?
Hello,
I have a problem when trying the detection function , it gives me this error: segmentation error core dumped. however, the test function works perfectly
Is there a way to return the top 5 probabilities in the pyyolo.detect() function versus just the top prediction?
I'm trying to do it for a video stream, and it's only spitting out the top selection.
I'm not much of a C programmer, so not sure what I'm looking at in the module.c file.
In Darknet, you see the top 5 guesses in the image printout.
I normally use Anaconda3 on Ubuntu 16.04 to manage my environments including Cuda & CUDNN. Create a new file called dev_environment.yml
at the root directory of pyyolo. The dev_environment.yml
should look like the following:
name: ENV-NAME
channels:
- defaults
dependencies:
- python=3.5
- cudatoolkit=8
- cudnn=5
- pip:
- cython
Install and activate the environment:
conda env create --force -f dev_environment.yml
source activate env-name
Set the flags GPU=1
and CUDNN=1
at the top of the Makefile.
Change the location of where cuda can be found. In the Makefile line 40, replace the line:
COMMON+= -DGPU -I/usr/local/cuda/include/
with
COMMON+= -DGPU -I/home/USER/anaconda3/envs/ENV-NAME/include/
Add an option to prevent the error: /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
. In the Makefile line 66, replace the line:
$(NVCC) $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $@
with
$(NVCC) -D_FORCE_INLINES $(ARCH) $(COMMON) --compiler-options "$(CFLAGS)" -c $< -o $@
You don't need sudo anymore since we will be using a locally available Anaconda python.
1. git clone --recursive https://github.com/thomaspark-pkj/pyyolo.git
2. Setup Environment (Described above)
3. Changes to Makefile (Described above)
4. make clean
5. make
6. python setup_gpu.py build
7. python setup_gpu.py install
python example.py
@digitalbrain79
I set
CUDNN=1
GPU=1
and every thing is fine with my cuda, etc.
I built pyyolo and executed the following commands.
python setup.py build (use setup_gpu.py for GPU)
sudo python setup.py install (use setup_gpu.py for GPU)
in user mode, by running
python3 example.py
I get
Segmentation fault (core dumped)
also, by running sudo python3 example.py
(in super user mode), I get
Traceback (most recent call last): File "example.py", line 1, in <module> import pyyolo ImportError: libcudart.so.10.0: cannot open shared object file: No such file or directory
also, by importing pyyolo on jupyter note book via import pyyolo
, I get the following error"
ImportError Traceback (most recent call last) <ipython-input-1-f5beecd7fd26> in <module> ----> 1 import pyyolo ImportError: /usr/local/lib/python3.6/dist-packages/pyyolo.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZGVbN2vv___pow_finite
I run these codes respectively and I have got this error :
gcc -DGPU -I/usr/local/cuda/include/ -DCUDNN -Wall -Wfatal-errors -Wno-unused-result -fPIC -I./darknet/src -I./darknet/include -Ofast -DGPU -DCUDNN -c libyolo.c -o obj/libyolo.o
In file included from libyolo.c:5:0:
./darknet/include/darknet.h:19:14: fatal error: cudnn.h: No such file or directory
#include "cudnn.h"
^~~~~~~~~
compilation terminated.
Makefile:66: recipe for target 'obj/libyolo.o' failed
make: *** [obj/libyolo.o] Error 1
But yet cudnn.h
does not exit yet in this directory. I run these codes and tried them, but they didn't work yet.
1.
git clone --recursive [email protected]:rayhou0710/pyyolo.git
make
git clone --recurse-submodules https://github.com/digitalbrain79/pyyolo.git
make
Also I downloaded pjreddie/darknet directly.
hi, @thomaspark-pkj
@jasrk11 @oulutan @rayhou0710
Try to debug the code with different GPUID instead of default 0.
I try to update the wrapper but failed. Could you help provide some hint? Thanks
i tried pyyolo on video it was working well,
i tried it again after a while it shows this error
AttributeError: 'module' object has no attribute 'load_meta'
Hi,
When I try to use the pyyolo.detect
function with my own yolo trained model, it generate a segmentation fault.
I copied the example.py
to make my own with those changes :
datacfg = '/home/ubuntu/mydata.data'
cfgfile = '/home/ubuntu/mymodel.cfg'
weightfile = '/home/ubuntu/mymodel_3700.weights'
filename = '/home/ubuntu/myimage.jpg'
thresh = 0.5
then when i run it i have this error :
layer filters size input output
0 conv 32 3 x 3 / 1 1024 x1024 x 3 -> 1024 x1024 x 32
1 max 2 x 2 / 2 1024 x1024 x 32 -> 512 x 512 x 32
2 conv 64 3 x 3 / 1 512 x 512 x 32 -> 512 x 512 x 64
3 max 2 x 2 / 2 512 x 512 x 64 -> 256 x 256 x 64
4 conv 128 3 x 3 / 1 256 x 256 x 64 -> 256 x 256 x 128
5 conv 64 1 x 1 / 1 256 x 256 x 128 -> 256 x 256 x 64
6 conv 128 3 x 3 / 1 256 x 256 x 64 -> 256 x 256 x 128
7 max 2 x 2 / 2 256 x 256 x 128 -> 128 x 128 x 128
8 conv 256 3 x 3 / 1 128 x 128 x 128 -> 128 x 128 x 256
9 conv 128 1 x 1 / 1 128 x 128 x 256 -> 128 x 128 x 128
10 conv 256 3 x 3 / 1 128 x 128 x 128 -> 128 x 128 x 256
11 max 2 x 2 / 2 128 x 128 x 256 -> 64 x 64 x 256
12 conv 512 3 x 3 / 1 64 x 64 x 256 -> 64 x 64 x 512
13 conv 256 1 x 1 / 1 64 x 64 x 512 -> 64 x 64 x 256
14 conv 512 3 x 3 / 1 64 x 64 x 256 -> 64 x 64 x 512
15 conv 256 1 x 1 / 1 64 x 64 x 512 -> 64 x 64 x 256
16 conv 512 3 x 3 / 1 64 x 64 x 256 -> 64 x 64 x 512
17 max 2 x 2 / 2 64 x 64 x 512 -> 32 x 32 x 512
18 conv 1024 3 x 3 / 1 32 x 32 x 512 -> 32 x 32 x1024
19 conv 512 1 x 1 / 1 32 x 32 x1024 -> 32 x 32 x 512
20 conv 1024 3 x 3 / 1 32 x 32 x 512 -> 32 x 32 x1024
21 conv 512 1 x 1 / 1 32 x 32 x1024 -> 32 x 32 x 512
22 conv 1024 3 x 3 / 1 32 x 32 x 512 -> 32 x 32 x1024
23 conv 1024 3 x 3 / 1 32 x 32 x1024 -> 32 x 32 x1024
24 conv 1024 3 x 3 / 1 32 x 32 x1024 -> 32 x 32 x1024
25 route 16
26 reorg / 2 64 x 64 x 512 -> 32 x 32 x2048
27 route 26 24
28 conv 1024 3 x 3 / 1 32 x 32 x3072 -> 32 x 32 x1024
29 conv 30 1 x 1 / 1 32 x 32 x1024 -> 32 x 32 x 30
30 detection
Loading weights from /home/ubuntu/mymodel_3700.weights...Done!
----- test original C using a file
Cannot load image "/home/ubuntu/myimage.jpg"
STB Reason: unknown image type
I found that was coming from the line ret_val = cv2.imwrite(filename,img)
which was removing my image so i removed it since i don't have any webcam.
Then after getting my image back, i run again and i have the segmentation fault error :
Loading weights from /home/ubuntu/mymodel_3700.weights...Done!
----- test original C using a file
/home/ubuntu/deep-learning/myimage.jpg: Predicted in 0.251751 seconds.
{'bottom': 1218, 'top': 953, 'right': 568, 'class': 'mylabel', 'left': 357}
{'bottom': 1213, 'top': 955, 'right': 788, 'class': 'mylabel', 'left': 578}
{'bottom': 1217, 'top': 956, 'right': 1012, 'class': 'mylabel', 'left': 799}
{'bottom': 1214, 'top': 960, 'right': 1225, 'class': 'mylabel', 'left': 1016}
----- test python API using a file
[1] 12904 segmentation fault (core dumped) python example_yoobic.py
The predictions from the ----- test original C using a file
version is ok.
Here is some tests i have made to find why this is happening :
python example.py
works fine with this output :False
False
layer filters size input output
0 conv 16 3 x 3 / 1 416 x 416 x 3 -> 416 x 416 x 16
1 max 2 x 2 / 2 416 x 416 x 16 -> 208 x 208 x 16
2 conv 32 3 x 3 / 1 208 x 208 x 16 -> 208 x 208 x 32
3 max 2 x 2 / 2 208 x 208 x 32 -> 104 x 104 x 32
4 conv 64 3 x 3 / 1 104 x 104 x 32 -> 104 x 104 x 64
5 max 2 x 2 / 2 104 x 104 x 64 -> 52 x 52 x 64
6 conv 128 3 x 3 / 1 52 x 52 x 64 -> 52 x 52 x 128
7 max 2 x 2 / 2 52 x 52 x 128 -> 26 x 26 x 128
8 conv 256 3 x 3 / 1 26 x 26 x 128 -> 26 x 26 x 256
9 max 2 x 2 / 2 26 x 26 x 256 -> 13 x 13 x 256
10 conv 512 3 x 3 / 1 13 x 13 x 256 -> 13 x 13 x 512
11 max 2 x 2 / 1 13 x 13 x 512 -> 13 x 13 x 512
12 conv 1024 3 x 3 / 1 13 x 13 x 512 -> 13 x 13 x1024
13 conv 1024 3 x 3 / 1 13 x 13 x1024 -> 13 x 13 x1024
14 conv 425 1 x 1 / 1 13 x 13 x1024 -> 13 x 13 x 425
15 detection
Loading weights from ../tiny-yolo.weights...Done!
----- test original C using a file
data/person.jpg: Predicted in 0.122906 seconds.
{'bottom': 353, 'top': 264, 'right': 194, 'class': 'dog', 'left': 71}
{'bottom': 338, 'top': 109, 'right': 594, 'class': 'horse', 'left': 411}
{'bottom': 381, 'top': 101, 'right': 274, 'class': 'person', 'left': 184}
{'bottom': 347, 'top': 137, 'right': 583, 'class': 'sheep', 'left': 387}
----- test python API using a file
Cam frame predicted in 0.013993 seconds.
{'bottom': 353, 'top': 264, 'right': 194, 'class': 'dog', 'left': 71}
{'bottom': 338, 'top': 109, 'right': 594, 'class': 'horse', 'left': 411}
{'bottom': 381, 'top': 101, 'right': 274, 'class': 'person', 'left': 184}
{'bottom': 348, 'top': 137, 'right': 583, 'class': 'sheep', 'left': 387}
I dont have any webcam so 2 first printing are False.
But running example.py
with the cv2,imwrite
instruction works for the dog.jpg
cv2.imwrite
(with it, i still have the remove) raise the segmentation fault exception :Loading weights from ../tiny-yolo.weights...Done!
----- test original C using a file
/home/ubuntu/myimage.jpg: Predicted in 0.119570 seconds.
----- test python API using a file
[1] 12948 segmentation fault (core dumped) python example.py
Loading weights from /home/ubuntu/mymodel_3700.weights...Done!
----- test original C using a file
/home/ubuntu/pyyolo/darknet/data/dog.jpg: Predicted in 0.240863 seconds.
----- test python API using a file
Cam frame predicted in 0.145188 seconds.
After searching i found out that the segmentation fault comes from the data parsing in line 46 of module.c
in the instruction if (!PyArg_ParseTuple(args, "iiiOff", &w, &h, &c, &array, &thresh, &hier_thresh))
I cant undestand why the parsing raise a segmentation fault error on my image.
My images are RGB with sizes (1920,1440,3) or (1440,1920,3) or (1920,1920,3)
Can you help ?
@thomaspark-pkj @jasrk11 @oulutan @rayhou0710 hii
when i run pyyolo it only uses single core processor in CPU , to enable the multicore usage in CPU , enabling of openmp option is not include .Can i manually add this? if i add what are the steps should i see in prior . I did not face this issue in darknet using c which had openMP enabled in make file
would it be possible to return the confidence in addition to object and bb?
The pyyolo.detect() function works well with the resolution of 480360,but i get a error when tested with a image size of 19201080.
What's the reason?
When I clone the repository and follow the instructions, I get the following error when trying to import pyyolo:
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import pyyolo
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-63420bffe21f> in <module>()
----> 1 import pyyolo
ImportError: /usr/local/lib/python2.7/dist-packages/pyyolo.so: undefined symbol: __cudaUnregisterFatBinary
I've tried both with setup.py and setup_gpu.py.
I have previously had pyyolo working on another PC 1-2 months ago.
When running example.py got an error:
Traceback (most recent call last):
File "example.py", line 1, in
import pyyolo
ImportError: /usr/local/lib/python2.7/dist-packages/pyyolo.so: undefined symbol: cvWaitKey
Hi Mr. Park.
When running your example.py file, i met this error "Undefined symbol: cvWaitKey" (because of pyyolo import) As i know, pyyolo source uses function incorrect. How to repair it? Thank so much!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.