Skip to content

hektorbot/backend

Repository files navigation

Known Vulnerabilities Code style: black

Hektor backend

This is Hektor's Python backend. It's responsible for creating images based on a set of rules defined by the artist, Isabelle Gagné. It also provides a REST API to let the frontend app retrieve the data it needs.

Images processing can take a significant amount of time since we need to trigger a style transfer through FloydHub by running a temporary Model API based on our own fork of anishathalye/neural-style, thus we append every request to a queue using Django-Q and a Redis backend.

Requirements

These should be installed on the host machine prior to setting up the app:

  • Python >= 3.7.3
  • Redis >= 5.0.4

The style transfer app must be set up on the same machine: https://github.com/hektorbot/neural-style

Setup

  1. Clone the project locally and cd into it:
$ git clone [email protected]:hektorbot/backend.git hektor-backend
$ cd hektor-backend
  1. Create a virtual environment and activate it (optional):
$ python3 -m venv venv
$ . venv/bin/activate
  1. Install required modules:
$ pip install -r requirements.txt
  1. Create a .env file based on .env.example and set the variables as needed:
$ cp .env.example .env
  1. Run migrations:
$ django manage.py migrate
  1. A Vision API-authorized GCP service account key is required for reverse image search, make sure one is saved locally and that the GOOGLE_APPLICATION_CREDENTIALS references it properly

  2. Pixelsort must be cloned locally and the PIXEL_SORT_PATH variable should be the absolute path to pixelsort.py

  3. Run the app:

$ django manage.py runserver
  1. To enable image processing, you'll need to start django-q's cluster in the background (make sure Redis server is running first):
$ nohup python manage.py qcluster&

The app should now be running on http://127.0.0.1:8000/

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published