Convert images and videos into a cartoon!
The webapp is deployed here - https://cartoonize-lkqov62dia-de.a.run.app
You can find a writeup on this webapp's architecture here!
These are important steps if you want to leverage Google buckets, signed URLs and Algorithmia's platform.
To use any functionalities pertaining to Google Cloud, you'll need a global authentication file (JSON). You can obtain this JSON by following the steps given here - Getting started with authentication
After you get the JSON file, rename it to token.json
(so that it's compatible with the codebase).
Set the environment variable in your terminal -
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/token.json"
Notes:
- You can set it permanently by adding this line to
~/.bashrc
. Dockerfile
already includes the setting of this particular environment variable. :)
We used the Serveless AI Layer product of Algorithmia for inference on videos. To learn more on how to deploy your model in Algorithmia, check here - https://algorithmia.com/developers
- python 3.7
- tensorflow 2.1.0
- tf_slim 1.1.0
- Cuda version 10.1
- OS: Linux (Ubuntu 18.04)
The easiest way to get the webapp running is by using the Dockerfile:
cd
into the root directory and build the image
docker build -t cartoonize .
Note: Set the appropriate values in config.yaml
before building the image.
- Run the container by exposing the appropriate ports
docker run -p 8080:8080 cartoonize
- Make a virtual environment using
virutalenv
and activate it
virtualenv -p python3 cartoonize
source cartoonize/bin/activate
- Install python dependencies
pip install -r requirements.txt
- Run the webapp. Be sure to set the appropriate values in
config.yaml
file before running the application.
python app.py
Using Google Colab
- Clone the repository using either of the below mentioned way:
-
Using Command:
- Create a new Notebook in Colab and in the cell execute the below command.
! git clone https://github.com/experience-ml/cartoonize.git
Note: Don't forget to add
!
at the beginning of the command -
From Colab User Interface
-
Open Colab
└── File
└── Open Notebook
└── Github
└── paste the Url of the repository
Note : Change the runtime to GPU before running the application
Runtime
└── Change runtime type
└── Select GPU
- After cloning the repository navigate to the
/cartoonize
using below command in the notebook cell:
%cd cartoonize
- Run the below code in cell to install the
ngrok
for creating the url to access the application:
!pip install flask-ngrok
-
In
/app.py
Add the following code:Import the ngrok:
from flask_ngrok import run_with_ngrok
After app variable add the following command at line 31:
run_with_ngrok(app) #starts ngrok when the app is run
Change the app.run() to the below format:
app.run() #remove the passed parameter
-
Run the below commands in the notebook cell :
Install the requirements
!pip install -r requirements.txt
Launch the flask app on ngrok
!python app.py
-
Copyright © Cartoonizer (Demo webapp)
-
Authors: Niraj Pandkar and Tejas Mahajan.
-
Licensed under the CC BY-NC-SA 4.0
-
Commercial application is prohibited by license
-
-
Copyright (C) Xinrui Wang, Jinze Yu. (White box cartoonization)
- All rights reserved.
- Licensed under the CC BY-NC-SA 4.0
- Also, Commercial application is prohibited license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).