Using OpenVino pre-trained models with AWS Sagemaker - deep-learning

I'm looking to deploy a pre-trained model for real-time pedestrian and/or vehicle detection using the AWS Sagemaker workflow, I particularly want to use Sagemaker Neo to compile the model and deploy it on the edge. I want to use one of OpenVino's prebuilt models from their model zoo, but when I download the model it is already in their Intermediate Representation (IR) format for their own optimizer.
Is there a way to get an OpenVino pre-trained model not in IR format so that I can use it in sagemaker? Or any possible way to containerize the OpenVino model for use in sagemaker?
If not, are there any free pre-trained models (using any of the popular frameworks like pytorch, tensorflow, ONXX, etc.) that I can use for vehicle detection from a traffic camera POV? AWS Marketplace does not seem to have much to offer in this regard.

Answers to the query as below:
No.Only in Intermediate Representation (IR) format.
There are a few OpenVINO pre-trained models available for vehicle detection.Check out the list of Object Detection Models that are relevant for vehicle detection on these Github pages.
https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/intel/index.md
https://github.com/openvinotoolkit/open_model_zoo/blob/master/models/public/index.md

Related

Integration a deep learning model with ROS

I am using VLP-16 velodyne sensor, I try to detect pedestrians by some deep learning methods.
But I don't know how to use the trained model with ROS.
For example, write a ros node to get the trained model and integrate it with other packages such as velodyne_driver.
I would be grateful if someone could give me some suggestions to achieve it.
Thanks:)

Ray RLllib: Export policy for external use

I have a PPO policy based model that I train with RLLib using the Ray Tune API on some standard gym environments (with no fancy preprocessing). I have model checkpoints saved which I can load from and restore for further training.
Now, I want to export my model for production onto a system that should ideally have no dependencies on Ray or RLLib. Is there a simple way to do this?
I know that there is an interface export_model in the rllib.policy.tf_policy class, but it doesn't seem particularly easy to use. For instance, after calling export_model('savedir') in my training script, and in another context loading via model = tf.saved_model.load('savedir'), the resulting model object is troublesome (something like model.signatures['serving_default'](gym_observation) doesn't work) to feed the correct inputs into for evaluation. I'm ideally looking for a method that would allow for easy out of the box model loading and evaluation on observation objects
Once you have restored from checkpoint with agent.restore(**checkpoint_path**), you can use agent.export_policy_model(**output_dir**) to export the model as a .pb file and variables folder.

Pretraining a language model on a small custom corpus

I was curious if it is possible to use transfer learning in text generation, and re-train/pre-train it on a specific kind of text.
For example, having a pre-trained BERT model and a small corpus of medical (or any "type") text, make a language model that is able to generate medical text. The assumption is that you do not have a huge amount of "medical texts" and that is why you have to use transfer learning.
Putting it as a pipeline, I would describe this as:
Using a pre-trained BERT tokenizer.
Obtaining new tokens from my new text and adding them to the existing pre-trained language model (i.e., vanilla BERT).
Re-training the pre-trained BERT model on the custom corpus with the combined tokenizer.
Generating text that resembles the text within the small custom corpus.
Does this sound familiar? Is it possible with hugging-face?
I have not heard of the pipeline you just mentioned. In order to construct an LM for your use-case, you have basically two options:
Further training BERT (-base/-large) model on your own corpus. This process is called domain-adaption as also described in this recent paper. This will adapt the learned parameters of BERT model to your specific domain (Bio/Medical text). Nonetheless, for this setting, you will need quite a large corpus to help BERT model better update its parameters.
Using a pre-trained language model that is pre-trained on a large amount of domain-specific text either from the scratch or fine-tuned on vanilla BERT model. As you might know, the vanilla BERT model released by Google has been trained on Wikipedia and BookCorpus text. After the vanilla BERT, researchers have tried to train the BERT architecture on other domains besides the initial data collections. You may be able to use these pre-trained models which have a deep understanding of domain-specific language. For your case, there are some models such as: BioBERT, BlueBERT, and SciBERT.
Is it possible with hugging-face?
I am not sure if huggingface developers have developed a robust approach for pre-training BERT model on custom corpora as claimed their code is still in progress, but if you are interested in doing this step, I suggest using Google research's bert code which has been written in Tensorflow and is totally robust (released by BERT's authors). In their readme and under Pre-training with BERT section, the exact process has been declared. This will provide you with Tensorflow checkpoint, which can be easily converted to Pytorch checkpoint if you'd like to work with Pytorch/Transformers.
It is entirely possible to both pre-train and further pre-train BERT (or almost any other model that is available in the huggingface library).
Regarding the tokenizer - if you are pre-training on a a small custom corpus (and therefore using a trained bert checkpoint), then you have to use the tokenizer that was used to train Bert. Otherwise, you will just confuse the model.
If your use case is text generation (from some initial sentence/part of sentence), then I can advise you to check gpt-2 (https://huggingface.co/gpt2). I haven't used GPT-2, but with some basic research I think you can do:
from transformers import GPT2Tokenizer, TFGPT2Model
tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
model = TFGPT2Model.from_pretrained('gpt2')
and follow this tutorial: https://towardsdatascience.com/train-gpt-2-in-your-own-language-fc6ad4d60171 on how to train the gpt-2 model.
Note: I am not sure if DeBERTa-V3, for example, can be pre-trained as usual. I have checked their github repo and it seems that for V3 there is no official pre-training code (https://github.com/microsoft/DeBERTa/issues/71). However, I think that using huggingface we can actually do it. Once I have time I will run a pre-training script and verify this.

How to create a keypoint detection model for human with custom dataset

I am trying to build a key-points detection model for human, as there are many pretrained networks available to generate key-points, but i want to practice myself to create a keypoint detection model with custom dataset, cant find anything in web if someone have some info's then please share.
I want more points specified to the human body, but to do so i need to create a custom model to generate such kind of key-points in human body, i checked some annotation tools but those annotation tool helps to adjust the points they have already specified when taking dataset like COCO etc, i think we cant add more points to the image. i just want to build a new model with custom key-points.
please share your views about my view on to the problem and please suggest some links if you have any idea about the same
I have created a detailed github repo Custom Keypoint Detection for dataset preparation, model training and inference on Centernet-hourglass104 keypoint detection model based on Tensorflow Object detection API with examples.
This could help you in training your keypoint detection model on custom dataset.
Any issues related to the project can be raised in the github itself and doubts can be cleared here.

what is the type of deep learning algorithm in Rapidminer?

I use rapid-miner's deep learning operator for classification. But I can not find the type of deep learning algorithms.
Does Rapidminer use Convolutional Neural Networks (CNNs) or Recurrent Neural Networks (RNNs) or others?
Please help me.
RapidMiner provides an H2O integration for multi-layer feed-forward artificial neural networks.
There is also a new Kerras extension available which integrates an interface to the python library.
Regarding the DL4J project, you need to build the extension with gradle and then put the compiled *.jar file into the extension folder in your '.RapidMiner' folder.
Also feel free to ask further, or re-post, questions in the RapidMiner community forum.
This is just a regular MLP (many layers of fully connected neurons), as specified in the documentation, no convolutions, recurrence or anything more complex, just good old MLP.