Go to file
wanghz 2c8db47408 Modify to adapt to the new version nncase and SDK 2019-11-25 16:22:01 +08:00
K210code Modify to adapt to the new version nncase and SDK 2019-11-25 16:22:01 +08:00
mobilenetv1 init project 2019-01-21 19:18:34 +08:00
pretrained init project 2019-01-21 19:18:34 +08:00
.gitignore init project 2019-01-21 19:18:34 +08:00
README.md add english readme 2019-01-22 00:04:34 +08:00

README.md

Tensorflow Workspace for K210

Classifier for ImageNet

  1. Download ImageNet dataset, extract it as the instructions to ILSVRC2012_img_train, it has 1000 folders, each folder's name represents its class id.
  2. The model definition file is mobilenetv1/models/mobilenet_v1.py, ATTENTION, K210 does not support the method of SAME PADDING in tensorflow, so we need to add padding around the image manually before a stride=2 conv (in this situation, the padding method of conv layer with stride=2 should be set to VALID
  3. Modify mobilenetv1/run_mobilenet_v1.sh and start your training.
  4. Using freeze_graph.py to freeze your model from ckpt to pb, just run python mobilenetv1/freeze_graph.py model.mobilenet_v1 ckpt_fold pb_file
  5. Test on ImageNet, you need a val dataset of ImageNet, then run python mobilenetv1/validation_imagenet.py pb_file val_set_fold
  6. Estimate one image, run python mobilenetv1/predict_one_pic.py pb_file pic

ImageNet 分类器示例

  1. 下载ImageNet数据集按照说明解压缩训练数据集到文件夹ILSVRC2012_img_train内含1000个子文件夹每个子文件夹的命名为其分类代号类似n02484975每个子文件夹内为该分类的训练数据
  2. mobilenet v1定义文件mobilenetv1/models/mobilenet_v1.py需要注意由于K210不支持tensorflow的SAME padding所以在stride=2时先固定padding一圈0然后再进行stride=2的卷积padding=VALID
  3. 训练脚本 mobilenetv1/run_mobilenet_v1.sh根据需要修改其中的参数然后运行
  4. freeze_graph.py将训练ckpt转成pb文件命令格式如下
    python mobilenetv1/freeze_graph.py model.mobilenet_v1 ckpt_fold pb_file
  5. 测试在ImageNet验证集上的性能下载验证集将文件按类别解压好与训练集类似运行 python mobilenetv1/validation_imagenet.py pb_fileor ckpt folder val_set_fold
  6. 预测单张图片python mobilenetv1/predict_one_pic.py pb_fileor ckpt folder pic