allanzelener / YAD2K

YAD2K: Yet Another Darknet 2 Keras
Other
2.71k stars 877 forks source link

converted h5 test results in no detectable objects. #76

Open Anraza-Valtieri opened 6 years ago

Anraza-Valtieri commented 6 years ago

Currently trying to convert a tiny-yolo custom dataset. Testing pre-conversion lead to positive detection but after converting results in no detection at all.

Using TensorFlow backend. Loading weights. Weights Header: [ 0 1 0 448000] Parsing Darknet config. Creating Keras model. Parsing section net_0 Parsing section convolutional_0 conv2d bn leaky (3, 3, 3, 16) 2017-10-18 15:51:22.062358: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-10-18 15:51:22.062385: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-10-18 15:51:22.062394: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-10-18 15:51:22.062401: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. Parsing section maxpool_0 Parsing section convolutional_1 conv2d bn leaky (3, 3, 16, 32) Parsing section maxpool_1 Parsing section convolutional_2 conv2d bn leaky (3, 3, 32, 64) Parsing section maxpool_2 Parsing section convolutional_3 conv2d bn leaky (3, 3, 64, 128) Parsing section maxpool_3 Parsing section convolutional_4 conv2d bn leaky (3, 3, 128, 256) Parsing section maxpool_4 Parsing section convolutional_5 conv2d bn leaky (3, 3, 256, 512) Parsing section maxpool_5 Parsing section convolutional_6 conv2d bn leaky (3, 3, 512, 1024) Parsing section convolutional_7 conv2d bn leaky (3, 3, 1024, 1024) Parsing section convolutional_8 conv2d linear (1, 1, 1024, 35) Parsing section region_0 Layer (type) Output Shape Param #
input_1 (InputLayer) (None, 416, 416, 3) 0
conv2d_1 (Conv2D) (None, 416, 416, 16) 432
batch_normalization_1 (Batch (None, 416, 416, 16) 64
leaky_re_lu_1 (LeakyReLU) (None, 416, 416, 16) 0
max_pooling2d_1 (MaxPooling2 (None, 208, 208, 16) 0
conv2d_2 (Conv2D) (None, 208, 208, 32) 4608
batch_normalization_2 (Batch (None, 208, 208, 32) 128
leaky_re_lu_2 (LeakyReLU) (None, 208, 208, 32) 0
max_pooling2d_2 (MaxPooling2 (None, 104, 104, 32) 0
conv2d_3 (Conv2D) (None, 104, 104, 64) 18432
batch_normalization_3 (Batch (None, 104, 104, 64) 256
leaky_re_lu_3 (LeakyReLU) (None, 104, 104, 64) 0
max_pooling2d_3 (MaxPooling2 (None, 52, 52, 64) 0
conv2d_4 (Conv2D) (None, 52, 52, 128) 73728
batch_normalization_4 (Batch (None, 52, 52, 128) 512
leaky_re_lu_4 (LeakyReLU) (None, 52, 52, 128) 0
max_pooling2d_4 (MaxPooling2 (None, 26, 26, 128) 0
conv2d_5 (Conv2D) (None, 26, 26, 256) 294912
batch_normalization_5 (Batch (None, 26, 26, 256) 1024
leaky_re_lu_5 (LeakyReLU) (None, 26, 26, 256) 0
max_pooling2d_5 (MaxPooling2 (None, 13, 13, 256) 0
conv2d_6 (Conv2D) (None, 13, 13, 512) 1179648
batch_normalization_6 (Batch (None, 13, 13, 512) 2048
leaky_re_lu_6 (LeakyReLU) (None, 13, 13, 512) 0
max_pooling2d_6 (MaxPooling2 (None, 13, 13, 512) 0
conv2d_7 (Conv2D) (None, 13, 13, 1024) 4718592
batch_normalization_7 (Batch (None, 13, 13, 1024) 4096
leaky_re_lu_7 (LeakyReLU) (None, 13, 13, 1024) 0
conv2d_8 (Conv2D) (None, 13, 13, 1024) 9437184
batch_normalization_8 (Batch (None, 13, 13, 1024) 4096
leaky_re_lu_8 (LeakyReLU) (None, 13, 13, 1024) 0
conv2d_9 (Conv2D) (None, 13, 13, 35) 35875
Total params: 15,775,635 Trainable params: 15,769,523 Non-trainable params: 6,112 None Saved Keras model to model_data/yolo.h5 Read 15775635 of 15775635.0 from Darknet weights.

This is the CFG

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

learning_rate=0.001 max_batches = 40200 policy=steps steps=-1,100,20000,30000 scales=.1,10,.1,.1

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

[maxpool] size=2 stride=2

[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

[maxpool] size=2 stride=2

[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

[maxpool] size=2 stride=1

[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] size=1 stride=1 pad=1 filters=35 activation=linear

[region] anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 bias_match=1 classes=2 coords=4 num=5 softmax=1 jitter=.2 rescore=1

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

absolute=1 thresh = .6 random=1

ghost commented 6 years ago

Same problem here. Any ideas?

seantempesta commented 6 years ago

Ah, didn't see this issue. Yeah, I'm having the same problem. Anyone here have any updates? https://github.com/allanzelener/YAD2K/issues/83

It's strange that the full yolo v2 conversion works (if you remove the reorg layer). Isn't the Tiny Yolo just the same model with less layers?

joyyang1215 commented 6 years ago

Hi, seantempesta My yolo v2 conversion cannot work, either. How to remove the reorg layer?

fengjihua commented 6 years ago

weights_header = np.ndarray( shape=(4, ), dtype='int32', buffer=weights_file.read(16))

change to:

weights_header = np.ndarray( shape=(4, ), dtype='int32', buffer=weights_file.read(20))

michaeldong commented 6 years ago

@fengjihua seem problem. I change buffer=weights_file.read(16)) to buffer=weights_file.read(20)) not work

michaeldong commented 6 years ago

from yolo model convert to h5, Even you change "weights_file.read(16)) to buffer=weights_file.read(20))" You still can't detect objects. I strong suggest you https://github.com/hollance/YOLO-CoreML-MPSNNGraph/issues/7 richard-giantrobot Answer is Good!

tgandor commented 5 years ago

I'm also having this issue. I suspected RGB and BGR channel ordering, but it seems to have little effect. My average recall on training is far greater than 0.5 (approaching 1) in most batches, and still, the converted version detects 0 boxes on the training set. Maybe it's time to try YOLOv3 with its own Python wrappers...

alecGraves commented 5 years ago

Keras Retinanet is also a great option if you don't need crazy speed (it's only 5-10 fps on a 1060) and want a nice, easy-to-use object detection package.

Sorry, but this project has kinda become inactive. @allanzelener disappeared :'(