A Telegram Bot is integrated with a convolutional neural network to classify images into one of the following categories:
Plane, Car, Bird, Cat, Deer, Dog, Frog, Horse, Ship and Truck
The bot was built using Python, Tensorflow and the Telegram Bot API.
- The bot connects to the Telegram server using the Bot API Token.
- This Token was generated by the BotFather (Telegram Chat).
- The token is stored in the token.txt for security reasons.
- Application.builder method allows the bot to communicate with the Telegram server.
-
Start function: Sends a welcome message to the user.
-
Train function: Trains the CNN model using the CIFAR-10 dataset in a seperate thread so the bot remains responsive.
-
Help function: Shows the commands that you can use.
-
Stop function: Stops the conversation with the Telegram bot.
-
Image Classification: Processed with OpenCV and predicted using the trained CNN model.
- A CNN is a type of deep learning model used for image and video recognition.
- It uses layers (convolutional, pooling) to extract and learn spatial features from the images.
The CNN in this project was built with the following architecture:
- Convolutional Layers: Extracts features from the input image.
- Pooling Layers: Downsamples the image and reduces complexity
- Dense Layers: Fully connected layers for classification.
- Model saved using .keras so it can be re-used.
- .keras is compatible with Tensorflow
- Performed well when classifying images of cars
- Struggled to classify images of dogs and planes
- The CNN model (trained on CIFAR-10) may have limitations due to a small dataset to work from.
-
Training the model with a larger and more diverse dataset.
-
Add commands for the user so they can see the training accuracy and loss.
-
Deploying the bot using a GPU for faster predictions
-
A GPU (Graphics Processing Unit) more suited than CPUs when it comes to rendering high-quality graphics
-
To do this I would need to use a cloud-platform which has GPU support such as AWS EC2 or Azure