xiaochus / yolov3 Goto Github PK
View Code? Open in Web Editor NEWKeras implementation of yolo v3 object detection.
License: MIT License
Keras implementation of yolo v3 object detection.
License: MIT License
I have noticed that Opencv imread was loading color channels in BGR order, what I did not know before. Since I suppose the original weights are made to deal with the channels in RGB order, I swapped the channels back by adding the line:
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
,at the beggining of the function process_image.
It indeed increased the detection rate especially for the yolo_tiny model. It may solve issue #8 btw.
When i convert my own trained yolov3.weights to .h5, the error will shown as follows:
Traceback (most recent call last):
File "yad2k.py", line 275, in
_main(parser.parse_args())
File "yad2k.py", line 151, in _main
buffer=weights_file.read(weights_size * 4))
TypeError: buffer is too small for requested array
How to solve this problem
Thanks!
Hi,
I was looking at the original YOLO cfg here. It seems the original one accepts a input of size 608x608, not 416 as mentioned in your config file.
So, how is this even working considering you are downloading the weights for for the larger 608x608 image. I understand that the initial convolutions will be the same but the size of your outputs will be different. Am I mistaking something here?
Update: looks like the cfg file was changed 4 days ago. But still the question remains as to why it worked given the weights would have been from the newer model?
I have a better code about yolo https://github.com/Stinky-Tofu/Stronger-yolo
I found mistake in the code.
File: yolo_model.py
for image with width not equal to height, this lines causes to error (lines 59-63):
col = np.tile(np.arange(0, grid_w), grid_w).reshape(-1, grid_w)
row = np.tile(np.arange(0, grid_h).reshape(-1, 1), grid_h)
col = col.reshape(grid_h, grid_w, 1, 1).repeat(3, axis=-2)
row = row.reshape(grid_h, grid_w, 1, 1).repeat(3, axis=-2)
instead, copy and paste these lines :
col = np.tile(np.arange(0, grid_w), grid_h).reshape(-1, grid_w)
row = np.tile(np.arange(0, grid_h).reshape(-1, 1), grid_w)
col = col.reshape(grid_h, grid_w, 1, 1).repeat(3, axis=-2)
row = row.reshape(grid_h, grid_w, 1, 1).repeat(3, axis=-2)
@xiaochus hi,xiaochus.when i tested the video with my own trained model,i couldn't identify anything;instead,i could identify if i used the author's yolov3.weights.i dont know why this result was produced,cause when i use my trained model on darknet,it worked well.
这个代码可以用usb摄像头实时检测吗
I found that you use:
col = np.tile(np.arange(1, grid_w + 1), grid_w).reshape(-1, grid_w)
row = np.tile(np.arange(1, grid_h + 1).reshape(-1, 1), grid_h)
It means you use offsets of [1, W] and [1, H], But why you not use [0, W-1] and [0, H-1]?
How could this be possible?
I am using the demo.py script.
Good work!
But I think there is a bug in darknet53.py, line 51:
in stead of x = conv2d_unit(inputs, 2 * filters, (3, 3))
, it shoud be x = conv2d_unit(x, 2 * filters, (3, 3))
.
Can you check it?
how to solve this ??????
ValueError: Error when checking : expected input_1 to have shape (608, 608, 3) but got array with shape (416, 416, 3)
I am using this repo to run YoloV3 on a test video. My GPU support is GeForce GTX 1080 Ti. The video is playing with almost 3 sec per frame. I have no idea why it is so slow, even though my GPU is good enough. I have attached a screen-shot of my terminal while running the test video. Any idea or guidance is much appreciated. Thank You
这个repo只有detection功能,那么怎么实现这个功能的呢?
写的一堆yolo model代码一点没用到,他只是用别人写好的yad2k.py文件把darknet.weight文件转成keras的.h5文件,然后load_model,就开始其实就是用训练好的模型,predict然后完事了。
所以我觉得没必要再看了,没有train功能,前面star的不知道真的看没看。
I found an error in this code. I am looking forward to the author's reply thanks
File "demo.py", line 152, in
image = detect_image(image, yolo, all_classes)
File "demo.py", line 90, in detect_image
boxes, classes, scores = yolo.predict(pimage, image.shape)
File "C:\Users\Administrator\Desktop\YOLOv3-master\model\yolo_model.py", line 209, in predict
boxes, classes, scores = self._yolo_out(outs, shape)
File "C:\Users\Administrator\Desktop\YOLOv3-master\model\yolo_model.py", line 158, in _yolo_out
b, c, s = self._process_feats(out, anchors, mask)
File "C:\Users\Administrator\Desktop\YOLOv3-master\model\yolo_model.py", line 54, in _process_feats
box_wh = box_wh * anchors_tensor
ValueError: operands could not be broadcast together with shapes (13,13,2) (1,1,3,2)
I've trained yolov3 on mobilenet backend and get a good MAP(about 90M and 2 times faster than keras yolov3).I upload my code for mobilenet-yolov3 on https://github.com/Adamdad/keras-YOLOv3-mobilenet.git
use it as you wish
Hi,I am trying to convert Yolo wieghts to Keras on my Mac but i can't run the script. It says;
Traceback (most recent call last):
File "yad2k.py", line 9, in
import configparser
ImportError: No module named configparser
i tried pip install configparser but it didn't work. Do you have any advise?
广告虽可耻,大家可以看看我复现的这版yolov4,精心设计了损失函数,训练了70000步就没出现过nan,mAP至少可达36%,欢迎点star:
Hello,
I'm trying to train a network for different tasks, based on your project. The main issue I have is that if I create the same net with random weights instead of those from yolov3.weights (using this script: https://pastebin.com/RECciwrs) I get a net with the same number of params, the same layers, but on inference it outputs a matrix of NaNs. Since it outputs NaNs, I cannot train it, it will not converge to the desired weights.
How to repro:
from keras.models import load_model
import numpy as np
import cv2
yolo = load_model('yolo.h5')
yolo_rw = load_model('yolo_random_weights.h5')
path = 'images/test/giraffe416.jpg'
image = cv2.imread(path)
image = np.array(image, dtype='float32')
image /= 255.
image = np.expand_dims(image, axis=0)
yolo.predict(image)
# will output a matrix of numbers
yolo_rw.predict(image)
# will output a matrix of NaNs
yolo_rw.set_weights(yolo.get_weights())
yolo_rw.predict(image)
# will output a matrix of numbers
Without using yolov3.weights, do you have any advice on how to seed the network so that it's trainable? I want to then use a different config file for a different number of classes in order to train.
Thank you.
I have used my own weights and configuration file. But while I am testing with new images the darknet can detect 4 objects where keras can detect only 2.
Do you know the reason behind this ?
I have the following problem when running "demo.py", could anyone tell me how to solve it?
`
WARNING:tensorflow:From C:\Users\10137\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
C:\Users\10137\Anaconda3\lib\site-packages\keras\engine\saving.py:292: UserWarning: No training configuration found in save file: the model was not compiled. Compile it manually.
warnings.warn('No training configuration found in save file: '
dog.jpg
Traceback (most recent call last):
File "", line 1, in
runfile('C:/Users/10137/Desktop/learn/python/yolov3_keras/demo.py', wdir='C:/Users/10137/Desktop/learn/python/yolov3_keras')
File "C:\Users\10137\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile
execfile(filename, namespace)
File "C:\Users\10137\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/10137/Desktop/learn/python/yolov3_keras/demo.py", line 152, in
image = detect_image(image, yolo, all_classes)
File "C:/Users/10137/Desktop/learn/python/yolov3_keras/demo.py", line 90, in detect_image
boxes, classes, scores = yolo.predict(pimage, image.shape)
File "C:\Users\10137\Desktop\learn\python\yolov3_keras\model\yolo_model.py", line 212, in predict
outs = self._yolo.predict(image)
File "C:\Users\10137\Anaconda3\lib\site-packages\keras\engine\training.py", line 1169, in predict
steps=steps)
File "C:\Users\10137\Anaconda3\lib\site-packages\keras\engine\training_arrays.py", line 294, in predict_loop
batch_outs = f(ins_batch)
File "C:\Users\10137\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2715, in call
return self._call(inputs)
File "C:\Users\10137\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 2675, in _call
fetched = self._callable_fn(*array_vals)
File "C:\Users\10137\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1439, in call
run_metadata_ptr)
File "C:\Users\10137\Anaconda3\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 528, in exit
c_api.TF_GetCode(self.status.status))
AbortedError: Operation received an exception:Status: 3, message: could not create a dilated convolution forward descriptor, in file tensorflow/core/kernels/mkl_conv_ops.cc:1111
[[{{node conv2d_2/convolution}}]]
`
Is anyone met this error ?
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.