Skip to content

Commit

Permalink
feat: ✨ tqdm slack (#1837)
Browse files Browse the repository at this point in the history
* feat: ✨ tqdm slack

* fix

* docs: ✏️ update README.md
  • Loading branch information
odulcy-mindee authored Jan 14, 2025
1 parent a3d2683 commit b0d2728
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 12 deletions.
10 changes: 10 additions & 0 deletions references/classification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ Each path must lead to a folder where the images are stored. For example:
└── ...
```

## Slack Logging with tqdm

To enable Slack logging using `tqdm`, you need to set the following environment variables:

- `TQDM_SLACK_TOKEN`: the Slack Bot Token
- `TQDM_SLACK_CHANNEL`: you can retrieve it using `Right Click on Channel > Copy > Copy link`. You should get something like `https://xxxxxx.slack.com/archives/yyyyyyyy`. Keep only the `yyyyyyyy` part.

You can follow this page on [how to create a Slack App](https://api.slack.com/quickstart).


## Advanced options

Feel free to inspect the multiple script option to customize your training to your own needs!
Expand Down
6 changes: 5 additions & 1 deletion references/classification/train_pytorch_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
RandomPhotometricDistort,
RandomRotation,
)
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr import transforms as T
from doctr.datasets import VOCABS, CharacterGenerator
Expand Down
6 changes: 5 additions & 1 deletion references/classification/train_pytorch_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@
RandomPerspective,
RandomPhotometricDistort,
)
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr import transforms as T
from doctr.datasets import OrientationDataset
Expand Down
6 changes: 5 additions & 1 deletion references/classification/train_tensorflow_character.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
import numpy as np
import tensorflow as tf
from tensorflow.keras import Model, mixed_precision, optimizers
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr.models import login_to_hub, push_to_hf_hub

Expand Down
6 changes: 5 additions & 1 deletion references/classification/train_tensorflow_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
import numpy as np
import tensorflow as tf
from tensorflow.keras import Model, mixed_precision, optimizers
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr.models import login_to_hub, push_to_hf_hub

Expand Down
9 changes: 9 additions & 0 deletions references/detection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ labels.json
}
```

## Slack Logging with tqdm

To enable Slack logging using `tqdm`, you need to set the following environment variables:

- `TQDM_SLACK_TOKEN`: the Slack Bot Token
- `TQDM_SLACK_CHANNEL`: you can retrieve it using `Right Click on Channel > Copy > Copy link`. You should get something like `https://xxxxxx.slack.com/archives/yyyyyyyy`. Keep only the `yyyyyyyy` part.

You can follow this page on [how to create a Slack App](https://api.slack.com/quickstart).

## Advanced options

Feel free to inspect the multiple script option to customize your training to your own needs!
Expand Down
6 changes: 5 additions & 1 deletion references/detection/evaluate_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
import torch
from torch.utils.data import DataLoader, SequentialSampler
from torchvision.transforms import Normalize
from tqdm import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr import datasets
from doctr import transforms as T
Expand Down
6 changes: 5 additions & 1 deletion references/detection/evaluate_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

import tensorflow as tf
from tensorflow.keras import mixed_precision
from tqdm import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

gpu_devices = tf.config.list_physical_devices("GPU")
if any(gpu_devices):
Expand Down
6 changes: 5 additions & 1 deletion references/detection/train_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
from torch.optim.lr_scheduler import CosineAnnealingLR, MultiplicativeLR, OneCycleLR, PolynomialLR
from torch.utils.data import DataLoader, RandomSampler, SequentialSampler
from torchvision.transforms.v2 import Compose, Normalize, RandomGrayscale, RandomPhotometricDistort
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr import transforms as T
from doctr.datasets import DetectionDataset
Expand Down
6 changes: 5 additions & 1 deletion references/detection/train_pytorch_ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
from torch.utils.data import DataLoader, SequentialSampler
from torch.utils.data.distributed import DistributedSampler
from torchvision.transforms.v2 import Compose, Normalize, RandomGrayscale, RandomPhotometricDistort
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr import transforms as T
from doctr.datasets import DetectionDataset
Expand Down
6 changes: 5 additions & 1 deletion references/detection/train_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
import numpy as np
import tensorflow as tf
from tensorflow.keras import Model, mixed_precision, optimizers
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr.models import login_to_hub, push_to_hf_hub

Expand Down
10 changes: 10 additions & 0 deletions references/recognition/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ The order of entries in the json does not matter.

When typing your labels, be aware that the VOCAB doesn't handle spaces. Also make sure your `labels.json` file is using UTF-8 encoding.

## Slack Logging with tqdm

To enable Slack logging using `tqdm`, you need to set the following environment variables:

- `TQDM_SLACK_TOKEN`: the Slack Bot Token
- `TQDM_SLACK_CHANNEL`: you can retrieve it using `Right Click on Channel > Copy > Copy link`. You should get something like `https://xxxxxx.slack.com/archives/yyyyyyyy`. Keep only the `yyyyyyyy` part.

You can follow this page on [how to create a Slack App](https://api.slack.com/quickstart).


## Advanced options

Feel free to inspect the multiple script option to customize your training to your own needs!
Expand Down
6 changes: 5 additions & 1 deletion references/recognition/train_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
RandomPerspective,
RandomPhotometricDistort,
)
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr import transforms as T
from doctr.datasets import VOCABS, RecognitionDataset, WordGenerator
Expand Down
6 changes: 5 additions & 1 deletion references/recognition/train_pytorch_ddp.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
RandomPerspective,
RandomPhotometricDistort,
)
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr import transforms as T
from doctr.datasets import VOCABS, RecognitionDataset, WordGenerator
Expand Down
6 changes: 5 additions & 1 deletion references/recognition/train_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
import numpy as np
import tensorflow as tf
from tensorflow.keras import Model, mixed_precision, optimizers
from tqdm.auto import tqdm

if os.getenv("TQDM_SLACK_TOKEN") and os.getenv("TQDM_SLACK_CHANNEL"):
from tqdm.contrib.slack import tqdm
else:
from tqdm.auto import tqdm

from doctr.models import login_to_hub, push_to_hf_hub

Expand Down
1 change: 1 addition & 0 deletions references/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-e .
tqdm
slack-sdk
wandb>=0.10.31
clearml>=1.11.1
matplotlib>=3.1.0

0 comments on commit b0d2728

Please sign in to comment.