Git Product home page Git Product logo

anime-face-detector's Introduction

Anime-Face-Detector

A Faster-RCNN based anime face detector.

This detector is trained on 6000 training samples and 641 testing samples, randomly selected from the dataset which is crawled from top 100 pixiv daily ranking.

Thanks to OpenCV based Anime face detector written by nagadomi, which helps labelling the data.

The original implementation of Faster-RCNN using Tensorflow can be found here

Dependencies

  • Python >= 3.6
  • tensorflow latest 1.x or 2.x
  • opencv-python (Will use other packages like pillow and scikit-image as backend in future version)
  • cython (optional, can be ignored with additional -nms-type PY_NMS argument)
  • Pre-trained ResNet101 model

Usage

  1. Clone this repository
    git clone https://github.com/qhgz2013/anime-face-detector.git
  2. Download the pre-trained model
    Google Drive: here
    Baidu Netdisk: here
  3. Unzip the model file into model directory
  4. Build the CPU NMS model (skip this step if use PY_NMS with argument: -nms-type PY_NMS)
    make clean
    make
    If using Windows Power Shell, type cmd /C make.bat to run build script.
  5. Run the demo as you want
    • Visualize the result (without output path):
      python main.py -i /path/to/image.jpg
    • Save results to a json file
      python main.py -i /path/to/image.jpg -o /path/to/output.json
      Format: {"image_path": [{"score": predicted_probability, "bbox": [min_x, min_y, max_x, max_y]}, ...], ...} Sample output file:
      {"/path/to/image.jpg": [{"score": 0.9999708, "bbox": [551.3375, 314.50253, 729.2599, 485.25674]}]}
    • Detecting a whole directory with recursion
      python main.py -i /path/to/dir -o /path/to/output.json
    • Customize threshold
      python main.py -i /path/to/image.jpg -nms 0.3 -conf 0.8
    • Customize model path
      python main.py -i /path/to/image.jpg -model /path/to/model.ckpt
    • Customize nms type (supports CPU_NMS and PY_NMS, not supports GPU_NMS because of the complicated build process for Windows platform)
      python main.py -i /path/to/image.jpg -nms-type PY_NMS
    • Crop detected images and store them in a folder (start output is an integer to start naming the cropped images, default is 0)
      python main.py -i /path/to/image/or/folder -crop-location /path/to/store/cropped/images -start-output 1
    • Crop detected images and resizes them
      python main.py -i /path/to/image/or/folder -crop-location /path/to/store/cropped/images -crop-height 224 -crop-width 224

Results

Mean AP for this model: 0.9086

Copyright info: 東方まとめ by 羽々斬

Copyright info: 【C94】桜と刀 by 幻像黒兎

Copyright info: アイドルマスター シンデレラガールズ by 我美蘭@1日目 東A-40a

About training

This model is directly trained by Faster-RCNN, with following argument:

python tools/trainval_net.py --weight data/imagenet_weights/res101.ckpt --imdb voc_2007_trainval --imdbval voc_2007_test --iters 60000 --cfg experiments/cfgs/res101.yml --net res101 --set ANCHOR_SCALES "[4,8,16,32]" ANCHOR_RATIOS "[1]" TRAIN.STEPSIZE "[50000]"

Dataset

We've uploaded the dataset to Google drive here, dataset structure is similar to VOC2007 (used in original Faster-RCNN implementation).

Citation and declaration

Feel free to cite this repo and dataset.
This work is not related to my research team and lab, just my personal interest.

anime-face-detector's People

Contributors

lauslim12 avatar ledlamp avatar qhgz2013 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

anime-face-detector's Issues

George Costanza is anime?

This has worked super well, except it has a very weird outlier of recognizing George Costanza's bald head as anime. I've tested this with 3 images of him:

image

image

image

I'm not totally sure why this is so set on believing George Costanza is anime, but maybe it is right?!?! 🤔

No module named 'tensorflow.contrib'

I think this means you're still using tensorflow pre-2.0, how much trouble would it be to upgrade? I'll make a PR if you say it won't be too hard

error: Unable to find vcvarsall.bat

Hi everyone. I try to run the command "make". But I see the error: Unable to find vcvarsall.bat.

Ps: I run it on Windows with anaconda
Thanks

tensorflow.python.framework.errors_impl.NotFoundError: model; No such file or directory

Hello! When i run the command below, it can not work. Can someone help me?

python /home/beryl/Documents/anime-face-detector-master/main.py -i /home/beryl/Documents/Anime-Face-Dataset-master/animeface-character-dataset/thumb/000_hatsune_miku/ -o /home/beryl/Documents/character_dataset/000_hatsune_miku.json -nms-type PY_NMS

/home/beryl/Documents/Anime-Face-Dataset-master/animeface-character-dataset/thumb/000_hatsune_miku/
2019-11-28 20:33:46.663551: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-11-28 20:33:47.276064: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-11-28 20:33:47.276415: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties:
name: GeForce RTX 2070 major: 7 minor: 5 memoryClockRate(GHz): 1.71
pciBusID: 0000:01:00.0
totalMemory: 7.79GiB freeMemory: 7.69GiB
2019-11-28 20:33:47.276443: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0
2019-11-28 20:33:47.537843: I tensorflow/core/common_runtime/gpu/gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-11-28 20:33:47.537891: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0
2019-11-28 20:33:47.537897: I tensorflow/core/common_runtime/gpu/gpu_device.cc:984] 0: N
2019-11-28 20:33:47.538050: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7402 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2070, pci bus id: 0000:01:00.0, compute capability: 7.5)
Traceback (most recent call last):
File "/home/beryl/Documents/anime-face-detector-master/main.py", line 172, in
main()
File "/home/beryl/Documents/anime-face-detector-master/main.py", line 124, in main
saver.restore(sess, args.model)
File "/home/beryl/anaconda3/envs/py3.6/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1715, in restore
if not checkpoint_exists(compat.as_text(save_path)):
File "/home/beryl/anaconda3/envs/py3.6/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 2056, in checkpoint_exists
if file_io.get_matching_files(pathname):
File "/home/beryl/anaconda3/envs/py3.6/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 342, in get_matching_files
for single_filename in filename
File "/home/beryl/anaconda3/envs/py3.6/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 519, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: model; No such file or directory

Can I access to the training data?

Hi! Thank you for creating great model.

Is it possible to access to the training data you used for this model?
Guessing from the README, you prepared rough annotated data and adjusted the data manually. Is it right? It's ok to make such data by myself but it's very helpful if I can use existing data.

Japanese filenames cause an error

$ python main.py -i ~/Desktop/a/ -crop-location ~/Desktop/b/
[1/144] Elapsed: 0:00.000, ETA: 0:00.000 >> C:/Users/me/Desktop/a/censored_cg05a.png
[2/144] Elapsed: 0:03.402, ETA: 8:06.521 >> C:/Users/me/Desktop/a/censored_cg05b.png
[3/144] Elapsed: 0:05.996, ETA: 7:05.748 >> C:/Users/me/Desktop/a/censored_cg05c.png
[4/144] Elapsed: 0:08.626, ETA: 6:45.443 >> C:/Users/me/Desktop/a/censored_cg05d.png
[5/144] Elapsed: 0:11.273, ETA: 6:34.558 >> C:/Users/me/Desktop/a/censored_cg14a.png
[6/144] Elapsed: 0:13.825, ETA: 6:24.344 >> C:/Users/me/Desktop/a/censored_ct07a.png
[7/144] Elapsed: 0:16.278, ETA: 6:14.415 >> C:/Users/me/Desktop/a/cg08ax2.png
Traceback (most recent call last):
  File "main.py", line 187, in <module>
    main()
  File "main.py", line 138, in main
    print('[%d/%d] Elapsed: %s, ETA: %s >> %s' % (idx+1, file_len, fmt_time(elapsed), fmt_time(eta), file))
  File "C:\Users\me\AppData\Local\Programs\Python\Python38\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 70-72: character maps to <undefined>
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile

It's failing on this

If I rename them with only ascii, it works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.