Skip to content

99sphere/NAVER_AI_Tech_Final_Project_CArtoonize_For_Extra_faces

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

CAFE: CArtoonize For Extra faces

TEAM Member

๋ธ”๋ž™๋ฐ•์Šค

๐Ÿ™ˆ ๊น€๊ธฐ์šฉ

๐Ÿ’ ๊น€์„ฑ์ˆ˜

๐Ÿ™‰ ๊น€์ฃผ์—ฝ

๐Ÿ™Š ์ด ๊ตฌ

๐Ÿต ์ดํƒœํฌ
  • ๊น€๊ธฐ์šฉ_T4020: Cartoonize ๋ชจ๋ธ ์กฐ์‚ฌ, ์‹คํ—˜ ๊ฒฐ๊ณผ ๋ถ„์„
  • ๊น€์„ฑ์ˆ˜_T4039: Object Tracking ๋ชจ๋ธ ์กฐ์‚ฌ, Modeling, ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋ฐœ
  • ๊น€์ฃผ์—ฝ_T4048: Model Serving
  • ์ด ๊ตฌ_T4145: Cartoonize ๋ชจ๋ธ ์กฐ์‚ฌ, Modeling, ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ฐœ๋ฐœ
  • ์ดํƒœํฌ_T4172: Object Tracking ๋ชจ๋ธ ์กฐ์‚ฌ, Modeling, ์ฝ”๋“œ ์˜ค๋ฅ˜ ๋ถ„์„ ๋ฐ ์ˆ˜์ •

Project Outline



  • TV ํ”„๋กœ๊ทธ๋žจ ํ˜น์€ ์œ ํŠœ๋ธŒ๋ฅผ ๋ณด๋‹ค๋ณด๋ฉด, ๋ฉ”์ธ ์ถœ์—ฐ์ž๊ฐ€ ์•„๋‹Œ ์ด๋“ค์˜ ์–ผ๊ตด์„ ๋ชจ์ž์ดํฌ ๋œ ๊ฒƒ์„ ์‰ฝ๊ฒŒ ์ฐพ์•„๋ณผ ์ˆ˜ ์žˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด๋Ÿฌํ•œ ๋ชจ์ž์ดํฌ ๊ธฐ๋ฒ•์€ ์–ผ๊ตด์˜ ํŠน์ง•์„ ์ง€์›Œ๋ฒ„๋ฆฌ๊ธฐ ๋•Œ๋ฌธ์— ์ธ๋ฌผ์˜ ์–ผ๊ตด ํ‘œ์ •, ๋ˆˆ๋น›, ์‹œ์„ ๊ณผ ๊ฐ™์€ ์ •๋ณด๋ฅผ ์žƒ๊ฒŒ ๋œ๋‹ค.


  • ์œ„์˜ ์‚ฌ์ง„๋“ค์€ '๋ฐฑ์ข…์›์˜ ์ฟ ํ‚น๋กœ๊ทธ'๋ผ๋Š” ์œ ํŠœ๋ธŒ ์ฑ„๋„์—์„œ ๊ฐ€์ ธ์˜จ ๊ฒƒ์œผ๋กœ, ์ผ๋ฐ˜์ธ์˜ ํ‘œ์ •๊ณผ ๋Œ€์‘๋˜๋Š” ๋ฐฑ์ข…์›์˜ ์‚ฌ์ง„์œผ๋กœ ๋Œ€์ฒดํ•จ์œผ๋กœ์จ ๊ทธ๋“ค์˜ ๋ฐ˜์‘์„ ํšจ๊ณผ์ ์œผ๋กœ ํŒŒ์•…ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜์˜€๋‹ค.
  • ํ•˜์ง€๋งŒ, ์ด๋Ÿฌํ•œ ๋ฐฉ์‹์€ ํŽธ์ง‘์ž๊ฐ€ ์ง์ ‘ ํ•ด๋‹น ํ”„๋ ˆ์ž„์˜ ์–ผ๊ตด์„ ์ฐพ์•„ ๋ฐ”๊ฟ”์ฃผ์–ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ƒ๋‹นํ•œ ๋น„์šฉ(์‹œ๊ฐ„, ๋…ธ๋ ฅ ๋“ฑ)์ด ๋ฐœ์ƒํ•œ๋‹ค.
  • ์ด์— ์šฐ๋ฆฌ๋Š” ๊ธฐ์กด์˜ ๋ชจ์ž์ดํฌ๋ฅผ ๋Œ€์ฒดํ•˜์—ฌ ์‚ฌ๋žŒ์„ ํŠน์ •ํ•  ์ˆ˜ ์žˆ์„ ์ •๋„๋กœ ์–ผ๊ตด์„ ๋…ธ์ถœ์‹œํ‚ค์ง€ ์•Š๋Š” ๋™์‹œ์— ์–ผ๊ตด ํ‘œ์ •, ์‹œ์„ , ๋ˆˆ๋น›๊ณผ ๊ฐ™์€ ์ •๋ณด๋Š” ๋ณด์กดํ•  ์ˆ˜ ์žˆ๋Š” ์ƒˆ๋กœ์šด ๋ฐฉ์‹, CAFE(CArtoonize For Extra faces)๋ฅผ ์ œ์•ˆํ•œ๋‹ค.

Environment

  • Ubuntu 18.04.5 LTS
  • Intel(R) Xeon(R) Gold 5120 CPU @ 2.20GHz
  • NVIDIA Tesla V100-SXM2-32GB (used up to 8GB at our test)
  • CUDA 11.0
  • Tensorflow 1.12.0
  • PyTorch 1.12.1
  • opencv-python 4.2.0.34

Architecture

Summary

Data Flow


์ „์ฒด์ ์ธ Data Flow๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

  1. User๋กœ๋ถ€ํ„ฐ ์˜์ƒ๊ณผ ์˜์ƒ์˜ ์ฃผ์ธ๊ณต(target) ์‚ฌ์ง„์„ ์ž…๋ ฅ๋ฐ›๋Š”๋‹ค.
  2. ์˜์ƒ์— face detection & tracking, cartoonize๋ฅผ ์ ์šฉํ•œ๋‹ค.
    2-1. ์˜์ƒ์— ๋Œ€ํ•œ face detection, tracking์„ ํ†ตํ•˜์—ฌ ๋ชจ๋“  ๋“ฑ์žฅ์ธ๋ฌผ์˜ ์–ผ๊ตด ์ •๋ณด๋ฅผ ์–ป๋Š”๋‹ค.
    2-2. ์˜์ƒ์˜ ๋ชจ๋“  ํ”„๋ ˆ์ž„์— ๋Œ€ํ•œ cartoonize๋ฅผ ์ง„ํ–‰ํ•œ๋‹ค.
  3. ์ฃผ์ธ๊ณต ์‚ฌ์ง„๊ณผ ์˜์ƒ์— ๋“ฑ์žฅํ•˜๋Š” ์ธ๋ฌผ๋“ค์˜ ์‚ฌ์ง„์— ๋Œ€ํ•œ feature๋ฅผ ๋ฝ‘์•„๋‚ธ ํ›„, cosine similarity๋ฅผ ๊ณ„์‚ฐํ•˜์—ฌ target๊ณผ target์ด ์•„๋‹Œ ์–ผ๊ตด๋“ค์„ ๊ตฌ๋ถ„ํ•œ๋‹ค.
  4. target์ด ์•„๋‹Œ ์–ผ๊ตด๋“ค์— ๋Œ€ํ•œ ์ •๋ณด(from 2-1)๋ฅผ ์ด์šฉํ•˜์—ฌ, ๋ชจ๋“  ํ”„๋ ˆ์ž„์˜ ์–ผ๊ตด์„ swap ํ•œ๋‹ค.

Service Flow


์ „์ฒด์ ์ธ Service Flow๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

  1. Streamlit์„ ํ†ตํ•ด user์™€ interactionํ•˜๋ฉฐ, ์ฃผ์ธ๊ณต ์ด๋ฏธ์ง€์™€ ์˜์ƒ์„ ์ž…๋ ฅ๋ฐ›๊ณ , ๊ฒฐ๊ณผ๋ฌผ์„ ๋‹ค์šด๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค.
  2. Streamlit์„ ํ†ตํ•ด ์ž…๋ ฅ๋ฐ›์€ ์ด๋ฏธ์ง€์™€ ์˜์ƒ์€ local file storage์— ์ €์žฅ๋˜๋ฉฐ, FastAPI๋ฅผ ํ†ตํ•ด Detection & Tracking, Cartoonize ์—ฐ์‚ฐ์„ ์š”์ฒญํ•œ๋‹ค.
  3. Detection & Tracking์€ PyTorch ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰๋˜๊ณ , Cartoonize๋Š” Tensorflow ํ™˜๊ฒฝ์—์„œ ์‹คํ–‰๋œ๋‹ค. ์ด ๊ณผ์ •์€ ๋ณ‘๋ ฌ์ ์œผ๋กœ ์ง„ํ–‰๋˜๋ฉฐ, Tracking ๊ฒฐ๊ณผ๋Š” MongoDB์— ์ €์žฅ๋œ๋‹ค.
  4. ์œ„์˜ ๊ณผ์ •์ด ๋๋‚œ ์ดํ›„, backend์—์„œ MongoDB์— ์ €์žฅ๋œ tracking ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ face swapping ๊ณผ์ •์„ ์ˆ˜ํ–‰ํ•œ๋‹ค.
  5. Streamlit์„ ํ†ตํ•ด user๊ฐ€ ์ตœ์ข… ๊ฒฐ๊ณผ๋ฌผ์˜ ์žฌ์ƒ ๋ฐ ์ €์žฅ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

Usage

Environment Setup

  • To use any form of function we provide, the following process must be followed.
# Clone our repository
git clone https://github.com/boostcampaitech4lv23cv1/final-project-level3-cv-07

# Move to our dir
cd final-project-level3-cv-07

# Setup for each virtual environment (for frontend, backend, detection & tracking, cartoonize)
bash init.sh

Run CAFE with Web Demo

  • You can run CAFE with web demo. Just follow the instruction below.
# Open frontend/app.py and update backend ip address in line 14
vim frontend/app.py

"""
fix below line
backend = "http://115.85.182.51:30002" -> backend = "http://{your_own_ip_address}:30002"
"""

# Start all process required for starting demo page
bash start.sh

# Now, you can access demo page at "http://{your_own_ip_address}:30001"}

Run CAFE without Web Demo (WIP)

  • Unfortunately, we haven't checked the file path yet. Do it yourself if you need to.

  • You can also run CAFE without web demo. Just run the python file in the order below.

  1. Run cartoonize function (models/cartoonize/Cartoonize.py)
cd final-project-level3-cv-07/models/cartoonize
python Cartoonize.py
  1. Run tracking, face swapping and save result (models/track/mc_demo_yolov7.py)
cd final-project-level3-cv-07/models/track
python tools/mc_demo_yolov7.py

Dataset

YOLOv7-tiny

Trained with WiderFace, [pretrained weights]
Download the pre-trained weights and place them in the path below.

./final-project-level3-cv-07/models/track/pretrained

White-box Cartoonization

Trained with private dataset. Scenery images are collected from Shinkai Makoto, Miyazaki Hayao and Hosoda Mamoru films. Portrait images are from Kyoto animations and PA Works). [pretrained weights]
Download the pre-trained weights and place them in the path below. (maybe, already exist)

./final-project-level3-cv-07/models/cartoonize/saved_models


Result

Discussion

  • ์ฒซ ๋ฒˆ์งธ ๊ฒฐ๊ณผ์˜ tracking result๋ฅผ ๋ณด๋ฉด ๋ฐฐ๊ฒฝ ๋ฐ ์˜์ƒ์—์„œ๋„ ์–ผ๊ตด์ด ์ธ์‹๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. CAFE๋Š” confidence thresholding์„ ํ†ตํ•ด ์ด๋Ÿฌํ•œ ์ƒํ™ฉ์—์„œ๋„ ๊ฐ•์ธํ•˜๊ฒŒ ๋™์ž‘ํ•œ๋‹ค.
  • ๋‘ ๋ฒˆ์งธ, ์„ธ ๋ฒˆ์งธ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ํ™”๋ฉด ์ „ํ™˜์— ์˜ํ•ด ๋™์ธ ์ธ๋ฌผ์— ๋Œ€ํ•œ ์—ฌ๋Ÿฌ๊ฐœ์˜ tracklet์ด ์ƒ์„ฑ๋˜์ง€๋งŒ, ์šฐ๋ฆฌ๊ฐ€ ์ œ์•ˆํ•œ two-step similarity check ๊ณผ์ •์„ ํ†ตํ•ด ์„ฑ๊ณต์ ์œผ๋กœ target๊ณผ extra๋ฅผ ๊ตฌ๋ถ„ํ•ด๋‚ด๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.
target
tracking result
CAFE result









์˜์ƒ ์ถœ์ฒ˜


Demo



More Details

[Wrap-up Report] [Slides] [Presentation]


Reference

  • C.-Y. Wang, A. Bochkovskiy, H.-Y. M. Liao, Yolov7: Trainable bag- of-freebies sets new state-of-the-art for real-time object detectors, arXiv preprint arXiv:2207.02696.
  • N. Aharon, R. Orfaig, B.-Z. Bobrovsky, Bot-sort: Robust associations multi-pedestrian tracking, arXiv preprint arXiv:2206.14651.
  • X. Wang, J. Yu, Learning to cartoonize using white-box cartoon represen- tations, in: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, 2020, pp. 8090โ€“8099.

Acknowledgement

A large part of the code are borrowed from YOLOv7 with wider face dataset, BoT-SORT, White-box-Cartoonization. Thanks for their excellent work and sharing.

About

CAFE: CArtoonize For Extra faces

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 81.3%
  • C++ 15.3%
  • C 1.5%
  • Cython 0.8%
  • Shell 0.5%
  • CMake 0.3%
  • Other 0.3%