MXNet:训练自己的数据并做预测
来源:互联网 发布:java安装失败 卸载 编辑:程序博客网 时间:2024/05/21 09:05
Prepare the input data
Because the input data’s formt of MXNet is rec,so we must turn the image into the .rec format,as folow:
First, we prepare some face images data stored in ‘test_face’ file:
step1:build the txt or lst format from the images
Now,we have so many images in hand.Next,we make some changes to them that generate a list or a txt about the images.As for the list or txt,its format as folllows:
To see explicitly,we can see an image below:
Of course, we still need the test.lst or test.txt.
step2:generate the .rec from txt or lst
Under our MXNet root diretory,we can see
so,we can build the rec doc by using ‘im2rec’.
The comman as folows:
Here,we can see three parameters.They are:
the first param: the path of your lst or txt have been build;
the second one: the path of your images;
the third one: the path of your .rec.
OK,so far we have the rec doc of train data,but we still lack the rec of test data.In that,we can generate the test.rec with the same method.Finally,you can get four files:
Good luck!
Construct the net
In this step,we can construct the net ourselves,but at first best do not.Because we can use the off-the-shelf models or net to achieve more higher use.And furthermore,it can save twists and turns at first.And it is so-called ‘standing on the shoulders of giants’.Hence,the simplest way is to make a little change on the off-th-shelf net.
As for the off-the-shelf examples,we can find under ‘mxnet/examples/image-classification/’ and ‘mxnet/tests/python/’ .
step1:New a folder named ‘MyTrainMxnet’;the folder path is freewill;
step2:Copy four files below to th new folder ‘MyTrainMxnet’;
Attention:Here we choose the ineption-bn-28-small net,of course, you can choose others,e.g alexnet..
step3:Let’s make some changes.
1.Rename the ‘symbol_inception-bn-28-small.py’ as ‘my-inception.py’;
2.Rename the ‘train_mnist.py’ as ‘train_face.py’;
3.Open ‘train_face.py’ and do some changes;
Delete the ‘symbol’,otherwise your model file must begin with ‘symbol’.
Train the model
Of course we can choose not do these changes.Instead,we can add ‘–network’ and ‘–data-dir’ in the command,as folows:
In addition, we can add other params if we need in the command above.
Attention:If you want to save the trained-well model after every epoch,please must add ‘–model-prefix’.And you will get it when making prediction afterwards.
Ok,the training step may need much time when cpu-only.So we can wait in patience.
Make a prediction
When you complete the training work,you will find:
Now,we can make a prediction using the test data.
First,we need write a prediction file named ‘predict_face.py’,its contents as follow:
Attention:Remember to change the path into yours.
Ok,hereto it’s over.
If yu want to make predition using new data,please keep attention.
Be continued!
- MXNet:训练自己的数据并做预测
- Mxnet训练自己的数据集并测试
- Mxnet(3)-SSD训练自己的数据
- Mxnet(4)-fcn训练自己的数据
- mxnet 使用自己的图片数据训练CNN模型
- mxnet 运行自己的数据
- 使用lenet模型训练及预测自己的图片数据
- Caffe-用自己的数据做训练
- mxnet 训练--如何生成rec 数据 +自己在本机测试的结果
- mxnet实战笔记(1) - 使用自己的图片数据训练CNN模型
- mxnet使用预训练模型预测
- 将tensorflow训练好的模型部署成sercice服务,并做预测
- 【caffe】使用自己的图像数据训练lenet并用opencv进行预测
- 如何安装fast rcnn并训练自己的数据
- py-faster-rcnn+cpu配置并训练自己的数据
- caffe实战之训练并测试自己的数据
- 训练自己的数据
- 训练自己的数据
- Linux下安装xgBoost
- Sprin mvc 出现 No mapping found for HTTP request with URI,解决方案之一
- 100道前端面试题系列01
- BigDecimal 加减乘除
- Spring Boot 学习12--普通类调用Bean
- MXNet:训练自己的数据并做预测
- 《Mask R-CNN》-2017
- 了解 Spring Data JPA
- mac上安装redis
- 如何通俗的理解Gradle?
- 机器学习数学原理(3)——生成型学习算法
- SqlSession类的各种方法和作用
- Sublime Text3 工具运用
- 【STL】模拟实现list