Git Product home page Git Product logo

keras-yolov3-mobilenet's Introduction

keras-yolo3-Mobilenet

license

Introduction

A Keras implementation of YOLOv3 (Tensorflow backend) inspired by allanzelener/YAD2K.

And I change the backend of darknet53 into

  • Mobilenet
  • VGG16
  • ResNet101
  • ResNeXt101

Experiment on open datasets

Model name InputSize TrainSet TestSet mAP Speed Ps
YOLOv3-Mobilenet 320x320 VOC07 VOC07 64.22% 29fps Keras on 1080Ti
YOLOv3-Mobilenet 320x320 VOC07+12 VOC07 74.56% 29fps Keras on 1080Ti
YOLOv3-Mobilenet 416x416 VOC07+12 VOC07 76.82% 25fps Keras on 1080Ti
MobileNet-SSD 300x300 VOC07+12+coco VOC07 72.7% (unknown)
MobileNet-SSD 300x300 VOC07+12 VOC07 68% (unknown)
Faster RCNN, VGG-16 ~1000x600 VOC07+12 VOC07 73.2% 151ms Caffe on Titan X
SSD,VGG-16 300x300 VOC07+12 VOC07 77.5% 39fps Keras on Titan X

PS:

  1. Compared with MobileNet-SSD, YOLOv3-Mobilenet is much better on VOC2007 test, even without pre-training on Ms-COCO
  2. I use the default anchor size that the author cluster on COCO with inputsize of 416*416, whereas the anchors for VOC 320 input should be smaller. The change of anchor size could gain performance improvement.
  3. Evaluation on https://github.com/Adamdad/Object-Detection-Metrics.git
  4. I only use the pure model of YOLOv3-Mobilenet with no additional tricks.

Guide of keras-yolov3-Mobilenet

1.train_Mobilenet.py

  • Code for training
  • I change some of the code to read in the annotaions seperately (train.txt and val.txt), remember to change that, and the .txt file are in the same form descibed below

2.yolo3/model_Mobilenet.py

  • Model_Mobilenet is the yolo model based on Mobilenet
  • If you want to go through the source code,ignore the other function,please see the yolo_body (I extract three layers from the Mobilenet to make the prediction)

3.yolo_Mobilenet.py

  • Testing on images
Be sure that you do not load pretrained model when training because I did it on keras_applications,and the keras will load the pretrained model for you
if you find anything tricky, contact me as you wish

Evaluation

Please use this repo to draw the RP curve calculate the MAP https://github.com/Adamdad/Object-Detection-Metrics.git


Guide of keras-yolov3

[this is the guide for darknet53 not mobilenet]

Quick Start

  1. Download YOLOv3 weights from YOLO website.
  2. Convert the Darknet YOLO model to a Keras model.
  3. Run YOLO detection.
wget https://pjreddie.com/media/files/yolov3.weights
python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5
python yolo_video.py [OPTIONS...] --image, for image detection mode, OR
python yolo_video.py [video_path] [output_path (optional)]

For Tiny YOLOv3, just do in a similar way, just specify model path and anchor path with --model model_file and --anchors anchor_file.

Usage

Use --help to see usage of yolo_video.py:

usage: yolo_video.py [-h] [--model MODEL] [--anchors ANCHORS]
                     [--classes CLASSES] [--gpu_num GPU_NUM] [--image]
                     [--input] [--output]

positional arguments:
  --input        Video input path
  --output       Video output path

optional arguments:
  -h, --help         show this help message and exit
  --model MODEL      path to model weight file, default model_data/yolo.h5
  --anchors ANCHORS  path to anchor definitions, default
                     model_data/yolo_anchors.txt
  --classes CLASSES  path to class definitions, default
                     model_data/coco_classes.txt
  --gpu_num GPU_NUM  Number of GPU to use, default 1
  --image            Image detection mode, will ignore all positional arguments

  1. MultiGPU usage: use --gpu_num N to use N GPUs. It is passed to the Keras multi_gpu_model().

Training

  1. Generate your own annotation file and class names file.
    One row for one image;
    Row format: image_file_path box1 box2 ... boxN;
    Box format: x_min,y_min,x_max,y_max,class_id (no space).
    For VOC dataset, try python voc_annotation.py
    Here is an example:

    path/to/img1.jpg 50,100,150,200,0 30,50,200,120,3
    path/to/img2.jpg 120,300,250,600,2
    ...
    
  2. Make sure you have run python convert.py -w yolov3.cfg yolov3.weights model_data/yolo_weights.h5
    The file model_data/yolo_weights.h5 is used to load pretrained weights.

  3. Modify train.py and start training.
    python train.py
    Use your trained weights or checkpoint weights with command line option --model model_file when using yolo_video.py Remember to modify class path or anchor path, with --classes class_file and --anchors anchor_file.

If you want to use original pretrained weights for YOLOv3:
1. wget https://pjreddie.com/media/files/darknet53.conv.74
2. rename it as darknet53.weights
3. python convert.py -w darknet53.cfg darknet53.weights model_data/darknet53_weights.h5
4. use model_data/darknet53_weights.h5 in train.py


Some issues to know

  1. The test environment is

    • Python 3.5.2
    • Keras 2.1.5
    • tensorflow 1.6.0
  2. Default anchors are used. If you use your own anchors, probably some changes are needed.

  3. The inference result is not totally the same as Darknet but the difference is small.

  4. The speed is slower than Darknet. Replacing PIL with opencv may help a little.

  5. Always load pretrained weights and freeze layers in the first stage of training. Or try Darknet training. It's OK if there is a mismatch warning.

  6. The training strategy is for reference only. Adjust it according to your dataset and your goal. And add further strategy if needed.

  7. For speeding up the training process with frozen layers train_bottleneck.py can be used. It will compute the bottleneck features of the frozen model first and then only trains the last layers. This makes training on CPU possible in a reasonable time. See this for more information on bottleneck features.

Citation

Please cite MobileNet-YOLO in your publications if it helps your research:

@article{MobileNet-Yolov3,
     Author = {Adam Yang},
     Year = {2018}
}
 @article{yolov3,
     title={YOLOv3: An Incremental Improvement},
     author={Redmon, Joseph and Farhadi, Ali},
     journal = {arXiv},
     year={2018}
}
@article{mobilenets,
     title={MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications},
     author={Andrew G. Howard, Menglong Zhu, Bo Chen,Dmitry Kalenichenko,Weijun Wang, Tobias Weyand,Marco Andreetto, Hartwig Adam},
     journal = {arXiv},
     year = {2017}
}

keras-yolov3-mobilenet's People

Contributors

adamdad avatar b02902131 avatar dleam avatar jiaowoboshao avatar philtrade avatar qqwweee avatar stefanbo92 avatar tanakataiki 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

keras-yolov3-mobilenet's Issues

transplant

this net can be transplant to mobile phone, have you try? ths!

Could you give detailed information to use yolo_Mobilenet.py

Hello,
Thanks for your sharing code.
I had done successfully until step 2 (I made voc2007.h5 file).
But next step, yolo_Mobilenet.py is so difficult to use.
I'm having trouble to use function detect_img and detect_video in yolo_Mobilenet.py.

Could you explain with detail of step 3 part?

Some trouble about structure

Hi,I see your change in the structure of YOLO3 ,perfect! But I want to know what need to modify if I want to change the structure with my mind?

What should I do to train model with 1080p images

If I want to train model with 1080p image, or other size image, what should I do? The val_loss > 4000 。。。

Train on 5022 samples, val on 557 samples, with batch size 32. Epoch 1/50 156/156 [==============================] - 481s 3s/step - loss: 1247.0383 - val_loss: 6076.1475 Epoch 2/50 156/156 [==============================] - 451s 3s/step - loss: 232.9773 - val_loss: 6009.3626 Epoch 3/50 156/156 [==============================] - 451s 3s/step - loss: 166.7342 - val_loss: 6068.7722

about the tracking ID

thanks your code, i had run it successfully on Nvidia Jetson TX2. It looks good.
However, as a freshman, i have two questions:

  1. i see that you output every detection result of each frame in the terminal, if i want to get the tracking id and corresponding timestamp,
    for example, the same car that appears in a part of the test video should only have one tracking id in the tracker, and be outputted in the terminal with the timestamp when it is first detected by yolo

  2. if i want to get the realtime FPS when test by video, how can i edit the code, tried to add this function in yolo_video.py but failed.

could you please tell me how to achieve that?

Thanks in advance!

Need some example content for train.txt

Hi ,
When I run train.py I get following error
AssertionError: class id must be less than num_classes
I have only one class and I made changes in yolov3.config as required.

My train.txt file contents are like this

data/armas10.jpg 409,95,697,352,0
data/armas100.jpg 184,148,283,229,0
data/armas1000.jpg 97,4,215,96,0
data/armas1001.jpg 96,17,227,72,0
....

Could you tell me what is the mistake :)

problem of .h5 to .pb

Hi, thanks for you to share this project for us. i followed this way to convert the model .h5 to .pb. https://github.com/amir-abdi/keras_to_tensorflow but i got a problem is that 'the model is read only' when i try to do it .
then i try to follow this way to use two ways to get a new model , the first is use model.save() to save the final model, and then to convert the .h5 to .pb, the error is that "yolo_head is not defined"
the second way is that i use model.save_weights(), and also save the model's json file use model.to_json(), when the code try to save the .json file, there also got the same problem that 'yolo_head is not defined'.
could please give me some advices on how to solve this problem . thanks very much .

Training and Validation Loss

I am training the Yolo with MobilenetV1 on VOC07+12 trainval dataset. I loaded Mobilenet with imagenet weights and built Yolo layers on top of it. I freeze the Mobilnet for first 50 epochs and tried to train to get a stabilized loss, after that I unfreeze all layers to train the network further.

I trained up to 105 epochs and still on it, the training loss decreased from 26 to around 12, val loss is around 14, and now further the loss is not decreasing and fluctuating around 12 and 14 respectively, as the loss is on Plateau the learning rate got decreased from 1e-4 to 1e-8.

I want to know:
Is this normal ?
Should I still continue training further ?
If anyone trained on the same dataset, I wanted to know the optimum loss they could reach ? (My each epoch is taking approximately 20mins)

Specifications:
Dataset : VOC 07+12 trainval with 0.1% validation set
Batch size : 16
Input shape : (416, 416)
Training on : Google Colab GPU

How to use it?

Hello. Please explain how to use your fork?
Do I need pretrained weight for mobile net?
You also mentioned train.txt and val.txt, but they are not present.
Please help, because it's really interesting.

How can I use MultiGPU?

when I use --gpu_num 2, just one GPU work and another GPU occupies Bus-Id but doesn't work。

when I try to add " from keras.utils import multi_gpu_model"
and change "p_model = multi_gpu_model(model, gpus=2)
p_model.compile(optimizer=Adam(lr=1e-4), loss={'yolo_loss': lambda y_true, y_pred: y_pred})"

rasie Error:

File "train.py", line 194, in
_main()
File "train.py", line 75, in _main
p_model = multi_gpu_model(model, gpus=2)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/keras/utils/multi_gpu_utils.py", line 239, in multi_gpu_model
axis=0, name=name))
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/keras/layers/merge.py", line 641, in concatenate
return Concatenate(axis=axis, **kwargs)(inputs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py", line 457, in call
output = self.call(inputs, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/keras/layers/merge.py", line 155, in call
return self._merge_function(inputs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/keras/layers/merge.py", line 357, in _merge_function
return K.concatenate(inputs, axis=self.axis)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 1934, in concatenate
return tf.concat([to_dense(x) for x in tensors], axis)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/array_ops.py", line 1114, in concat
return gen_array_ops.concat_v2(values=values, axis=axis, name=name)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1030, in concat_v2
"ConcatV2", values=values, axis=axis, name=name)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func
return func(*args, **kwargs)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3155, in create_op
op_def=op_def)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1731, in init
control_input_ops)
File "/home/ubuntu/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1579, in _create_c_op
raise ValueError(str(e))
ValueError: Can't concatenate scalars (use tf.stack instead) for 'yolo_loss_1/concat' (op: 'ConcatV2') with input shapes: [], [], [].

no test result

as i trained the model on widerface dataset for face detection,
the loss
875/875 [==============================] - 1327s 2s/step - loss: 13.1126 - val_loss: 13.7300
loos not decrease , and test no bbox output result.

do you know the reason

nan loss when training from scratch

Hi! When i’m training from scratch (withiut freezing or preuploading weights, on coco2014 train or coco2017) loss is decrease from 4k till 100 for first hundreds of iterations. And then loss is nan. Is it normal? Do you have the same behaviour, or do I need to check my data?

Training errors

Create YOLOv3 model with 9 anchors and 5 classes.
[<tf.Tensor 'conv2d_7/BiasAdd:0' shape=(?, ?, ?, 30) dtype=float32>, <tf.Tensor 'conv2d_15/BiasAdd:0' shape=(?, ?, ?, 30) dtype=float32>, <tf.Tensor 'conv2d_23/BiasAdd:0' shape=(?, ?, ?, 30) dtype=float32>]
Train on 749 samples, val on 0 samples, with batch size 1.
Epoch 1/300
749/749 [==============================] - 276s 368ms/step - loss: 930.2716
Epoch 2/300
749/749 [==============================] - 275s 367ms/step - loss: 75.0715
Epoch 3/300
749/749 [==============================] - 274s 366ms/step - loss: 68.3971
Traceback (most recent call last):
File "train_Mobilenet.py", line 200, in
_main()
File "train_Mobilenet.py", line 75, in _main
callbacks=[logging, checkpoint])
File "/home/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/home/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 1418, in fit_generator
initial_epoch=initial_epoch)
File "/home/anaconda3/lib/python3.6/site-packages/keras/engine/training_generator.py", line 251, in fit_generator
callbacks.on_epoch_end(epoch, epoch_logs)
File "/home/anaconda3/lib/python3.6/site-packages/keras/callbacks.py", line 79, in on_epoch_end
callback.on_epoch_end(epoch, logs)
File "/home/anaconda3/lib/python3.6/site-packages/keras/callbacks.py", line 429, in on_epoch_end
filepath = self.filepath.format(epoch=epoch + 1, **logs)
KeyError: 'val_loss'

convert .h5 to .pb

I have changed the structure of the model, and use "model.save()" to save the model. When I use "h5_model = load_model(weight_file_path, custom_objects={'yolo_loss': lambda y_true, y_pred: y_pred})", an error happended.

File "/home/ubuntu/lmy/program/keras-YOLOv3-mobilenet/yolo3/model.py", line 375, in yolo_loss
grid, raw_pred, pred_xy, pred_wh = yolo_head(yolo_outputs[l],
NameError: name 'yolo_head' is not defined

Convert Darknet conv-lstm to .h5

@Adamdad
Hi ,
Conv-lstm has been added to Darknet and I am trying to convert trained yolov3+conv-lstm to .h5 using your repo (convert.py ).However, it has unsupported header error .I really need to do this .I would be grateful if it is possible add this to your repo or advice me how to proceed .

Many thanks .

about vgg16 of the baseNet?

hello,Why do vgg16 have many similar structures? For example, the following sections

vgg16 = VGG16(input_tensor=inputs,weights='imagenet',include_top=False)
x = vgg16.get_layer('block5_pool').output
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block6_conv1')(x)
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block6_conv2')(x)
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block6_conv3')(x)
x = Conv2D(512, (3, 3), activation='relu', padding='same', name='block6_conv4')(x)

KeyError: 'val_loss'

when i use this to train my dataset I get this error ,Can you help me ?
Create YOLOv3 model with 9 anchors and 16 classes. [<tf.Tensor 'conv2d_7/BiasAdd:0' shape=(?, ?, ?, 63) dtype=float32>, <tf.Tensor 'conv2d_15/BiasAdd:0' shape=(?, ?, ?, 63) dtype=float32>, <tf.Tensor 'conv2d_23/BiasAdd:0' shape=(?, ?, ?, 63) dtype=float32>] Train on 1887 samples, val on 0 samples, with batch size 4. Epoch 1/30 471/471 [==============================] - 163s 346ms/step - loss: 519.5828 Epoch 2/30 471/471 [==============================] - 161s 342ms/step - loss: 108.0543 Epoch 3/30 471/471 [==============================] - 157s 333ms/step - loss: 91.7087 Traceback (most recent call last): File "train_Mobilenet.py", line 199, in <module> _main() File "train_Mobilenet.py", line 74, in _main callbacks=[logging, checkpoint]) File "/home/tf/anaconda3/envs/keras-yolov3-Mobilenet/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/home/tf/anaconda3/envs/keras-yolov3-Mobilenet/lib/python3.5/site-packages/keras/engine/training.py", line 2262, in fit_generator callbacks.on_epoch_end(epoch, epoch_logs) File "/home/tf/anaconda3/envs/keras-yolov3-Mobilenet/lib/python3.5/site-packages/keras/callbacks.py", line 77, in on_epoch_end callback.on_epoch_end(epoch, logs) File "/home/tf/anaconda3/envs/keras-yolov3-Mobilenet/lib/python3.5/site-packages/keras/callbacks.py", line 430, in on_epoch_end filepath = self.filepath.format(epoch=epoch + 1, **logs) KeyError: 'val_loss'

How to modify the network structure?

Here, in order to meet my project I've needed to change some details in mobilenet.py. After that work, there's nothing changed on final result. Eg. I replaced the 'relu6' with 'linear' or 'LeakyReLU', but it still showed us 'relu6' but not others when I read the final .h5 model. So, would you mind show me how to make it work after these basic networks are modified ( based on keras environment)?

MobileNet w/o DepthwiseConv2D?

A key feature of MobileNet is factorizing Conv2D into DepthwiseConv2D and pointwise convolution. This reduce the computation a lot. But seems tiny_yolo_body is just Conv2D.

Cannot move to target thread (0x7fec28bfbad0)

When I test on a video, it raise an error:

QObject::moveToThread: Current thread (0x7fec28bfbad0) is not the object's thread (0x7fec2ae338f0).
Cannot move to target thread (0x7fec28bfbad0)

QPixmap: Must construct a QApplication before a QPaintDevice
Aborted (core dumped)

Questions about performance , loss and data augmentation

Hi,
Thanks for the work.

I'm using train_Mobilenet.py to train train.txt of VOC2007, and try to reproduce the performance on your page (64.22%).
A question first is that, for VOC 2007, do you use the same setting in train_Mobilenet.py (input size, #epoch, etc.) to get the 64.22% model?
What I did is only changing the input size to 416 to fit anchor size and train on the training data of VOC 2007 (no validation data) and validate on 300 images of validation data.
The training loss I get is around 15 and validation loss is around 20 and cannot get lower.
mAP is around 52%.

I have tried increasing the epoch but the result only improve a little.
Did I miss anything? Or there are some other tricks need to be applied to make the result better.
I've been stuck at this for a while, and I'll be very grateful if you can help me with it.

I also take a look of the data generation and found that the data is randomly change size but not keeping the original size ones.
Is there any reason of not keeping them?

Thank you very much for the help.

the weight file's layer is different to the model's layer

hello Adamdad
I try to run the yolo-mobilenet.py, I got the following message, I used the weight that automatic downloaded, named as mobilenet_1_0_224_tf.h5
and i modified that at yolo-mobilenet.py as the following:

class YOLO(object):
def init(self):
self.model_path = 'model_data/mobilenet_1_0_224_tf.h5' # model path or trained weights path
---------------------error messages--------------------
File "D:\Anaconda3\lib\site-packages\keras\engine\saving.py", line 900, in load_weights_from_hdf5_group
str(len(filtered_layers)) + ' layers.')
ValueError: You are trying to load a weight file containing 55 layers into a model with 97 layers.

cheers
Edward

Syntax Error

I got this error when i tried running train_mobilenet.py using python2

File "train_Mobilenet.py", line 138
[*model_body.output, *y_true])
^
SyntaxError: invalid syntax

and when i tried to use python3 this error show up

ImportError: /usr/local/lib/python3/dist-packages/PIL/_imaging.so: undefined symbol: PyString_FromStringAndSize

Hope you can help me Thank you!

AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'

keras==2.1.5,
tensorflow-gpu==1.6.0,
when I trained the code, I got this error:

File "/data/home/anaconda3/envs/keras_YOLOv3/lib/python3.6/site-packages/keras/engine/base_layer.py", line 460, in call
output = self.call(inputs, **kwargs)
File "/data/home/anaconda3/envs/keras_YOLOv3/lib/python3.6/site-packages/keras/layers/advanced_activations.py", line 46, in call
return K.relu(inputs, alpha=self.alpha)
File "/data/home/anaconda3/envs/keras_YOLOv3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 3111, in relu
x = tf.nn.leaky_relu(x, alpha)
AttributeError: module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'
swig/python detected a memory leak of type 'int64_t *', no destructor found.

map

please tell me how to test Map

How you used MobileNet model?

Have you used the pretrained MobileNet model and construct yolo layers on top? And used pretrained MobileNet weights for Mobilenet initialization?

Or you just took the architecture of MobileNet and add yolo layers and started training from scratch using voc or coco?

raise IOError("Couldn't open webcam or video")

Dear Adamdad:
Thank you for your hard work!!!
when I executed the command: python yolo_video.py,but there is an errorr: aise IOError("Couldn't open webcam or video").
while, I have tested that the camera is good.
what's more, i have installed opencv3.4, tf2.0, and yolov3.weights is also have changed well.
what should i do??
Greatful! !

ValueError: Cannot create group in read only mode.OSError: Unable to open file (truncated file: eof = 458752, sblock->base_addr = 0, stored_eof = 17225924)

Traceback (most recent call last):
File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 61, in generate
self.yolo_model = load_model(model_path, compile=False)
File "G:\python\lib\site-packages\keras\engine\saving.py", line 419, in load_model
model = _deserialize_model(f, custom_objects, compile)
File "G:\python\lib\site-packages\keras\engine\saving.py", line 221, in _deserialize_model
model_config = f['model_config']
File "G:\python\lib\site-packages\keras\utils\io_utils.py", line 302, in getitem
raise ValueError('Cannot create group in read only mode.')
ValueError: Cannot create group in read only mode.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 234, in
detect_img(YOLO())
File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 35, in init
self.boxes, self.scores, self.classes = self.generate()
File "F:/keras-YOLOv3-mobilenet-master-my/yolo_my_1.py", line 64, in generate
if is_tiny_version else yolo_body(Input(shape=(None,None,3)), num_anchors//3, num_classes)
File "F:/keras-YOLOv3-mobilenet-master-my\yolo3\model_Mobilenet.py", line 198, in yolo_body
mobilenet = MobileNet(input_tensor=inputs,weights='imagenet')
File "G:\python\lib\site-packages\keras\applications_init_.py", line 28, in wrapper
return base_fun(*args, **kwargs)
File "G:\python\lib\site-packages\keras\applications\mobilenet.py", line 11, in MobileNet
return mobilenet.MobileNet(*args, **kwargs)
File "G:\python\lib\site-packages\keras_applications\mobilenet.py", line 320, in MobileNet
model.load_weights(weights_path)
File "G:\python\lib\site-packages\keras\engine\network.py", line 1157, in load_weights
with h5py.File(filepath, mode='r') as f:
File "G:\python\lib\site-packages\h5py_hl\files.py", line 312, in init
fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
File "G:\python\lib\site-packages\h5py_hl\files.py", line 142, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py\h5f.pyx", line 78, in h5py.h5f.open
OSError: Unable to open file (truncated file: eof = 458752, sblock->base_addr = 0, stored_eof = 17225924)

Can't load model successfully

Hi, i just train a new model by feeding mobilenet pre_trained weights into mobilenet (train.py). But i got train loss non-convergence, always at 30. Should i train mobilnet first by using train_Mobilenet.py ???

loss doesn't decrease and keep on 40 in my dataset

I train with my own dataset with the default script
my dataset has three types of objection with 40000 train sample and 6000 validation sample
the batch_size is 4, my loss decrease to 49 in the first epoch, but loss keep on 40 in the 13th epoch, the loss doesn't decrease anymore.
how should i change my learning rate and others parameter

mAP

Is there a mAP metric in your code?

About the backbone

Hello!
I wonder how could i modified the backbone instead of darknet-53?

Training with other feature extractors

Hey, query with respect to implementing other networks as backends for the Yolov3. Would it be straightforward to implement a Resnet or VGGNet extractor by switching up the keras import for the Mobilenet model in the Yolo model file and extract an equivalent number of layers for prediction?

Please:when I change the dataset into VOC ,the training have some problem

Train on 9657 samples, val on 1073 samples, with batch size 25.
Epoch 1/50
29/386 [=>............................] - ETA: 6:42 - loss: 1466.7280Traceback (most
recent call last):
File "train_Mobilenet.py", line 194, in
_main()
File "train_Mobilenet.py", line 69, in _main
callbacks=[logging, checkpoint])
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\legacy\interfaces.py", line 9
1, in wrapper
return func(*args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training.py", line 141
8, in fit_generator
initial_epoch=initial_epoch)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\engine\training_generator.py"
, line 181, in fit_generator
generator_output = next(output_generator)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\data_utils.py", line 70
9, in get
six.reraise(*sys.exc_info())
File "C:\ProgramData\Anaconda3\lib\site-packages\six.py", line 693, in reraise
raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\data_utils.py", line 68
5, in get
inputs = self.queue.get(block=True).get()
File "C:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 644, in get
raise self._value
File "C:\ProgramData\Anaconda3\lib\multiprocessing\pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\utils\data_utils.py", line 62
6, in next_sample
return six.next(_SHARED_SEQUENCES[uid])
File "train_Mobilenet.py", line 179, in data_generator
image, box = get_random_data(annotation_lines[i], input_shape, random=True)
File "E:\CTB\VOC-mobilenet-YOLOv3-keras\yolo3\utils.py", line 39, in get_random_data

image = Image.open(line[0])

IndexError: list index out of range

Could you share pre-trained weight?

Thanks for the work.
Could you share pre-trained weight of mobilenet | 320*320 | VOC 2007 ?
I'm using train_Mobilenet.py to train VOC2007 dataset, but I get the mAP 32%.
I find that the train loss and val loss are around 13 and cannot get lower.
I have tried increasing the epoch but the performance only improve a little.
Could you share pre-trained weight or some information of hyperparameters(learning rate、epoch etc.)

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.