Giter VIP home page Giter VIP logo

mobilenet_v2_ssdlite_keras's Introduction

mobilenet_v2_ssdlite_keras

A keras version of real-time object detection network: mobilenet_v2_ssdlite

the pretrained weights file in the 'pretrained_weights' folder

the model structure in the 'model' folder

the train and inference process in the 'experiments' folder

mobilenet_v2_ssdlite_keras's People

Contributors

markshih91 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

Watchers

 avatar  avatar  avatar

mobilenet_v2_ssdlite_keras's Issues

Inference time IOU setting has no effect

I have trained the model on a custom dataset
When I do inferencing there are multiple bbox for the same object and even after changing IOU value from 0.9 to 0.1.
I am not sure why IOU is not taking any effect on inferencing

Did anybody face a similar problem?

Thank you

Invalid argument: ConcatOp : Dimensions of inputs should match: shape[0] = [1,2268,81] vs. shape[2] = [1,4000,8]

Hello, @markshih91 , thanks for your repo first !
I cloneed this repo, and try to adapt it to TF 2.1 -gpu by modifying a few API.
After i modified all the APIs, and run inference.py, pycharm shows below error:
Snipaste_2020-01-31_13-25-46
Could you give me some suggestion to fix it ? thanks!
哈喽,博主你好,首先感谢你上传了这个仓库
我下载了这个仓库,并试图把它改编成适应TF2.1-gpu,这主要就是改改API
当我把这些API都改完之后再运行inference.py,pycharm报出了上图的错误
你能给一些建议来解决它吗?谢谢!

python3 experiments/inference.py error

tensorflow 2.4.0
keras 2.4.3

KerasTensor(type_spec=TensorSpec(shape=(None, 2268, 81), dtype=tf.float32, name=None), name='ssd_mbox_conf_softmax/truediv:0', description="created by layer 'ssd_mbox_conf_softmax'")
KerasTensor(type_spec=TensorSpec(shape=(None, 2268, 4), dtype=tf.float32, name=None), name='ssd_box/concat:0', description="created by layer 'ssd_box'")
KerasTensor(type_spec=TensorSpec(shape=(None, 4000, 8), dtype=tf.float32, name=None), name='ssd_priorbox/concat:0', description="created by layer 'ssd_priorbox'")
Traceback (most recent call last):
File "experiments/inference.py", line 42, in
model = mobilenet_v2_ssd(image_size, n_classes, mode, l2_regularization, min_scale, max_scale, scales,
File "/Users/xx/Work/AI/TF/code/mobilenet_v2_ssdlite_keras/models/keras_mobilenet_v2_ssdlite.py", line 386, in mobilenet_v2_ssd
predictions = Concatenate(axis=0, name='ssd_predictions')([cls, box, priorbox])
File "/Users/xx/.conda/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 951, in call
return self._functional_construction_call(inputs, args, kwargs,
File "/Users/xx/.conda/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1090, in _functional_construction_call
outputs = self._keras_tensor_symbolic_call(
File "/Users/xx/.conda/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 822, in _keras_tensor_symbolic_call
return self._infer_output_signature(inputs, args, kwargs, input_masks)
File "/Users/xx/.conda/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 862, in _infer_output_signature
self._maybe_build(inputs)
File "/Users/xx/.conda/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py", line 2710, in _maybe_build
self.build(input_shapes) # pylint:disable=not-callable
File "/Users/xx/.conda/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/utils/tf_utils.py", line 272, in wrapper
output_shape = fn(instance, input_shape)
File "/Users/xx/.conda/envs/tensorflow/lib/python3.8/site-packages/tensorflow/python/keras/layers/merge.py", line 519, in build
raise ValueError(err_msg)
ValueError: A Concatenate layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 2268, 81), (None, 2268, 4), (None, 4000, 8)]

Tensorflow and keras version issue

Hi @markshih91 ,

Could you please provide a requirement.txt or tensorflow , keras version you have used for this project?

I tried
tensorflow :2.3.1 | keras : 2.2.0
tensorflow :1.4 | keras : 2.0.8

Thanks

make it work

who can tell me,make the project work,Version number required keras and tensorflow.
请问,让代码跑起来,需要的tensorflow 和keras的版本号各是多少?我这边总报错。

谢谢!

experiment/train.py error

When I use my own dataset for training, I got this error message at model.fit_generator.

Tensor conversion requested dtype float32_ref for Tensor with dtype float32: 'Tensor("Adam/bbn_stage1_block1_conv/kernel/m/Initializer/zeros:0", shape=(3, 3, 3, 32), dtype=float32)'

Would you meet this error ever?

Predictions seem to be off even when the loss / val-loss is low

Hi @markshih91

I trained your model on a toy dataset where the task was just to predict the edges of randomly generated black rectangles on a white background, something which should be a simple task.

The loss and val-loss seem to be low here but the predictions seem to be very much off (Negative values in the predictions seem to be the norm, which I've truncated). Is this because of an error in the decoding layer?

This is a snapshot of the loss.
loss

The predictions (seen in red) -
predictions

My model is configured to train using the following configuration

aspect_ratios_per_layer = [[1.0, 2.0, 0.5], 
                           [1.0, 2.0, 0.5, 3.0, 1.0 / 3.0], 
                           [1.0, 2.0, 0.5, 3.0, 1.0 / 3.0],
                           [1.0, 2.0, 0.5, 3.0, 1.0 / 3.0], 
                           [1.0, 2.0, 0.5],
                           [1.0, 2.0, 0.5]]

predictor_sizes = [model.get_layer('ssd_cls1conv2_bn').output_shape[1:3],
                   model.get_layer('ssd_cls2conv2_bn').output_shape[1:3],
                   model.get_layer('ssd_cls3conv2_bn').output_shape[1:3],
                   model.get_layer('ssd_cls4conv2_bn').output_shape[1:3],
                   model.get_layer('ssd_cls5conv2_bn').output_shape[1:3],
                   model.get_layer('ssd_cls6conv2_bn').output_shape[1:3]]
image_size=(416,416,3)
n_classes=1
min_scale=0.3 
max_scale=0.9
normalize_coords=False
subtract_mean=None
divide_by_stddev=None
swap_channels=None #[2,1,0],
confidence_thresh=0.01
iou_threshold=0.45
top_k=200
scales = None
aspect_ratios_global = None
return_predictor_sizes = False
two_boxes_for_ar1=True
steps=None
offsets=None
clip_boxes=True
variances=[0.1, 0.1, 0.2, 0.2]
matching_type='multi'
pos_iou_threshold=0.45
neg_iou_limit=0.3

model = mobilenet_v2_ssd(
    image_size=image_size,
    n_classes=n_classes,
    min_scale=min_scale, 
    max_scale=max_scale,
    coords='corners',
    mode='training',
    clip_boxes=clip_boxes,
    normalize_coords=normalize_coords,
    subtract_mean=subtract_mean,
    divide_by_stddev=divide_by_stddev,
    swap_channels=swap_channels,
    confidence_thresh=confidence_thresh,
    iou_threshold=iou_threshold,
    top_k=top_k
)

And it predicts using similar configurations, except with top_k=1, coords='centroids', mode='inference'

I've trained with a large-ish dataset composed of around 3000 images for the training set and 500 images on the validation set. The predictions you see are on the training set itself which I expected to be better due to the reportedly low loss. The rest of the training config is similar to that of the example posted. The ground truth is of the format image-name, class, xmin, ymin, xmax, ymax

Thanks in advance!

Loss quickly stabilizes around 8 and does not converge

Hi @markshih91
I have used your model to train COCO dataset. I just found 1 error in your script *ssdlite_praph.py one of the link definition were missing. Unfortunately it does quickly stabilize around 5000 steps. I also tested with scales modified in train.py as suggested by @pierluigiferrari but no real difference. Did you trained with the version you have posted? Can you share your training experience here? Thx

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.