Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
|
4 years ago | |
|---|---|---|
| .. | ||
| scripts | 4 years ago | |
| src | 4 years ago | |
| README.md | 4 years ago | |
| eval.py | 4 years ago | |
| requirements.txt | 5 years ago | |
| train.py | 4 years ago | |
CNN Direction Model is a model designed to perform binary classification of text images on whether the text in the image is going from left-to-right or right-to-left.
CNN Direction Model's composition consists of 1 convolutional layer and 4 residual blocks for feature extraction. The feature extraction stage is then followed by 3 dense layers to perform the classification.
Dataset used: FSNS (French Street Name Signs)
Dataset size:~200GB,~1M 150*600 colored images with a label indicating the text within the image.
Data format:binary files
Download the dataset, the recommended directory structure to have is as follows:
Annotations for training and testing should be in test_annot and train_annot.
Training and Testing images should be in train and test.
├─test
│
└─test_annot
│
└─train
│
└─train_annot
python create_mindrecord.py
This will create two folders: train and test in the target directory you specify in config.py.
After installing MindSpore via the official website, you can start training and evaluation as follows:
# enter script dir, train CNNDirectionModel
sh run_standalone_train.sh [DATASET_PATH] [PRETRAINED_CKPT_PATH](optional)
# enter script dir, evaluate CNNDirectionModel
sh run_standalone_train.sh [DATASET_PATH] [PRETRAINED_CKPT_PATH]
├── cv
├── cnn_direction_model
├── README.md // descriptions about cnn_direction_model
├── requirements.txt // packages needed
├── scripts
│ ├──run_distribute_train_ascend.sh // distributed training in ascend
│ ├──run_standalone_eval_ascend.sh // evaluate in ascend
│ ├──run_standalone_train_ascend.sh // train standalone in ascend
├── src
│ ├──dataset.py // creating dataset
│ ├──cnn_direction_model.py // cnn_direction_model architecture
│ ├──config.py // parameter configuration
│ ├──create_mindrecord.py // convert raw data to mindrecords
├── train.py // training script
├── eval.py // evaluation script
Major parameters in config.py as follows:
--data_root_train: The path to the raw training data images for conversion to mindrecord script.
--data_root_test: The path to the raw test data images for conversion to mindrecord script.
--test_annotation_file: The path to the raw training annotation file.
--train_annotation_file: The path to the raw test annotation file.
--mindrecord_dir: The path to which create_mindrecord.py uses to save the resulting mindrecords for training and testing.
--epoch_size: Total training epochs.
--batch_size: Training batch size.
--im_size_h: Image height used as input to the model.
--im_size_w: Image width used as input the model.
running on Ascend
sh run_standalone_train_ascend.sh path-to-train-mindrecords pre-trained-chkpt(optional)
The model checkpoint will be saved script/train.
Before running the command below, please check the checkpoint path used for evaluation.
running on Ascend
sh run_standalone_eval_ascend.sh path-to-test-mindrecords trained-chkpt-path
Results of evaluation will be printed after evaluation process is completed.
| Parameters | Ascend |
|---|---|
| Resource | Ascend 910; CPU 2.60GHz, 192cores; Memory 755G; OS Euler2.8 |
| uploaded Date | 01/15/2021 (month/day/year) |
| MindSpore Version | 1.1 |
| Dataset | FSNS |
| Training Parameters | epoch=1, steps=104,477, batch_size = 20, lr=1e-07 |
| Optimizer | Adam |
| Loss Function | Softmax Cross Entropy |
| outputs | top 1 accuracy |
| Overall accuracy | 91.72% |
| Speed | 583 ms/step |
| Total time | 17 hours |
In train.py, we set some seeds before training.
Please check the official homepage.
MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios.
C++ Python Text Unity3D Asset C other