Setup slackker with Telegram to monitor Keras model training

Siddhesh Gunjal
3 min readJul 7, 2023

--

slackker with telegram integration

Training our DL model is a time consuming process and watching it train is a time killer and it is addictive. We always find ourselves walking back and forth to computer screen to check the progress to only find that the current epoch is not finished.

All the time models are training, our brain usually works at 50% at most. To help you with this, I have introduced slackker.

slackker is a python package for monitoring your training in real-time on slack and telegram. It can send you update for your ML model training progress and send final report with graphs when the training finishes. So now you don’t have to sit in front of the machine all the time. You can quickly go and grab coffee ☕️ downstairs or run some errands and still keep tracking the progress while on the move.

In this article we are gonna go through detailed explaination on how to setup telegram with slackker to monitoring your ML training.

1. Create A Telegram Bot Using Telegram’s BotFather

  1. Open your telegram app and search for BotFather. (A built-in Telegram bot that helps users create custom Telegram bots)
  2. Type /newbot to create a new bot
  3. Give your bot a name & a username
  4. Copy your new Telegram bot’s token
Get token for your telegram bot

It should be in the follwoing format:

1234567890:AAAAA_A111BBBBBCCC2DD3eEe44f5GGGgGG

2. Initiate chat with your newly created bot

Let’s send a any random message to our telegram bot (Hello!) so that slackker can automatically discover our chat.

Now we’re ready to use slackker with telegram. Let’s head back to our code and setup slackker with keras.

3. Create slackker object to use in callbacks

Install slackker in your working environment

pip install slackker

Now let’s import keras callback module from slackker:

from slackker.callbacks.keras import TelegramUpdate

Let’s create slackker object with TelegramUpdate

Telegram_update = TelegramUpdate(token="1234567890:AAAAA_A111BBBBBCCC2DD3eEe44f5GGGgGG",
ModelName='Simple_NN',
export='png',
SendPlot=True)

TelegramUpdate takes following arguments:

  • token: (string) Telegram bot token
  • ModelName: (string) Name for your model. This same name will be used in future for title of the generated plots.
  • export: (string) default "png": Format for plots to be exported. (supported formats: eps, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff)
  • SendPlots: (Bool) default True: If set to True it will export history of model, both training and validation, save it in the format given in export argument and send graphs to slack channel when training ends. If set to False it will not send exported graphs to slack channel.
  • verbose: (int) default 0: You can sent the verbose level up to 2.

4. Call slackker object into keras callbacks during model fit

history = model.fit(x_train, 
y_train,
epochs = 3,
batch_size = 16,
verbose=1,
validation_data=(x_val,y_val),
callbacks=[checkpoints, telegram_update])
Report messages on telegram from slackker callbacks

Hope this helped 🌟

Have anything in mind that can help become slackker better? or require any feature? Do visit the GitHub Repo for more details about contribution to the source code.

Additional links:

Future plans for slackker

  • ̶S̶u̶p̶p̶o̶r̶t̶ ̶f̶o̶r̶ ̶P̶y̶T̶o̶r̶c̶h̶-̶L̶i̶g̶h̶t̶n̶i̶n̶g̶
  • Support for Discord
  • Support for transformers
  • Support for MLOps workflows

Would love to know your experience with slackker. Follow me & star the repo to get updates about the future releases of slackker.

--

--

Siddhesh Gunjal

ML Engineer | Creator of Slackker (PyPi pakage) | Former Adjunct Faculty @upGrad | Former Professor @BSE (Bombay stock exchange)