Spaces:
Running
Running
imseldrith
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,165 +1,8 @@
|
|
1 |
-
# Cartoonizer
|
2 |
-
|
3 |
-
> Convert images and videos into a cartoon!
|
4 |
-
|
5 |
-
The webapp is deployed here - https://cartoonize-lkqov62dia-de.a.run.app
|
6 |
-
<div style="text-align:center"><img height="100" alt="Powered by Algorithmia" style="border-width:0" src="static/sample_images/algorithmia.jpeg" /></div>
|
7 |
-
|
8 |
-
You can find a writeup on this webapp's architecture [here](https://medium.com/@Niraj_pandkar/how-we-built-an-inexpensive-scalable-architecture-to-cartoonize-the-world-8610050f90a0)!
|
9 |
-
|
10 |
---
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
- [Google Colab](#using-google-colab)
|
19 |
-
- [Sample Image and Video](#sample-image-and-video)
|
20 |
-
|
21 |
-
---
|
22 |
-
|
23 |
-
## Prerequisites for Google Cloud and Algorithmia
|
24 |
-
|
25 |
-
**These are important steps if you want to leverage Google buckets, signed URLs and Algorithmia's platform. Skip this if you want to run locally / colab.**
|
26 |
-
|
27 |
-
### Cloud Run authentication
|
28 |
-
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](https://cloud.google.com/docs/authentication/getting-started)
|
29 |
-
|
30 |
-
After you get the JSON file, rename it to `token.json` (so that it's compatible with the codebase).
|
31 |
-
|
32 |
-
Set the environment variable in your terminal -
|
33 |
-
```
|
34 |
-
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/token.json"
|
35 |
-
```
|
36 |
-
**Notes**:
|
37 |
-
- You can set it permanently by adding this line to `~/.bashrc`.
|
38 |
-
- `Dockerfile` already includes the setting of this particular environment variable. :)
|
39 |
-
|
40 |
-
|
41 |
-
### Algorithmia
|
42 |
-
We used the Serveless AI Layer product of [Algorithmia](https://algorithmia.com/serverless-ai-layer) for inference on videos.
|
43 |
-
To learn more on how to deploy your model in Algorithmia, check here - https://algorithmia.com/developers
|
44 |
-
|
45 |
-
---
|
46 |
-
|
47 |
-
## Installation
|
48 |
-
|
49 |
-
### Application tested on:
|
50 |
-
|
51 |
-
- python 3.7
|
52 |
-
- tensorflow 2.1.0
|
53 |
-
- tf_slim 1.1.0
|
54 |
-
- ffmpeg 3.4.8
|
55 |
-
- Cuda version 10.1
|
56 |
-
- OS: Linux (Ubuntu 18.04)
|
57 |
-
|
58 |
-
### Using Docker
|
59 |
-
|
60 |
-
The easiest way to get the webapp running is by using the Dockerfile:
|
61 |
-
|
62 |
-
1. `cd` into the root directory and build the image
|
63 |
-
```
|
64 |
-
docker build -t cartoonize .
|
65 |
-
```
|
66 |
-
**Note**: Set the appropriate values in `config.yaml` before building the image.
|
67 |
-
|
68 |
-
2. Run the container by exposing the appropriate ports
|
69 |
-
```
|
70 |
-
docker run -p 8080:8080 cartoonize
|
71 |
-
```
|
72 |
-
|
73 |
-
|
74 |
-
### Using `virtualenv`
|
75 |
-
|
76 |
-
1. Make a virtual environment using `virutalenv` and activate it
|
77 |
-
```
|
78 |
-
virtualenv -p python3 cartoonize
|
79 |
-
source cartoonize/bin/activate
|
80 |
-
```
|
81 |
-
2. Install python dependencies
|
82 |
-
```
|
83 |
-
pip install -r requirements.txt
|
84 |
-
```
|
85 |
-
3. Run the webapp. Be sure to set the appropriate values in `config.yaml` file before running the application.
|
86 |
-
```
|
87 |
-
python app.py
|
88 |
-
```
|
89 |
-
|
90 |
-
### Using [Google Colab](https://colab.research.google.com/drive/1oDhMEVMcsRbe7bt-2A7cDsx44KQpQwuB?usp=sharing)
|
91 |
-
1. Clone the repository using either of the below mentioned way:
|
92 |
-
- Using Command:
|
93 |
-
- Create a new Notebook in Colab and in the cell execute the below command.
|
94 |
-
|
95 |
-
```
|
96 |
-
! git clone https://github.com/experience-ml/cartoonize.git
|
97 |
-
```
|
98 |
-
**Note:** Don't forget to add `!` at the beginning of the command
|
99 |
-
|
100 |
-
- From Colab User Interface
|
101 |
-
```
|
102 |
-
Open Colab
|
103 |
-
└── File
|
104 |
-
└── Open Notebook
|
105 |
-
└── Github
|
106 |
-
└── paste the Url of the repository
|
107 |
-
```
|
108 |
-
Note : Before running the application change the runtime to GPU for processing videos but you for images CPU shall also work just fine.
|
109 |
-
```
|
110 |
-
Runtime
|
111 |
-
└── Change runtime type
|
112 |
-
└── Select GPU
|
113 |
-
```
|
114 |
-
2. After cloning the repository navigate to the `/cartoonize` using below command in the notebook cell:
|
115 |
-
|
116 |
-
```
|
117 |
-
%cd cartoonize
|
118 |
-
```
|
119 |
-
3. Run the below commands in the notebook cell to install the requirements.
|
120 |
-
|
121 |
-
```
|
122 |
-
!pip install -r requirements.txt
|
123 |
-
```
|
124 |
-
|
125 |
-
|
126 |
-
4. In config.yaml file set:
|
127 |
-
|
128 |
-
```
|
129 |
-
colab-mode: true
|
130 |
-
```
|
131 |
-
|
132 |
-
5. Launch the flask app on ngrok
|
133 |
-
|
134 |
-
```
|
135 |
-
!python app.py
|
136 |
-
```
|
137 |
-
|
138 |
-
#### Note : Sample [Google Colab Notebook](https://colab.research.google.com/drive/1oDhMEVMcsRbe7bt-2A7cDsx44KQpQwuB?usp=sharing) for reference
|
139 |
-
|
140 |
-
---
|
141 |
-
|
142 |
-
## Sample Image and Video
|
143 |
-
|
144 |
-
### Emma Watson Cartoonized
|
145 |
-
<img alt="Emma Watson Cartoonized" style="border-width:0" src="static/sample_images/twitter_image.png" />
|
146 |
-
|
147 |
-
### Youtube Video of Avenger's Bar Scene Cartoonized
|
148 |
-
[![Cartoonized version of Avenger's bar scene](http://img.youtube.com/vi/GqduSLcmhto/0.jpg)](http://www.youtube.com/watch?v=GqduSLcmhto "AVENGERS BAR SCENE [Cartoonized Version]")
|
149 |
-
|
150 |
-
---
|
151 |
-
|
152 |
-
## License
|
153 |
-
|
154 |
-
1. Copyright © Cartoonizer ([Demo webapp](https://cartoonize-lkqov62dia-de.a.run.app/))
|
155 |
-
|
156 |
-
- Authors: [Niraj Pandkar](https://twitter.com/Niraj_pandkar) and [Tejas Mahajan](https://twitter.com/tjdevWorks).
|
157 |
-
|
158 |
-
- Licensed under the [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode)
|
159 |
-
- Commercial application is prohibited by license
|
160 |
-
|
161 |
-
|
162 |
-
2. Copyright (C) Xinrui Wang, Jinze Yu. ([White box cartoonization](https://github.com/SystemErrorWang/White-box-Cartoonization))
|
163 |
-
- All rights reserved.
|
164 |
-
- Licensed under the CC BY-NC-SA 4.0
|
165 |
-
- Also, Commercial application is prohibited license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: mit
|
3 |
+
title: Cartoonize
|
4 |
+
sdk: static
|
5 |
+
emoji: 🔥
|
6 |
+
colorFrom: green
|
7 |
+
colorTo: blue
|
8 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|