Skip to content

Feat/try-deployment #14638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3da4108
add files to ignore. Feat.
Svtter Oct 25, 2024
f8835d2
generate lock files. Chore.
Svtter Oct 28, 2024
4a189b0
Merge branch 'main' of github.com:PaddlePaddle/PaddleOCR
Svtter Oct 28, 2024
3cc26d7
add train script. Feat.
Svtter Oct 28, 2024
bfaf7c5
Rename Train Files. Feat.
Svtter Oct 28, 2024
4ddf7c6
using atrain_script. Chore.
Svtter Oct 28, 2024
314da23
add paddlepaddle 2.4.2 for compatible, Chore.
Svtter Oct 28, 2024
122cb60
udpate depends mirror. Chore.
Svtter Oct 28, 2024
b403e7b
add dockerfiles for env. Chore.
Svtter Oct 28, 2024
2ae0503
add dockerfile and compose file. Feat.
Svtter Nov 1, 2024
8951564
add python path and update ignore file. Chore.
Svtter Nov 1, 2024
36d6c36
update config dataset.
Svtter Nov 1, 2024
1bb1d7b
accept local changes.
Svtter Nov 1, 2024
649ef06
update setuptools and paddle version. Chore.
Svtter Nov 4, 2024
892793e
validation passwd with docker compose. Feat.
Svtter Nov 4, 2024
1209de6
add meter eval file. Feat.
Svtter Nov 4, 2024
251b65a
Feat, Done for eval-meter.
Svtter Nov 4, 2024
03a0746
enable training. Feat.
Svtter Nov 4, 2024
3a8b13c
add my customed config. Feat.
Svtter Nov 5, 2024
d91169c
update train-meter. save result to meter folder. Feat.
Svtter Nov 5, 2024
fe7628b
remove useless transforms. feat.
Svtter Nov 5, 2024
4c8b9da
update test name of file. Feat.
Svtter Nov 5, 2024
b7d8224
add v3 release. Feat
Svtter Nov 5, 2024
84b7e91
add eval v3. Feat.
Svtter Nov 5, 2024
559b82e
Merge branch 'main' of github.com:PaddlePaddle/PaddleOCR
Svtter Nov 5, 2024
7cc9be6
use p100
Svtter Nov 6, 2024
ad10e3d
add change log.
Svtter Feb 8, 2025
2391bf7
ref: using eval.py
Svtter Feb 8, 2025
530b3c9
merge eval meter to eval.py
Svtter Feb 8, 2025
6703ad6
add version support. merge them is useful to compare between differen…
Svtter Feb 8, 2025
1eeb9d7
move v2 code to eval.py
Svtter Feb 8, 2025
97e9bab
feat, add some examples for generated text.
Svtter Feb 8, 2025
a571248
add train notebook.
Svtter Feb 11, 2025
49fc81c
save result.
Svtter Feb 11, 2025
93f81a6
update training notebook.
Svtter Feb 12, 2025
dbd4eac
finish training.
Svtter Feb 14, 2025
2365ab8
add deployment try.
Svtter Feb 15, 2025
8fa99a7
2.4.2, for inference, notebook.
Svtter Feb 15, 2025
5fc98c0
inference worked.
Svtter Feb 15, 2025
6181c43
inference tools
Svtter Feb 15, 2025
0f18e12
add inference compose file.
Svtter Feb 15, 2025
c0ff257
finish paddleOCR inference.
Svtter Feb 15, 2025
9e24506
easy passwd.
Svtter Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,18 @@ paddleocr.egg-info/
/deploy/android_demo/app/cache/
test_tipc/web/models/
test_tipc/web/node_modules/


pretrain_models
train_data
debug
core
data
ckpt

ch_ppocr_mobile_v2.0_rec_infer
*.tar

*.tgz
resnet50
*.whl
1 change: 1 addition & 0 deletions .pdm-python
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/data2/xiuhao-new/work/meter-project/meterhub-pretrain/src/PaddleOCR/.venv/bin/python
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# FROM paddlecloud/paddleocr:2.6-gpu-cuda10.2-cudnn7-latest

# build from paddle
# FROM paddlepaddle/paddle:2.6.2-gpu-cuda12.0-cudnn8.9-trt8.6
FROM svtter/paddle:cuda11.2-paddle2.4.2

COPY requirements.txt .
RUN pip install jupyterlab && pip install -r requirements.txt

RUN jupyter lab --generate-config

RUN mkdir -p /root/.jupyter
EXPOSE 8888

WORKDIR /opt/PaddleOCR
CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--NotebookApp.token='abcd'"]
14 changes: 14 additions & 0 deletions Dockerfile.inference
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# FROM python:3.10-slim
# 先用一个大的,如果跑通,再用小的。
FROM registry.baidubce.com/paddlepaddle/paddle:2.6.2


# RUN python3 -m pip install paddlepaddle==2.4.2 -i https://pypi.tuna.tsinghua.edu.cn/simple && \
# python3 -m pip install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN pip install jupyterlab -i https://pypi.tuna.tsinghua.edu.cn/simple

WORKDIR /opt/PaddleOCR

CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root"]

1 change: 1 addition & 0 deletions atrain_script/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.tar
Empty file added atrain_script/CHANGELOG.md
Empty file.
9 changes: 9 additions & 0 deletions atrain_script/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Train PPOCR

My training script.

start with `./atrain_script/train.sh`.

## Why `atrain`?

Start with `a` could make the folder found fast.
213 changes: 213 additions & 0 deletions atrain_script/configs/ch_PP-OCRv3_rec_distillation-meter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
Global:
debug: false
use_gpu: true
epoch_num: 800
log_smooth_window: 20
print_batch_step: 10
save_model_dir: ./output/rec_ppocr_v3_distillation_meter
save_epoch_step: 3
eval_batch_step: 500
cal_metric_during_train: true
pretrained_model:
checkpoints:
save_inference_dir:
use_visualdl: false
infer_img: doc/imgs_words/ch/word_1.jpg
character_dict_path: atrain_script/meter_dict.txt
# character_dict_path: ./atrain_script/meter_dict.txt # seems not work.
max_text_length: &max_text_length 8
infer_mode: false
use_space_char: false
distributed: true
save_res_path: ./output/rec/predicts_ppocrv3_distillation_meter.txt
d2s_train_image_shape: [3, 32, 300]
use_wandb: True

wandb:
project: ProjectMeter # (optional) this is the wandb project name

Optimizer:
name: Adam
beta1: 0.9
beta2: 0.999
lr:
name: Piecewise
decay_epochs : [700]
values : [0.0005, 0.00005]
warmup_epoch: 5
regularizer:
name: L2
factor: 3.0e-05


Architecture:
model_type: &model_type "rec"
name: DistillationModel
algorithm: Distillation
Models:
Teacher:
pretrained:
freeze_params: false
return_all_feats: true
model_type: *model_type
algorithm: SVTR_LCNet
Transform:
Backbone:
name: MobileNetV1Enhance
scale: 0.5
last_conv_stride: [1, 2]
last_pool_type: avg
last_pool_kernel_size: [2, 2]
Head:
name: MultiHead
head_list:
- CTCHead:
Neck:
name: svtr
dims: 64
depth: 2
hidden_dims: 120
use_guide: True
Head:
fc_decay: 0.00001
- SARHead:
enc_dim: 512
max_text_length: *max_text_length
Student:
pretrained:
freeze_params: false
return_all_feats: true
model_type: *model_type
algorithm: SVTR_LCNet
Transform:
Backbone:
name: MobileNetV1Enhance
scale: 0.5
last_conv_stride: [1, 2]
last_pool_type: avg
last_pool_kernel_size: [2, 2]
Head:
name: MultiHead
head_list:
- CTCHead:
Neck:
name: svtr
dims: 64
depth: 2
hidden_dims: 120
use_guide: True
Head:
fc_decay: 0.00001
- SARHead:
enc_dim: 512
max_text_length: *max_text_length
Loss:
name: CombinedLoss
loss_config_list:
- DistillationDMLLoss:
weight: 1.0
act: "softmax"
use_log: true
model_name_pairs:
- ["Student", "Teacher"]
key: head_out
multi_head: True
dis_head: ctc
name: dml_ctc
- DistillationDMLLoss:
weight: 0.5
act: "softmax"
use_log: true
model_name_pairs:
- ["Student", "Teacher"]
key: head_out
multi_head: True
dis_head: sar
name: dml_sar
- DistillationDistanceLoss:
weight: 1.0
mode: "l2"
model_name_pairs:
- ["Student", "Teacher"]
key: backbone_out
- DistillationCTCLoss:
weight: 1.0
model_name_list: ["Student", "Teacher"]
key: head_out
multi_head: True
- DistillationSARLoss:
weight: 1.0
model_name_list: ["Student", "Teacher"]
key: head_out
multi_head: True

PostProcess:
name: DistillationCTCLabelDecode
model_name: ["Student", "Teacher"]
key: head_out
multi_head: True

Metric:
name: DistillationMetric
base_metric_name: RecMetric
main_indicator: acc
key: "Student"
ignore_space: False

Train:
dataset:
name: SimpleDataSet
data_dir: ./train_data/
ext_op_transform_idx: 1
label_file_list:
- ./train_data/train_list.txt
transforms:
- DecodeImage:
img_mode: BGR
channel_first: false
# - RecConAug:
# prob: 0.5
# ext_data_num: 2
# image_shape: [48, 320, 3]
# max_text_length: *max_text_length
- RecAug:
- MultiLabelEncode:
- RecResizeImg:
image_shape: [3, 32, 300]
- KeepKeys:
keep_keys:
- image
- label_ctc
- label_sar
- length
- valid_ratio
loader:
shuffle: true
batch_size_per_card: 128
drop_last: true
num_workers: 4
Eval:
dataset:
name: SimpleDataSet
data_dir: ./train_data
label_file_list:
- ./train_data/val_list.txt
transforms:
- DecodeImage:
img_mode: BGR
channel_first: false
- MultiLabelEncode:
- RecResizeImg:
image_shape: [3, 32, 300]
- KeepKeys:
keep_keys:
- image
- label_ctc
- label_sar
- length
- valid_ratio
loader:
shuffle: false
drop_last: false
batch_size_per_card: 128
num_workers: 4
Loading