diff --git a/.github/workflows/references.yml b/.github/workflows/references.yml index bee0804f16..860d8185f3 100644 --- a/.github/workflows/references.yml +++ b/.github/workflows/references.yml @@ -36,7 +36,7 @@ jobs: pip install -r references/requirements.txt sudo apt-get update && sudo apt-get install fonts-freefont-ttf -y - name: Train for a short epoch - run: python references/classification/train_pytorch_character.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1 + run: python references/classification/train_character.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1 train-orientation-classification: runs-on: ${{ matrix.os }} @@ -75,9 +75,9 @@ jobs: sudo apt-get update && sudo apt-get install unzip -y unzip toy_recogition_set-036a4d80.zip -d reco_set - name: Train for a short epoch (document orientation) - run: python references/classification/train_pytorch_orientation.py resnet18 --type page --train_path ./det_set --val_path ./det_set -b 2 --epochs 1 + run: python references/classification/train_orientation.py resnet18 --type page --train_path ./det_set --val_path ./det_set -b 2 --epochs 1 - name: Train for a short epoch (crop orientation) - run: python references/classification/train_pytorch_orientation.py resnet18 --type crop --train_path ./reco_set --val_path ./reco_set -b 4 --epochs 1 + run: python references/classification/train_orientation.py resnet18 --type crop --train_path ./reco_set --val_path ./reco_set -b 4 --epochs 1 train-text-recognition: runs-on: ${{ matrix.os }} @@ -111,7 +111,7 @@ jobs: sudo apt-get update && sudo apt-get install unzip -y unzip toy_recogition_set-036a4d80.zip -d reco_set - name: Train for a short epoch - run: python references/recognition/train_pytorch.py crnn_mobilenet_v3_small --train_path ./reco_set --val_path ./reco_set -b 4 --epochs 1 + run: python references/recognition/train.py crnn_mobilenet_v3_small --train_path ./reco_set --val_path ./reco_set -b 4 --epochs 1 evaluate-text-recognition: runs-on: ${{ matrix.os }} @@ -137,7 +137,7 @@ jobs: python -m pip install --upgrade pip pip install -e .[viz,html] --upgrade - name: Evaluate text recognition - run: python references/recognition/evaluate_pytorch.py crnn_mobilenet_v3_small --dataset SVT -b 32 + run: python references/recognition/evaluate.py crnn_mobilenet_v3_small --dataset SVT -b 32 latency-text-recognition: runs-on: ${{ matrix.os }} @@ -163,7 +163,7 @@ jobs: python -m pip install --upgrade pip pip install -e .[viz,html] --upgrade - name: Benchmark latency - run: python references/recognition/latency_pytorch.py crnn_mobilenet_v3_small --it 5 + run: python references/recognition/latency.py crnn_mobilenet_v3_small --it 5 train-text-detection: runs-on: ${{ matrix.os }} @@ -197,7 +197,7 @@ jobs: sudo apt-get update && sudo apt-get install unzip -y unzip toy_detection_set-bbbb4243.zip -d det_set - name: Train for a short epoch - run: python references/detection/train_pytorch.py db_mobilenet_v3_large --train_path ./det_set --val_path ./det_set -b 2 --epochs 1 + run: python references/detection/train.py db_mobilenet_v3_large --train_path ./det_set --val_path ./det_set -b 2 --epochs 1 evaluate-text-detection: runs-on: ${{ matrix.os }} @@ -224,7 +224,7 @@ jobs: pip install -e .[viz,html] --upgrade pip install -r references/requirements.txt - name: Evaluate text detection - run: python references/detection/evaluate_pytorch.py db_mobilenet_v3_large + run: python references/detection/evaluate.py db_mobilenet_v3_large latency-text-detection: runs-on: ${{ matrix.os }} @@ -250,4 +250,4 @@ jobs: python -m pip install --upgrade pip pip install -e .[viz,html] --upgrade - name: Benchmark latency - run: python references/detection/latency_pytorch.py db_mobilenet_v3_large --it 5 --size 512 + run: python references/detection/latency.py db_mobilenet_v3_large --it 5 --size 512 diff --git a/docs/source/using_doctr/sharing_models.rst b/docs/source/using_doctr/sharing_models.rst index 01697294e8..b2dcbfbc6f 100644 --- a/docs/source/using_doctr/sharing_models.rst +++ b/docs/source/using_doctr/sharing_models.rst @@ -48,7 +48,7 @@ It is also possible to push your model directly after training. .. code:: bash - python3 ~/doctr/references/recognition/train_pytorch.py crnn_mobilenet_v3_large --name doctr-crnn-mobilenet-v3-large --push-to-hub + python3 ~/doctr/references/recognition/train.py crnn_mobilenet_v3_large --name doctr-crnn-mobilenet-v3-large --push-to-hub Pretrained community models diff --git a/references/classification/README.md b/references/classification/README.md index 7fabbd7da4..6265ebbe81 100644 --- a/references/classification/README.md +++ b/references/classification/README.md @@ -16,7 +16,7 @@ pip install -r references/requirements.txt You can start your training in PyTorch: ```shell -python references/classification/train_pytorch_character.py mobilenet_v3_large --epochs 5 --device 0 +python references/classification/train_character.py mobilenet_v3_large --epochs 5 --device 0 ``` ## Usage orientation classification @@ -24,7 +24,7 @@ python references/classification/train_pytorch_character.py mobilenet_v3_large - You can start your training in PyTorch: ```shell -python references/classification/train_pytorch_orientation.py resnet18 --type page --train_path path/to/your/train_set --val_path path/to/your/val_set --epochs 5 +python references/classification/train_orientation.py resnet18 --type page --train_path path/to/your/train_set --val_path path/to/your/val_set --epochs 5 ``` The type can be either `page` for document images or `crop` for word crops. @@ -58,11 +58,11 @@ Feel free to inspect the multiple script option to customize your training to yo Character classification: ```shell -python references/classification/train_pytorch_character.py --help +python references/classification/train_character.py --help ``` Orientation classification: ```shell -python references/classification/train_pytorch_orientation.py --help +python references/classification/train_orientation.py --help ``` diff --git a/references/classification/latency_pytorch.py b/references/classification/latency.py similarity index 100% rename from references/classification/latency_pytorch.py rename to references/classification/latency.py diff --git a/references/classification/train_pytorch_character.py b/references/classification/train_character.py similarity index 100% rename from references/classification/train_pytorch_character.py rename to references/classification/train_character.py diff --git a/references/classification/train_pytorch_orientation.py b/references/classification/train_orientation.py similarity index 100% rename from references/classification/train_pytorch_orientation.py rename to references/classification/train_orientation.py diff --git a/references/detection/README.md b/references/detection/README.md index 6f007aa3c1..5ab9ce3a70 100644 --- a/references/detection/README.md +++ b/references/detection/README.md @@ -16,7 +16,7 @@ pip install -r references/requirements.txt You can start your training in PyTorch: ```shell -python references/detection/train_pytorch.py db_resnet50 --train_path path/to/your/train_set --val_path path/to/your/val_set --epochs 5 +python references/detection/train.py db_resnet50 --train_path path/to/your/train_set --val_path path/to/your/val_set --epochs 5 ``` ### Multi-GPU support @@ -41,7 +41,7 @@ By default all visible GPUs will be used. To limit which GPUs participate, set t ```shell CUDA_VISIBLE_DEVICES=0,2 \ -torchrun --nproc_per_node=2 references/detection/train_pytorch.py \ +torchrun --nproc_per_node=2 references/detection/train.py \ db_resnet50 \ --train_path path/to/train \ --val_path path/to/val \ @@ -124,5 +124,5 @@ You can follow this page on [how to create a Slack App](https://api.slack.com/qu Feel free to inspect the multiple script option to customize your training to your own needs! ```python -python references/detection/train_pytorch.py --help +python references/detection/train.py --help ``` diff --git a/references/detection/evaluate_pytorch.py b/references/detection/evaluate.py similarity index 100% rename from references/detection/evaluate_pytorch.py rename to references/detection/evaluate.py diff --git a/references/detection/latency_pytorch.py b/references/detection/latency.py similarity index 100% rename from references/detection/latency_pytorch.py rename to references/detection/latency.py diff --git a/references/detection/train_pytorch.py b/references/detection/train.py similarity index 100% rename from references/detection/train_pytorch.py rename to references/detection/train.py diff --git a/references/recognition/README.md b/references/recognition/README.md index 5a8afa6efd..6902ee5c27 100644 --- a/references/recognition/README.md +++ b/references/recognition/README.md @@ -16,7 +16,7 @@ pip install -r references/requirements.txt You can start your training in PyTorch: ```shell -python references/recognition/train_pytorch.py crnn_vgg16_bn --train_path path/to/your/train_set --val_path path/to/your/val_set --epochs 5 +python references/recognition/train.py crnn_vgg16_bn --train_path path/to/your/train_set --val_path path/to/your/val_set --epochs 5 ``` ### Multi-GPU support @@ -41,7 +41,7 @@ By default all visible GPUs will be used. To limit which GPUs participate, set t ```shell CUDA_VISIBLE_DEVICES=0,2 \ -torchrun --nproc_per_node=2 references/recognition/train_pytorch.py \ +torchrun --nproc_per_node=2 references/recognition/train.py \ crnn_vgg16_bn \ --train_path path/to/train \ --val_path path/to/val \ @@ -94,7 +94,7 @@ You can follow this page on [how to create a Slack App](https://api.slack.com/qu Feel free to inspect the multiple script option to customize your training to your own needs! ```shell -python references/recognition/train_pytorch.py --help +python references/recognition/train.py --help ``` ## Using custom fonts @@ -102,10 +102,10 @@ python references/recognition/train_pytorch.py --help If you want to use your own custom fonts for training, make sure the font is installed on your OS. Do so on linux by copying the .ttf file to the desired directory with: ```sudo cp custom-font.ttf /usr/local/share/fonts/``` and then running ```fc-cache -f -v``` to build the font cache. -Keep in mind that passing fonts to the training script will only work with the WordGenerator which will not augment or change images from the dataset if it is passed as argument. If no path to a dataset is passed like in this command ```python3 doctr/references/recognition/train_pytorch.py crnn_mobilenet_v3_small --vocab french --font "custom-font.ttf"``` only then is the WordGenerator "triggered" to create random images from the given vocab and font. +Keep in mind that passing fonts to the training script will only work with the WordGenerator which will not augment or change images from the dataset if it is passed as argument. If no path to a dataset is passed like in this command ```python3 doctr/references/recognition/train.py crnn_mobilenet_v3_small --vocab french --font "custom-font.ttf"``` only then is the WordGenerator "triggered" to create random images from the given vocab and font. Running the training script should look like this for multiple custom fonts: ```shell -python references/recognition/train_pytorch.py crnn_vgg16_bn --epochs 5 --font "custom-font-1.ttf,custom-font-2.ttf" +python references/recognition/train.py crnn_vgg16_bn --epochs 5 --font "custom-font-1.ttf,custom-font-2.ttf" ``` diff --git a/references/recognition/evaluate_pytorch.py b/references/recognition/evaluate.py similarity index 100% rename from references/recognition/evaluate_pytorch.py rename to references/recognition/evaluate.py diff --git a/references/recognition/latency_pytorch.py b/references/recognition/latency.py similarity index 100% rename from references/recognition/latency_pytorch.py rename to references/recognition/latency.py diff --git a/references/recognition/train_pytorch.py b/references/recognition/train.py similarity index 100% rename from references/recognition/train_pytorch.py rename to references/recognition/train.py