---
# System prepended metadata

title: Cartoonify
tags: [cartoonify, finalproject, ideas, mle]

---

---
title: 'Cartoonify'
disqus: hackmd
---

Cartoonify
===

## Table of Contents

[TOC]

## Summary

This project is to transform a real world image into a cartoon one using *cycleGAN*.

![](https://i.imgur.com/cL7mpJO.jpg)
![](https://i.imgur.com/qdqqUtG.png)
![](https://i.imgur.com/rbfTfPo.png)



### Problem

Cartoon is a popular art form that has been widely applied in diverse scenes, but it needs skills and time to create one (for a scenary or a portrait).

### Solution

Re-implement the paper [AnimeGAN: A Novel Lightweight GAN for Photo Animation](https://github.com/TachibanaYoshino/AnimeGAN/blob/master/doc/Chen2020_Chapter_AnimeGAN.pdf)

- TODO add steps

## Data

- The real-world photos (*6,656*) as the **content images** and the anime images as the **style images** (*1500+* for each style) are used as the training data.



## Model

![](https://i.imgur.com/3WzuZJd.png)

In the generator, the numbers on all boxes represent the number of channels and SUM means the element-wise sum. In the discriminator, “K” is the kernel size, “C” is the number of the feature maps, “S” is the stride in each convolutional layer and Inst Norm indicates the instance normalization layer.

![](https://i.imgur.com/ifMMTuF.png)


The architectures of Conv-Block, DSConv, IRB, Down-Conv and Up-Conv in AnimeGAN. The “K” is the kernel size, “C” is the number of feature maps, “S” is the stride in each convolutional layer. The “H” is the height of the feature map, “W” is the width of the feature map. Resize means the interpolation method to set the size of the feature maps. The ⊕ indicates the element-wise addition.

## Loss function

## Training


## Result

## Setup environment

```bash=
$ conda create -n animeGAN python=3
$ conda activate animeGAN
$ conda install -y pandas matplotlib scikit-learn jupyterlab
$ conda install -c conda-forge opencv
$ conda install -c apple tensorflow-deps
$ python -m pip install tensorflow-macos
$ python -m pip install tensorflow-metal
$ conda install -c anaconda numpy
$ conda install -c conda-forge tqdm
$ conda install -c conda-forge glob2
$ conda install -c conda-forge configargparse
```

## Todo

- [x] Collect data as per mentioned in the [Data](#Data).
- [x] Understand the paper
    * Neural Style Transfer Methods.
    * cycleGAN.
- [x] Pre-process data:
    * Place training data in corresponding folders in */dataset*.
    * Run *pretrain.py*, results will be saved in */pretrain* folder
- [x] Run *train.py*, results will be saved in */traincartoon* folder

Pretrained VGG_19 model can be found [here](https://drive.google.com/file/d/1j0jDENjdwxCDb36meP6-u5xDBzmKBOjJ/view?usp=sharing).

## Timeline

```mermaid
gantt
    axisFormat  %d
    title Total 140hrs, avg 35hrs per week

    section Week 1
    Collect data (20h)     :a1, 2021-07-29, 20h
    section Week 2
    Understand the paper (8h)   : 2021-08-02, 8h
    Pre-process data (24h) : 24h
    Training (24h)         : 24h
    section Week 3
    Issues (48h)           : 2021-08-09, 48h
    StreamLit (8h          : 8h
    section Week 4
    Demo preparation (8h)  : 2021-08-16, 8h
```

<!-- ## Appendix and FAQ

:::info
**Find this document incomplete?** Leave a comment!
::: -->

###### tags: `mle` `finalproject` `ideas` `cartoonify`
