Skip to content

Commit

Permalink
[Misc] rename char classifiation scripts and dependency pin (#1469)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 authored Feb 14, 2024
1 parent 4ff5ce2 commit 2daf0d9
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ requirements:
- shapely >=1.6.0, <3.0.0
- langdetect >=1.0.9, <2.0.0
- rapidfuzz >=3.0.0, <4.0.0
- huggingface_hub >=0.20.0, <1.0.0
- matplotlib >=3.1.0
- weasyprint >=55.0
- defusedxml >=0.7.0
- mplcursors >=0.3
- unidecode >=1.0.0
- tqdm >=4.30.0
- huggingface_hub >=0.20.0

about:
home: {{ urls.get('repository') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/references.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ jobs:
sudo apt-get update && sudo apt-get install fonts-freefont-ttf -y
- if: matrix.framework == 'tensorflow'
name: Train for a short epoch (TF)
run: python references/classification/train_tensorflow.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1
run: python references/classification/train_tensorflow_character.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1
- if: matrix.framework == 'pytorch'
name: Train for a short epoch (PT)
run: python references/classification/train_pytorch.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1
run: python references/classification/train_pytorch_character.py vit_s -b 32 --val-samples 1 --train-samples 1 --epochs 1

train-orientation-classification:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "Apache-2.0"

[tool.poetry.dependencies]
python = ">=3.8.2,<3.11" # pypdfium2 needs a python version above 3.8.2
tensorflow = ">=2.11.0,<3.0.0"
tensorflow = ">=2.11.0,<2.16.0" # cf. https://github.com/mindee/doctr/pull/1461
python-doctr = {git = "https://github.com/mindee/doctr.git", extras = ['tf'], branch = "main" }
# Fastapi: minimum version required to avoid pydantic error
# cf. https://github.com/tiangolo/fastapi/issues/4168
Expand Down
38 changes: 17 additions & 21 deletions doctr/models/detection/differentiable_binarization/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,24 @@ def __init__(

conv_layer = DeformConv2d if deform_conv else nn.Conv2d

self.in_branches = nn.ModuleList(
[
nn.Sequential(
conv_layer(chans, out_channels, 1, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU(inplace=True),
)
for idx, chans in enumerate(in_channels)
]
)
self.in_branches = nn.ModuleList([
nn.Sequential(
conv_layer(chans, out_channels, 1, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU(inplace=True),
)
for idx, chans in enumerate(in_channels)
])
self.upsample = nn.Upsample(scale_factor=2, mode="bilinear", align_corners=True)
self.out_branches = nn.ModuleList(
[
nn.Sequential(
conv_layer(out_channels, out_chans, 3, padding=1, bias=False),
nn.BatchNorm2d(out_chans),
nn.ReLU(inplace=True),
nn.Upsample(scale_factor=2**idx, mode="bilinear", align_corners=True),
)
for idx, chans in enumerate(in_channels)
]
)
self.out_branches = nn.ModuleList([
nn.Sequential(
conv_layer(out_channels, out_chans, 3, padding=1, bias=False),
nn.BatchNorm2d(out_chans),
nn.ReLU(inplace=True),
nn.Upsample(scale_factor=2**idx, mode="bilinear", align_corners=True),
)
for idx, chans in enumerate(in_channels)
])

def forward(self, x: List[torch.Tensor]) -> torch.Tensor:
if len(x) != len(self.out_branches):
Expand Down
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,21 @@ dependencies = [
"shapely>=1.6.0,<3.0.0",
"langdetect>=1.0.9,<2.0.0",
"rapidfuzz>=3.0.0,<4.0.0",
"huggingface-hub>=0.20.0,<1.0.0",
"matplotlib>=3.1.0",
"weasyprint>=55.0",
"Pillow>=9.2.0",
"defusedxml>=0.7.0",
"mplcursors>=0.3",
"unidecode>=1.0.0",
"tqdm>=4.30.0",
"huggingface-hub>=0.20.0",
]

[project.optional-dependencies]
tf = [
"tensorflow>=2.11.0,<3.0.0", # cf. https://github.com/mindee/doctr/pull/1182
# cf. https://github.com/mindee/doctr/pull/1182
# cf. https://github.com/mindee/doctr/pull/1461
"tensorflow>=2.11.0,<2.16.0",
"tf2onnx>=1.16.0,<2.0.0", # cf. https://github.com/onnx/tensorflow-onnx/releases/tag/v1.16.0
]
torch = [
Expand Down Expand Up @@ -89,7 +91,9 @@ docs = [
]
dev = [
# Tensorflow
"tensorflow>=2.11.0,<3.0.0", # cf. https://github.com/mindee/doctr/pull/1182
# cf. https://github.com/mindee/doctr/pull/1182
# cf. https://github.com/mindee/doctr/pull/1461
"tensorflow>=2.11.0,<2.16.0",
"tf2onnx>=1.16.0,<2.0.0", # cf. https://github.com/onnx/tensorflow-onnx/releases/tag/v1.16.0
# PyTorch
"torch>=1.12.0,<3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions references/classification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pip install -r references/requirements.txt
You can start your training in TensorFlow:

```shell
python references/classification/train_tensorflow.py mobilenet_v3_large --epochs 5
python references/classification/train_tensorflow_character.py mobilenet_v3_large --epochs 5
```

or PyTorch:

```shell
python references/classification/train_pytorch.py mobilenet_v3_large --epochs 5 --device 0
python references/classification/train_pytorch_character.py mobilenet_v3_large --epochs 5 --device 0
```

## Usage orientation classification
Expand Down Expand Up @@ -61,7 +61,7 @@ Feel free to inspect the multiple script option to customize your training to yo
Character classification:

```python
python references/classification/train_tensorflow.py --help
python references/classification/train_tensorflow_character.py --help
```

Orientation classification:
Expand Down
31 changes: 0 additions & 31 deletions references/classification/latency.csv

This file was deleted.

File renamed without changes.
15 changes: 0 additions & 15 deletions references/detection/latency.csv

This file was deleted.

9 changes: 0 additions & 9 deletions references/detection/results.csv

This file was deleted.

3 changes: 0 additions & 3 deletions references/obj_detection/latency.csv

This file was deleted.

21 changes: 0 additions & 21 deletions references/recognition/latency.csv

This file was deleted.

0 comments on commit 2daf0d9

Please sign in to comment.