Leveraging YOLOv5, Flask, Telegram API, and Ngrok, this project delivers a Dockerized solution for image object detection via a user-friendly chat-based interface. The Object Detection Telegram Bot utilizes the Telegram Bot API to seamlessly receive user images and provide swift responses with detected objects.
- Introduction
- Features
- Implementation Guidelines
- Getting Started
- Running the Bot Locally
- Setting Up Ngrok for Webhook
- Telegram Bot Usage
- Running YOLOv5 Microservice
The Telegram app, implemented in Flask, serves as a chat-based interface for users to interact with image object detection functionality.
- Python environment
- Docker
-
Clone the Repository:
git clone https://github.com/ibraheemGanayim/DetectiveBot-YOLOv5-Telegram.git cd DetectiveBot-YOLOv5-Telegram
-
Build and Run the Docker Containers:
docker-compose up --build
-
Set Up Ngrok for Secure Tunneling:
- Sign up for Ngrok and install the Ngrok agent.
- Authenticate Ngrok with your authtoken:
ngrok config add-authtoken <your-authtoken>
- Start Ngrok to expose the local server:
ngrok http 8443
- Obtain the Ngrok public URL (e.g., https://16ae-2a06-c701-4501-3a00-ecce-30e9-3e61-3069.ngrok-free.app).
- Set the
TELEGRAM_APP_URL
environment variable to your Ngrok URL.
-
Test the Echo Bot:
- The default behavior echoes incoming messages. Try it out!
-
Extend with QuoteBot:
- Change the instantiated instance in
app.py
:- Bot(TELEGRAM_TOKEN, TELEGRAM_APP_URL) + QuoteBot(TELEGRAM_TOKEN, TELEGRAM_APP_URL)
- Change the instantiated instance in
The ObjectDetectionBot
class in bot.py
handles incoming messages for image object detection.
-
Change the instantiated instance in
app.py
:- Bot(TELEGRAM_TOKEN, TELEGRAM_APP_URL) + ObjectDetectionBot(TELEGRAM_TOKEN, TELEGRAM_APP_URL)
-
Run the Object Detection Bot:
- Start Ngrok to expose the local server:
ngrok http 8443
- Start the other services:
docker-compose up --build
- Send an image to the bot and observe the results.
- Start Ngrok to expose the local server:
Feel free to customize and enhance the project based on your needs. Contributions are welcome!