This Telegram bot allows users to send images and receive enhanced versions using the Replicate API, which is based on the gfpgan model.
To use this bot, you need to follow these steps:
-
Obtain a Telegram bot token by creating a new bot on Telegram. You can do this by talking to the BotFather on Telegram and following these steps:
- Search for "@BotFather" on Telegram and start a chat with the BotFather.
- Use the "/newbot" command to create a new bot. Follow the instructions to choose a name and username for your bot.
- The BotFather will provide you with a bot token. Save this token as it will be required to interact with the Telegram Bot API.
-
Obtain a Replicate API token. Visit the Replicate website or platform to create an account and obtain your API token.
-
Install the required dependencies by running the following command:
pip install -r requirements.txt -
Set the API variables for your Telegram bot token and Replicate API token:
TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" REPLICATE_API_TOKEN = "YOUR_REPLICATE_API_TOKEN" -
Run the bot by executing the main Python script:
python main.py
-
Start a chat with your Telegram bot.
-
Send an image to the bot by attaching it to the message.
-
The bot will process the image using the gfpgan model through the Replicate API.
-
The enhanced image will be sent back to you in the same chat.
This bot relies on the following dependencies:
-
telebot: The Telegram Bot API wrapper for Python, which enables easy interaction with Telegram bots. -
replicate: A Python client for the Replicate API, allowing you to utilize the gfpgan model for image enhancement.
-
The gfpgan model used for image enhancement is provided by Replicate. For more information about Replicate and its services, visit their website (URL).
-
Special thanks to the developers of the
telebotlibrary for making Telegram bot development accessible and straightforward.
This project is provided for educational and demonstration purposes only. The usage of the gfpgan model and the Replicate API is subject to their terms and conditions. Ensure you comply with the usage policies of the respective services when deploying the bot in production or for commercial purposes.
Feel free to fork, modify, and use this code in accordance with the license.