T03:- How to convert given existing model into DLC format
Conversion of given model into DLC format
We will try to convert the machine learning model which is given in the neural processing sdk
into the Dlc format manually.
-> We are doing this step because SDK tools and libraries are able to understand the code only in the
converted DLC format.
->We will first make directory like above structure in this path /opt/qcom/aistack/snpe/<Version_ number>/examples/Models/InceptionV3
-> We will make a folder data.
mkdir data && cd data
-> Then we will make another subfolder into data folder.
mkdir cropped
-> Then we will come out from that folder data.
-> After that we will make dlc and tensorflow folder in the InceptionV3 folder.
mkdir dlc && tensorflow
After making all the required folders into InceptionV3 model , we will download InceptionV3 Model into the tmp folder into snpe root(/opt/qcom/aistack/snpe/<version_number>)
-> We will make a folder named as tmp into snpe root.
mkdir tmp
-> Copy this into the terminal for the download of Inception model and its asset.
-> wget -N ./tmp "https://storage.googleapis.com/download.tensorflow.org/models/inception_v3_2016_08_28_frozen.pb.tar.gz"
Now we will extract the InceptionV3 tar file into folder like below image.
mkdir tensorflow_dlc_data/cropped
-> then we will extract tar file by following this command.
tar -xzf ./tmp/inception_v3_2016_08_28_frozen.pb.tar.gz -C Model/InceptionV3/tensorflow
-> Now we will Copy the list of trained data set to data folder for classification purpose
cp tensorflow/imagenet_slim_labels.txt data/
So, we will prepare the input data set for the conversion process.
-> The Neural processing sdk able to accept only raw files which is of size 299*299 .
Here -i means we have to give the path for the input data path and -d means we have to give the cropped file -s 299.
We are making this because to make the raw file of the image data.
After this step of conversion of raw file , we will first a raw list file by following this conversion process.
-> Actually you have to go to the scripts file and look for the create_file_list.py for the conversion process of raw file into the raw file list.
->And then you have to make another raw file list for the target device which is given in the image
itself.
So now at last step you have to convert the inception_v3 model into the dlc format by using the below command .
Lets understand this command snpe-tensorflow-to-dlc --graph
tensorflow/inception_v3_2016_08_28_frozen.pb
--input_dim input "1, 299,299,3"
--out_node InceptionV3/Predictions/Reshape_1
--dlc inception_v3.dlc
So, snpe-tensorflow-to-dlc is an tool which is present in the snpe root folder . We will use this and convert our machine learning model into dlc.
--graph means our InceptionV3 model path we have to give.
--input_dim input means we have to give model input dimension which can be known by searching the inceptionv3 model
--out_node It means what is the outputNode dimension of the architecture layer.
--dlc means we have to give the path where we have to dlc file path where we want to put our dlc file.
So , now in the next article we will understand how we can actually run this dlc file onto the target device.
Comments
Post a Comment