Giter VIP home page Giter VIP logo

styletransfer's Introduction

StyleTransfer

Python telegram bot for style transfer between two photos. It can be found here.

At the time of publication of this text the bot is running on VK Cloud service, and will probably runs for the next month with interruptions for technical issues, then access to the bot via the link is not guaranteed.

Model

For transferring style I chose MSG-Net implemented by zhanghang1989. It is already pre-trained and small enough to work out in a few seconds per image. A little bit corrected for my purposes code is placed in model.py. Photo examples can be found in the examples folder. The pre-trained weights of the model are placed in 21styles.model.

Bot

I used pyTelegramBotApi framework for the bot. It was chosen because it is quite simple and flexible, and also allows to write asynchronous code, which is very useful for Telegram bots. The intuitive interface of the bot is implemented using buttons, there is also detailed instruction for the user how to work with bot. While working with bot, users photos are stored in the chats folder in subfolders with chat_id names. The bots code is in main.py.

Setup

To launch the bot, you should get a unique token here. Next, put it in the main.py in line number 9 instead of token = get_token() write token = <YOUR TOKEN>.

Install

Easy way:

  1. Download the repository.
  2. Go to the root directory.
  3. Install the required packages from requirements.txt. This can be done by:

$ pip install -r requirements.txt

If you have troubles with installation, then try installing without the cache directory:

$ pip install -r --no-cache-dir requirements.txt

  1. Run the bot using the:

$ python3 main.py

Module installation:

By file setup.py it is possible to build a package wheel, for this you should use:

$ python3 setup.py sdist bdist_wheel

Next, the assembled package will appear in the dist folder.

Docker installation:

it is also possible to build a docker container using the Dockerfile:

$ docker build -t python-docker-app .

Deploy

To deploy the Telegram bot, I used VK Cloud service. Tested on a virtual machine with Ubuntu 22.04, 2 CPU cores and 4GB RAM. You can upload the application code there directly from github or from a local system using the scp utility, install and run according to the instructions above.

Feedback

For questions related to the bot, you can contact me in my telegram.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.