Skip to content

deepvertex/DeepFakeDefenders

Repository files navigation

If you like our project, please give us a star ⭐ on GitHub for latest update.

License GitHub contributors Hits GitHub Repo stars GitHub issues GitHub closed issues

💡 We also provide [中文文档 / CHINESE DOC]. We very welcome and appreciate your contributions to this project.

📣 News

  • [2024.09.27] 🔥 We officially released the initial version of Deepfake defenders, and we won the third prize in the deepfake challenge at [the conference on the bund].

🚀 Quickly Start

1. Deploy in Docker

Building

sudo docker build  -t vision-rush-image:1.0.1 --network host .

Running

sudo docker run -d --name  vision_rush_image  --gpus=all  --net host  vision-rush-image:1.0.1

2. Training from Scratch

Modifying the dataset path

Place the training-set (*.txt) file, validation-set (*.txt) file, and label (*.txt) file required for training in the dataset folder and name them with the same file name (there are various txt examples under dataset)

Modifying the Hyper-parameters

For the two models (RepLKNet and ConvNeXt) used, the following parameters need to be changed in main_train.py:

# For RepLKNet.
cfg.network.name = 'replknet'; cfg.train.batch_size = 16
# For ConvNeXt.
cfg.network.name = 'convnext'; cfg.train.batch_size = 24

Using the training script

bash main.sh

Model Assembling

Replace the ConvNeXt model path and the RepLKNet model path in merge.py, and execute python merge.py to obtain the final inference test model.

Inference

The following example uses the POST request interface to request the image path as the request parameter, and the response output is the deepfake score predicted by the model.

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import requests
import json
import requests
import json

header = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36'
}

url = 'http://ip:10005/inter_api'
image_path = './dataset/val_dataset/51aa9b8d0da890cd1d0c5029e3d89e3c.jpg'
data_map = {'img_path':image_path}
response = requests.post(url, data=json.dumps(data_map), headers=header)
content = response.content
print(json.loads(content))

Star History

Star History Chart

About

Image forgery recognition algorithm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.5%
  • Dockerfile 1.4%
  • Shell 0.1%