Commit
·
1d47d08
1
Parent(s):
11d47e4
Add instruction to convert model to ONNX
Browse files
README.md
CHANGED
|
@@ -38,6 +38,18 @@ If you are running the whole procedure again, remember to reinstall the older tr
|
|
| 38 |
python train.py --cust_data_init_weights_path ./cust-data/weights --checkpoint_path ./checkpoint/trocr-custdata --dataset_path "./dataset/*/*.jpg" --per_device_train_batch_size 8
|
| 39 |
```
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
## 训练
|
| 42 |
### 初始化模型到自定义训练数据集
|
| 43 |
#### 字符集准备参考cust-data/vocab.txt
|
|
|
|
| 38 |
python train.py --cust_data_init_weights_path ./cust-data/weights --checkpoint_path ./checkpoint/trocr-custdata --dataset_path "./dataset/*/*.jpg" --per_device_train_batch_size 8
|
| 39 |
```
|
| 40 |
|
| 41 |
+
## Optimize inference
|
| 42 |
+
Install dependencies
|
| 43 |
+
```
|
| 44 |
+
python -m pip install optimum
|
| 45 |
+
conda install onnxruntime -c conda-forge
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
Convert to ONNX
|
| 49 |
+
```
|
| 50 |
+
python -m transformers.onnx --model=checkpoint/trocr-custdata-8000/last --feature=vision2seq-lm onnx/ --atol 1e-3
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
## 训练
|
| 54 |
### 初始化模型到自定义训练数据集
|
| 55 |
#### 字符集准备参考cust-data/vocab.txt
|
checkpoint/trocr-custdata-8000/last/preprocessor_config.json
CHANGED
|
@@ -8,6 +8,7 @@
|
|
| 8 |
0.5
|
| 9 |
],
|
| 10 |
"image_processor_type": "ViTImageProcessor",
|
|
|
|
| 11 |
"image_std": [
|
| 12 |
0.5,
|
| 13 |
0.5,
|
|
|
|
| 8 |
0.5
|
| 9 |
],
|
| 10 |
"image_processor_type": "ViTImageProcessor",
|
| 11 |
+
"feature_extractor_type": "ViTFeatureExtractor",
|
| 12 |
"image_std": [
|
| 13 |
0.5,
|
| 14 |
0.5,
|