Skip to content
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

add OCR Decoding support - WIP #39

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7c16e47
Resnet Variants (#9)
DrejcPesjak Feb 20, 2024
8e35f25
MLFlow Upload Fix (#10)
klemen1999 Feb 20, 2024
15bd923
CLI Source Option (#11)
kozlov721 Feb 21, 2024
2797278
Fix Removed Tensor Metadata (#12)
kozlov721 Feb 21, 2024
2c62a08
Forbid Extra Fields (#13)
kozlov721 Feb 22, 2024
0b51fa0
Automatic Inference of attach_index (#14)
kozlov721 Feb 24, 2024
bd67595
Backbone Fix (#15)
kozlov721 Feb 27, 2024
f42192c
Uploading logs to MLFlow (#16)
kozlov721 Feb 28, 2024
e1ab39b
Generate NN archive from training configs (#17)
jkbmrz Mar 20, 2024
b3b4e32
Extend NN Archive Generation Test Coverage (#18)
jkbmrz Mar 25, 2024
351e0c5
Upload All Checkpoints (#19)
kozlov721 Apr 11, 2024
9c4cadb
LuxonisML v0.1.0 (#20)
kozlov721 Apr 11, 2024
f425fdb
SIGTERM Handling (#21)
kozlov721 Apr 15, 2024
ca57063
Task Label Groups Support (#22)
kozlov721 Apr 24, 2024
d1d71f0
Tensor Core Float16 Precision (#24)
kozlov721 May 8, 2024
0830043
Metrics - Fixed Missing Reset (#25)
kozlov721 May 14, 2024
5a31f72
Deterministic Training Support (#23)
klemen1999 May 15, 2024
99b1857
Custom Loaders Support (#27)
kozlov721 May 21, 2024
b6b4688
enums handling (#31)
kozlov721 May 21, 2024
72afb72
GPUStatsMonitor (#29)
kozlov721 May 24, 2024
5893c3e
More Efficient Keypoint Export (#28)
JSabadin May 24, 2024
4110f78
Added active param to augmentations (#32)
klemen1999 May 24, 2024
36a92a6
Fix Archiver Pre-Processing (#34)
kozlov721 May 30, 2024
1d9998b
EfficientRep Variants (#33)
JSabadin May 31, 2024
c2e98b7
Support for LuxonisML - Annotation Refactor (#37)
kozlov721 Jun 6, 2024
abe7d3d
Changed Imports in Config (#38)
kozlov721 Jun 7, 2024
da0106e
adding OCR Decoding support
N950 Jun 10, 2024
b716f50
[Automated] Updated coverage badge
actions-user Jun 10, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ jobs:
run: pytest tests --cov=luxonis_train --cov-report xml --junit-xml pytest.xml

- name: Run tests [Windows, macOS]
env:
PYTORCH_MPS_HIGH_WATERMARK_RATIO: 0.0
if: matrix.os != 'ubuntu-latest' || matrix.version != '3.10'
run: pytest tests --junit-xml pytest.xml

Expand Down
36 changes: 19 additions & 17 deletions configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,25 @@ To store and load the data we use LuxonisDataset and LuxonisLoader. For specific

Here you can change everything related to actual training of the model.

| Key | Type | Default value | Description |
| ----------------------- | --------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| batch_size | int | 32 | batch size used for training |
| accumulate_grad_batches | int | 1 | number of batches for gradient accumulation |
| use_weighted_sampler | bool | False | bool if use WeightedRandomSampler for training, only works with classification tasks |
| epochs | int | 100 | number of training epochs |
| num_workers | int | 2 | number of workers for data loading |
| train_metrics_interval | int | -1 | frequency of computing metrics on train data, -1 if don't perform |
| validation_interval | int | 1 | frequency of computing metrics on validation data |
| num_log_images | int | 4 | maximum number of images to visualize and log |
| skip_last_batch | bool | True | whether to skip last batch while training |
| accelerator | Literal\["auto", "cpu", "gpu"\] | "auto" | What accelerator to use for training. |
| devices | int \| list\[int\] \| str | "auto" | Either specify how many devices to use (int), list specific devices, or use "auto" for automatic configuration based on the selected accelerator |
| strategy | Literal\["auto", "ddp"\] | "auto" | What strategy to use for training. |
| num_sanity_val_steps | int | 2 | Number of sanity validation steps performed before training. |
| profiler | Literal\["simple", "advanced"\] \| None | None | PL profiler for GPU/CPU/RAM utilization analysis |
| verbose | bool | True | Print all intermediate results to console. |
| Key | Type | Default value | Description |
| ----------------------- | ---------------------------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| seed | int | None | seed for reproducibility |
| batch_size | int | 32 | batch size used for training |
| accumulate_grad_batches | int | 1 | number of batches for gradient accumulation |
| use_weighted_sampler | bool | False | bool if use WeightedRandomSampler for training, only works with classification tasks |
| epochs | int | 100 | number of training epochs |
| num_workers | int | 2 | number of workers for data loading |
| train_metrics_interval | int | -1 | frequency of computing metrics on train data, -1 if don't perform |
| validation_interval | int | 1 | frequency of computing metrics on validation data |
| num_log_images | int | 4 | maximum number of images to visualize and log |
| skip_last_batch | bool | True | whether to skip last batch while training |
| accelerator | Literal\["auto", "cpu", "gpu"\] | "auto" | What accelerator to use for training. |
| devices | int \| list\[int\] \| str | "auto" | Either specify how many devices to use (int), list specific devices, or use "auto" for automatic configuration based on the selected accelerator |
| matmul_precision | Literal\["medium", "high", "highest"\] \| None | None | Sets the internal precision of float32 matrix multiplications. |
| strategy | Literal\["auto", "ddp"\] | "auto" | What strategy to use for training. |
| num_sanity_val_steps | int | 2 | Number of sanity validation steps performed before training. |
| profiler | Literal\["simple", "advanced"\] \| None | None | PL profiler for GPU/CPU/RAM utilization analysis |
| verbose | bool | True | Print all intermediate results to console. |

### Preprocessing

Expand Down
5 changes: 3 additions & 2 deletions configs/classification_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ model:
thickness: 2
include_plot: True

dataset:
name: cifar10_test
loader:
params:
dataset_name: cifar10_test

trainer:
preprocessing:
Expand Down
8 changes: 4 additions & 4 deletions configs/coco_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ tracker:
wandb_entity: luxonis
is_mlflow: False

dataset:
name: coco_test
loader:
train_view: train
val_view: val
test_view: test

params:
dataset_name: coco_test

trainer:
accelerator: auto
devices: auto
Expand All @@ -117,7 +119,6 @@ trainer:
validation_interval: 10
num_log_images: 8
skip_last_batch: True
main_head_index: 0
log_sub_losses: True
save_top_k: 3

Expand Down Expand Up @@ -154,7 +155,6 @@ trainer:
monitor: val/loss
mode: min
verbose: true
- name: DeviceStatsMonitor
- name: ExportOnTrainEnd
- name: TestOnTrainEnd

Expand Down
5 changes: 3 additions & 2 deletions configs/detection_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ model:
params:
use_neck: True

dataset:
name: coco_test
loader:
params:
dataset_name: coco_test

trainer:
preprocessing:
Expand Down
5 changes: 3 additions & 2 deletions configs/example_export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ model:
backbone: MicroNet
task: binary

dataset:
name: coco_test
loader:
params:
dataset_name: coco_test

trainer:
preprocessing:
Expand Down
5 changes: 3 additions & 2 deletions configs/example_tuning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ model:
backbone: MicroNet
task: binary

dataset:
name: coco_test
loader:
params:
dataset_name: coco_test

trainer:
preprocessing:
Expand Down
5 changes: 3 additions & 2 deletions configs/keypoint_bbox_model.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ model:
predefined_model:
name: KeypointDetectionModel

dataset:
name: coco_test
loader:
params:
dataset_name: coco_test

trainer:
preprocessing:
Expand Down
132 changes: 132 additions & 0 deletions configs/ocr_decoding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# An example configuration for OCR Decoding network.


model:
name: ocr_decoding_test
nodes:
- name: OCRDecoderBackbone
params:
task: "text"
num_characters: 37
in_channels: 3
dropout_rate: 0.1

- name: OCRDecoderHead
inputs:
- OCRDecoderBackbone
params:
task: "text"
num_characters: 37



losses:
- name: FocalCTC
attached_to: OCRDecoderHead
params:
blank: 0

metrics:
- name: OCRAccuracy
is_main_metric: true
attached_to: OCRDecoderHead

# visualizers:
# - name: MultiVisualizer
# attached_to: ImplicitKeypointBBoxHead
# params:
# visualizers:
# - name: KeypointVisualizer
# params:
# nonvisible_color: blue
# - name: BBoxVisualizer
# params:
# colors:
# person: "#FF5055"
# - name: SegmentationVisualizer
# attached_to: SegmentationHead
# params:
# colors: "#FF5055"
# - name: BBoxVisualizer
# attached_to: EfficientBBoxHead

tracker:
project_name: ocr_example
save_directory: ocr_output
is_tensorboard: True
is_wandb: False
wandb_entity: luxonis
is_mlflow: False

loader:
train_view: train
val_view: val
test_view: test

params:
dataset_name: dataset_dev_0

trainer:
accelerator: auto
devices: auto
strategy: auto

num_sanity_val_steps: 1
profiler: null
verbose: True
batch_size: 2
accumulate_grad_batches: 1
epochs: &epochs 200
num_workers: 2
train_metrics_interval: -1
validation_interval: 1
num_log_images: 1
skip_last_batch: False
log_sub_losses: True
save_top_k: 3

preprocessing:
train_image_size: [&height 160, &width 320]
keep_aspect_ratio: False
train_rgb: True
normalize:
active: True
augmentations:
- name: OCRAugmentation
params:
image_size: [160, 320]
is_rgb: True
is_train: True

callbacks:
- name: LearningRateMonitor
params:
logging_interval: step
- name: MetadataLogger
params:
hyperparams: ["trainer.epochs", trainer.batch_size]
- name: TestOnTrainEnd

optimizer:
name: SGD
params:
lr: 0.0001
momentum: 0.937
nesterov: True
weight_decay: 0.0005

scheduler:
name: CosineAnnealingLR
params:
T_max: *epochs
eta_min: 0

exporter:
onnx:
opset_version: 11

tuner:
params:
trainer.optimizer.name_categorical: ["Adam", "SGD"]
trainer.optimizer.params.lr_float: [0.0001, 0.001]
trainer.batch_size_int: [4, 16, 4]
59 changes: 59 additions & 0 deletions configs/resnet_model.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@

model:
name: resnet50_classification
nodes:
- name: ResNet
params:
variant: "50"
download_weights: True

- name: ClassificationHead
inputs:
- ResNet

losses:
- name: CrossEntropyLoss
attached_to: ClassificationHead

metrics:
- name: Accuracy
is_main_metric: true
attached_to: ClassificationHead

visualizers:
- name: ClassificationVisualizer
attached_to: ClassificationHead
params:
font_scale: 0.5
color: [255, 0, 0]
thickness: 2
include_plot: True

loader:
params:
dataset_name: cifar10_test

trainer:
batch_size: 4
epochs: &epochs 200
num_workers: 4
validation_interval: 10
num_log_images: 8

preprocessing:
train_image_size: [&height 224, &width 224]
keep_aspect_ratio: False
normalize:
active: True

callbacks:
- name: ExportOnTrainEnd
- name: TestOnTrainEnd

optimizer:
name: SGD
params:
lr: 0.02

scheduler:
name: ConstantLR
Loading