/level3_cv_finalproject-cv-11

level3_cv_finalproject-cv-11 created by GitHub Classroom

Primary LanguageJupyter Notebook

Personalized deepfake detection service

Traditional Deepfake detection focuses on Deepfake detection for an unspecified number of people.
These are ways to improve the performance of benchmark dataset in Deepfake detection competitions.
Therefore, these methods do not take into account the actual service situation.
Accordingly, we propose a model structure that improves the performance of the detection model by few shot learning a small amount of victim pictures.
Finally, we would like to provide the model-based deepfake detection service 'Fakey' to prevent the abuse of deepfake.

Team Members

김용희 프로필 박승희 프로필 이윤표 프로필 이준하 프로필 주재영 프로필
김용희 박승희 이윤표 이준하 주재영

Environment

Google compute engine

  • region: asia-northeast3-b
  • GPU: Nvidia-T4, num:1 (GPU mem:GDDR6 16GB)
  • CPU: n1-standard-4(vCPU 4개, 15GB 메모리)
  • Boot-disk: Ubuntu20.04LTS 50GB

Cloud SQL

  • database engine: MySQL 8.0.31
  • vCPU:2, 8GB 메모리
  • Disk: SSD 50GB

Folder Structure

├─backend
├─checkpoints
├─datas
├─deepfake
├─docs
├─frontend
├─MobileFaceSwap
└─source



Model architecture

image


Getting Started with Google Cloud Platform

Make GCP instance

  1. Make gcp instance

  2. call for GPU allocation [참고]: https://kim6394.tistory.com/98

  3. GCP config

region: asia-northeast3-b  
GPU: Nvidia-T4, num:1  
CPU: n1-standard-4(vCPU 4개, 15GB 메모리)
Boot-disk: Ubuntu20.04LTS at least 30GB
Firewall: allow all
  1. make SSH-key & add metadata & access with VSCode to GCE
    follow this link to make key by puttygen(don't need private key)https://amanokaze.github.io/blog/Connect-GCE-using-VS-Code/

  2. install cuda

sudo apt install ubuntu-drivers-common -y  
sudo apt install nvidia-driver-515 -y  
wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run

if above link expired find appropriate version in this link https://developer.nvidia.com/cuda-toolkit-archive

sudo sh cuda_11.7.0_515.43.04_linux.run need to wait long time
image
remember checkout Driver!

  1. update .bashrc
    add this to /home/USERNAME/.bashrc
export PATH=/usr/local/cuda-11.7/bin${PATH:+:${PATH}}  
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  1. run bashrc
    source ~/.bashrc
  2. check installed CUDA
    nvcc --version
  3. download cudnn fron oneDrive
    filename is cudnn-linux-x86_64-8.5.0.96_cuda11-archive.tar.zip
  4. install cudnn
    tar -xvf cudnn-linux-x86_64-8.5.0.96_cuda11-archive.tar.xz
sudo cp cudnn-linux-x86_64-8.5.0.96_cuda11-archive/include/cudnn*.h /usr/local/cuda/include
sudo cp -P cudnn-linux-x86_64-8.5.0.96_cuda11-archive/lib/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
  1. check installed cudnn
    cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
  2. reboot to apply changes
    sudo reboot

Make conda virtualenv

  1. download conda
    wget https://repo.anaconda.com/archive/Anaconda3-2020.07-Linux-x86_64.sh
  2. install conda
    bash Anaconda3-2020.07-Linux-x86_64.sh
    image
    check "yes" at here
  3. run bashrc
    source ~/.bashrc
  4. make virtual env
    conda create -n final python=3.9.7
    conda activate final
  5. install mysql
    sudo apt-get install mysql-server mysql-client libmysqlclient-dev
  6. clone our github and cd move to it
    git clone https://github.com/boostcampaitech5/level3_cv_finalproject-cv-11.git
    after this move to develop branch and pull
  7. install requirements without dependencies
    pip install -r requirements.txt --no-deps

Setting mysql database

  1. start mysql server
    sudo service mysql start
  2. make root user & make user_db database
    sudo mysqladmin -u root create user_db -p
  3. import default tables
for localhost
sudo mysql -u root -p user_db < {home_path}/level3_cv_finalproject-cv-11/deepfake.sql

for Cloud SQL
sudo mysql -u root -p user_db -h {your cloud sql ip} < {home_path}/level3_cv_finalproject-cv-11/deepfake.sql
  1. connect mysql with root user
    sudo mysql -u root -p

  2. change mysql security setting for connection
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '1234';
    FLUSH PRIVILEGES;

  3. finally set backend/routers/database.py for your database setting

in 5~6 line in backend/routers/database.py
SQLALCHEMY_DATABASE_URL = "mysql://root:1234@localhost:3306/user_db?charset=utf8"        #change user user, password for localhost mysql setting
SQLALCHEMY_DATABASE_URL = "mysql://root:1234@34.64.189.15:3306/user_db?charset=utf8"        #For my cloud SQL server

Download model weights

  1. download all model weights by below link
    https://schackr-my.sharepoint.com/:f:/g/personal/hykhhijk_sch_ac_kr/EjauXOPs4RBKh3S2RsNiK2sBQaIiG8quXpdAjJbTo10ncA?e=hDgffg
  2. move checkpoints folder to right below outr folder and Meta_train_learning_id_60.pt in to datas
    image
    structure have to looks like this