Skip to content

yw0nam/anime_face_detection_tinaface

Repository files navigation

Introduction

source of above video [youtube]

This repositroy developed based on TinaFace and vedadet.

The model is trained by data from anime-face-detector(Train 6000, validation 640). We collect data using our custom pipeline from anime videos. We extract the datas from follwoing animes.

name season
Mahouka Koukou no Rettousei 1
Sword Art Online 1, 2
My Youth Romantic Comedy Is Wrong, As I Expected 1, 2
Kaguya-sama: Love Is War 1

Each anime season, our pipeline can extract about 3000 images. We split the datas 80% for training and 20% for validation. For Detail about our pipeline, Please refer here

License

This project is released under the Apache 2.0 license.

Installation

Requirements

  • Linux
  • Python 3.7+
  • PyTorch 1.6.0 or higher
  • CUDA 10.2 or higher

We have tested the following versions of OS and softwares:

  • OS: Ubuntu 16.04.6 LTS
  • CUDA: 10.2
  • PyTorch 1.6.0
  • Python 3.8.5

Install animeface

a. Create a conda virtual environment and activate it.

conda create -n animeface python=3.8.5 -y
conda activate animeface

b. Install PyTorch and torchvision following the official instructions, e.g.,

conda install pytorch torchvision -c pytorch

c. Clone the anime_face_detection_tinaface repository.

git clone https://github.com/yw0nam/anime_face_detection_tinaface.git
cd anime_face_detection_tinaface

d. Install animeface.

pip install -r requirements/build.txt
pip install -v -e .

e. Other libraries.

you need to install other libraries(pascal_voc_writer, pandas, tqdm, etc) in order to run training and test code.

Data Preparation

Dataset

a. Download danbooru dataset from here, and (optional) extract more data using our pipeline

Data structure before processing
```plain
vedadet
├── vedadet
├── vedacore
├── tools
├── configs
├── data
│   ├── anime_face_detector
│   │   ├── train
│   │   │   ├── Annotations
│   │   ├── val
│   │   │   ├── Annotations

b. Run the following code to generate txt file of xmls.

bash process_xml.sh

c. Final data structure as follow

vedadet
├── vedadet
├── vedacore
├── tools
├── configs
├── data
│   ├── anime_face_detector
│   │   ├── train
│   │   │   ├── 0--danbooru
│   │   │   ├── 1--anime_1
│   │   │   ├── ......
│   │   │   ├── 22--anime_21
│   │   │   ├── Annotations
│   │   │   ├── train.txt
│   │   ├── val
│   │   │   ├── 0--danbooru
│   │   │   ├── 1--anime_1
│   │   │   ├── ......
│   │   │   ├── 22--anime_21
│   │   │   ├── Annotations
│   │   │   ├── val.txt

Train

a. Config

Modify some configuration accordingly in the config file like configs/trainval/anime_face_detection/animeface.py

b. Multi-GPUs training

tools/dist_trainval.sh configs/anime_face_detection/animeface.py "0,1"

c. Single GPU training

CUDA_VISIBLE_DEVICES="0" python tools/trainval.py configs/trainval/anime_face_detection/animeface.py

Test

a. Config

Modify some configuration accordingly in the config file like configs/trainval/anime_face_detection/animeface.py

b. Test

CUDA_VISIBLE_DEVICES="0" python tools/test.py configs/trainval/anime_face_detection/animeface.py weight_path

Inference

a. Config

Modify some configuration accordingly in the config file like configs/infer/anime_face_detection/animeface.py

For image

b. Inference

CUDA_VISIBLE_DEVICES="0" python tools/infer.py configs/infer/anime_face_detection/animeface.py image_path

For video(It is not stable yet. this code developed based cheese-roll)

CUDA_VISIBLE_DEVICES="0" python tools/infer_video.py configs/infer/anime_face_detection/animeface.py -i input_video_path -o out_video_path

More inference result

original Out source
youtube
youtube

Contact

This repository is currently maintained by yw0nam. please contact for any issue.

Credits

We can develop this code thanks to vedadet.