Reputation: 11
I usually create just object recognition or classification. There is plenty tutorials on internet and its quite easy. It has usually few line of code:
1. load dataset
2. create model
3. model.compile()
4. model.fit()
5. load test image
6. model.predict()
The problem is, that it can just say if there is banana, apple, orange etc. But I want to localize the object in the image. I want object detection. The problem is that I can't find some easy code as I mention above. Can you recommend me something?
I just found tensorflow object detection API and its not so easy as above mentioned object recognition.
Thank you for your advices.
Upvotes: 1
Views: 1869
Reputation: 1184
Hope this helps others trying to do Transfer learning using tensorflow object detection api
I found this Transfer learning with TensorFlow Hub, this link is about classification
changing the code for object detection
should be a nice learning curve for how every tries it out.
It basically has 3 steps
This tutorial demonstrates how to:
- Use models from TensorFlow Hub with tf.keras.
- Use an image classification model from TensorFlow Hub.
- Do simple transfer learning to fine-tune a model for your own image classes.
You can have a look at the Downloading the model section which has a classifier as a example
You can check out pre trained object detection model that the Tensorflow Hub currently support
Here are a few good once's
Model name | Speed (ms) | COCO mAP |
---|---|---|
CenterNet HourGlass104 512x512 | 70 | 41.9 |
EfficientDet D2 768x768 | 67 | 41.8 |
EfficientDet D3 896x896 | 95 | 45.4 |
SSD ResNet101 V1 FPN 640x640 (RetinaNet101) | 57 | 35.6 |
CenterNet Resnet101 V1 FPN 512x512 | 34 | 34.2 |
CenterNet Resnet50 V1 FPN 512x512 | 27 | 31.2 |
Step 1
and Step 2
can be completed if you follow the previous section properly.
You can use this section simple_transfer_learning
You have to got through the entire Transfer learning with TensorFlow Hub to understand more
You have colab code readymade for you to test it out as well
It is better you raise any issues you have at tensorflow/models github page issues
PS: There seem to be no option to freeze the weight inside pipeline.config
of any of tensorflow hub models for both feature extraction
layers and final
layer, no official support from the tensorflow guys on github also. Training without freezing has been shown to give degrading results for one user according to github tensorflow comment. I would suggest using pytorch
where we use requires_grad=False
to freeze weights
Upvotes: 1
Reputation: 430
Generally, I think object detection is a bit harder to setup. But there is this keras tutorial I quite like for its simplicity while it also dives in a bit deeper if you're interested. If you combine the initialization of the model with the training parts and add the needed functions, the overall complexity isn't that bad. But to understand every step, it requires way more effort.
resnet50_backbone = get_backbone()
loss_fn = RetinaNetLoss(num_classes)
model = RetinaNet(num_classes, resnet50_backbone)
optimizer = tf.optimizers.SGD(learning_rate=learning_rate_fn, momentum=0.9)
model.compile(loss=loss_fn, optimizer=optimizer)
epochs = 1
model.fit(
train_dataset.take(100),
validation_data=val_dataset.take(50),
epochs=epochs,
callbacks=callbacks_list,
verbose=1,
)
Upvotes: 0
Reputation: 2385
Of course, object detection is not easy compared to image classification. It's a harder problem to solve and requires more work in terms of gathering and labeling data. Maybe you didn't find good documentation or a source for helping you out? You can check this detailed explanation of setting up the object detection for training/testing on your custom dataset
Upvotes: 0