https://github.com/jovianhq/fastai_slack
Get Slack notifications while training FastAI models
https://github.com/jovianhq/fastai_slack
deep-learning developer-tools fastai
Last synced: 10 days ago
JSON representation
Get Slack notifications while training FastAI models
- Host: GitHub
- URL: https://github.com/jovianhq/fastai_slack
- Owner: JovianHQ
- License: mit
- Created: 2019-04-01T12:35:40.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-20T06:02:04.000Z (almost 6 years ago)
- Last Synced: 2025-03-16T01:23:55.888Z (about 2 months ago)
- Topics: deep-learning, developer-tools, fastai
- Language: Python
- Homepage:
- Size: 12.7 KB
- Stars: 13
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Slack Notifications for FastAI
Get slack notifications for [FastAI](https://github.com/fastai/fastai) model training.
Demo: https://jvn.io/aakashns/2e505d1a5e7b49e18e7849da3280b9da
`fastai_slack` provides a simple callback to receive Slack notifcations while training FastAI models, with just one extra line of code.

`fastai_slack` sends notifications to your chosen Slack workspace & channel for the following events:
* Start of training
* Losses and metrics at the end of every epoch (or every few epochs)
* End of training
* Exceptions that occur during training (with stack trace)## Installation and Usage
See this Jupyter notebook for a detailed setup and usage example: https://jvn.io/aakashns/2e505d1a5e7b49e18e7849da3280b9da
1. Install the `fastai_slack` library using pip:
```
pip install fastai_slack
```2. Generate a [Slack incoming webhook URL](https://api.slack.com/incoming-webhooks), which will allow you to send notifications to a Slack channel of your choice. More details here: https://api.slack.com/incoming-webhooks
The webhook URL should be kept secret, so `fastai_slack` provides a helpful `read_webhook_url` method to safely input webhook URL within Jupyter.
```python
from fastai_slack import read_webhook_url
webhook_url = read_webhook_url()
```3. While calling the `fit` method to train the model, passing in a `SlackCallback` configured with:
`name`: project/job name which will be included in every notification
`webhook_url`: The Slack incoming webhook URL (read from user input earlier)
`frequency`: How often to send a notification (defaults to 1 i.e. every epoch)Here's a complete example:
```
from fastai.vision import *
from fastai_slack import SlackCallback# Create a learner
data = ImageDataBunch.from_folder(untar_data(URLs.MNIST),train='training', valid='testing')
learn = cnn_learner(data, models.resnet18, metrics=accuracy)# Create a callback
slack_cb = SlackCallback('mnist', webhook_url, frequency=2)# fit with callback
learn.fit(8, callbacks=[slack_cb])
```Here's what the notifications look like:

## Configuration
Instead of passing the webhook URL manually each time, you can also set a system wide environment variable with the name `FASTAI_SLACK_WEBHOOK` contaning the URL, and it will be read automatically by `SlackCallback`. For instance, on Mac/Linux, you might need to add the following like to your `~/.bashrc`:
```
FASTAI_SLACK_WEBHOOK=https://hooks.slack.com/services/T00000/B0000/XXXXXXXXXXX
# Replace the URL above with your Slack incoming webhook URL
```## Contributing
fastai_slack is open source, and you can view the source code here: https://github.com/jvn-io/fastai_slackPlease use Github to report bugs, request/propose feature. Pull requests with bug fixes and PRs are most welcome!