diff --git a/.github/workflows/docker-bump-push-app.yml b/.github/workflows/docker-bump-push-app.yml index 1d89224a..da0a0f29 100644 --- a/.github/workflows/docker-bump-push-app.yml +++ b/.github/workflows/docker-bump-push-app.yml @@ -21,14 +21,18 @@ jobs: bump-and-push: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write + pull-requests: write steps: - name: Checkout uses: actions/checkout@v7 with: lfs: true + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -73,6 +77,7 @@ jobs: context: . file: App/Dockerfile target: fastapi + platforms: linux/amd64,linux/arm64 tags: | ${{ env.DOCKERHUB_NAMESPACE }}/deepguard-fastapi:${{ steps.bump.outputs.new_tag }} ${{ env.GHCR_NAMESPACE }}/deepguard-fastapi:${{ steps.bump.outputs.new_tag }} @@ -86,9 +91,28 @@ jobs: context: . file: App/Dockerfile target: celery + platforms: linux/amd64,linux/arm64 tags: | ${{ env.DOCKERHUB_NAMESPACE }}/deepguard-celery:${{ steps.bump.outputs.new_tag }} ${{ env.GHCR_NAMESPACE }}/deepguard-celery:${{ steps.bump.outputs.new_tag }} push: true cache-from: type=gha,scope=celery cache-to: type=gha,mode=max,scope=celery + + - name: Update docker-compose.yml image tags + run: | + sed -i -E "s#(image: ${DOCKERHUB_NAMESPACE}/deepguard-fastapi:)[0-9]+\.[0-9]+\.[0-9]+#\1${{ steps.bump.outputs.new_tag }}#" docker-compose.yml + sed -i -E "s#(image: ${DOCKERHUB_NAMESPACE}/deepguard-celery:)[0-9]+\.[0-9]+\.[0-9]+#\1${{ steps.bump.outputs.new_tag }}#" docker-compose.yml + + - name: Open PR to bump docker-compose.yml + uses: peter-evans/create-pull-request@v8 + with: + commit-message: "๐Ÿณ Bump fastapi/celery image tag to ${{ steps.bump.outputs.new_tag }} in docker-compose.yml" + title: "๐Ÿณ Bump fastapi/celery image tag to ${{ steps.bump.outputs.new_tag }}" + body: | + Docker Bump & Push - FastAPI/Celery ์›Œํฌํ”Œ๋กœ์šฐ๊ฐ€ ์ƒˆ๋กœ pushํ•œ ์ด๋ฏธ์ง€ ํƒœ๊ทธ๋ฅผ `docker-compose.yml`์— ๋ฐ˜์˜ํ•ฉ๋‹ˆ๋‹ค. + + - `${{ env.DOCKERHUB_NAMESPACE }}/deepguard-fastapi:${{ steps.bump.outputs.new_tag }}` + - `${{ env.DOCKERHUB_NAMESPACE }}/deepguard-celery:${{ steps.bump.outputs.new_tag }}` + branch: bump/docker-compose-app + delete-branch: true diff --git a/.github/workflows/docker-bump-push-mysql.yml b/.github/workflows/docker-bump-push-mysql.yml index afa337a6..acefacba 100644 --- a/.github/workflows/docker-bump-push-mysql.yml +++ b/.github/workflows/docker-bump-push-mysql.yml @@ -16,12 +16,16 @@ jobs: bump-and-push: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write + pull-requests: write steps: - name: Checkout uses: actions/checkout@v7 + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -62,9 +66,26 @@ jobs: with: context: . file: docker/mysql/Dockerfile + platforms: linux/amd64,linux/arm64 tags: | ${{ env.DOCKERHUB_NAMESPACE }}/deepguard-mysql:${{ steps.bump.outputs.new_tag }} ${{ env.GHCR_NAMESPACE }}/deepguard-mysql:${{ steps.bump.outputs.new_tag }} push: true cache-from: type=gha,scope=mysql cache-to: type=gha,mode=max,scope=mysql + + - name: Update docker-compose.yml image tag + run: | + sed -i -E "s#(image: ${DOCKERHUB_NAMESPACE}/deepguard-mysql:)[0-9]+\.[0-9]+\.[0-9]+#\1${{ steps.bump.outputs.new_tag }}#" docker-compose.yml + + - name: Open PR to bump docker-compose.yml + uses: peter-evans/create-pull-request@v8 + with: + commit-message: "๐Ÿณ Bump mysql image tag to ${{ steps.bump.outputs.new_tag }} in docker-compose.yml" + title: "๐Ÿณ Bump mysql image tag to ${{ steps.bump.outputs.new_tag }}" + body: | + Docker Bump & Push - MySQL ์›Œํฌํ”Œ๋กœ์šฐ๊ฐ€ ์ƒˆ๋กœ pushํ•œ ์ด๋ฏธ์ง€ ํƒœ๊ทธ๋ฅผ `docker-compose.yml`์— ๋ฐ˜์˜ํ•ฉ๋‹ˆ๋‹ค. + + - `${{ env.DOCKERHUB_NAMESPACE }}/deepguard-mysql:${{ steps.bump.outputs.new_tag }}` + branch: bump/docker-compose-mysql + delete-branch: true diff --git a/.github/workflows/docker-bump-push-react.yml b/.github/workflows/docker-bump-push-react.yml index c17d66d6..29d3a654 100644 --- a/.github/workflows/docker-bump-push-react.yml +++ b/.github/workflows/docker-bump-push-react.yml @@ -15,12 +15,16 @@ jobs: bump-and-push: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write + pull-requests: write steps: - name: Checkout uses: actions/checkout@v7 + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -61,9 +65,26 @@ jobs: with: context: client file: client/Dockerfile + platforms: linux/amd64,linux/arm64 tags: | ${{ env.DOCKERHUB_NAMESPACE }}/deepguard-react:${{ steps.bump.outputs.new_tag }} ${{ env.GHCR_NAMESPACE }}/deepguard-react:${{ steps.bump.outputs.new_tag }} push: true cache-from: type=gha,scope=react cache-to: type=gha,mode=max,scope=react + + - name: Update docker-compose.yml image tag + run: | + sed -i -E "s#(image: ${DOCKERHUB_NAMESPACE}/deepguard-react:)[0-9]+\.[0-9]+\.[0-9]+#\1${{ steps.bump.outputs.new_tag }}#" docker-compose.yml + + - name: Open PR to bump docker-compose.yml + uses: peter-evans/create-pull-request@v8 + with: + commit-message: "๐Ÿณ Bump react image tag to ${{ steps.bump.outputs.new_tag }} in docker-compose.yml" + title: "๐Ÿณ Bump react image tag to ${{ steps.bump.outputs.new_tag }}" + body: | + Docker Bump & Push - React ์›Œํฌํ”Œ๋กœ์šฐ๊ฐ€ ์ƒˆ๋กœ pushํ•œ ์ด๋ฏธ์ง€ ํƒœ๊ทธ๋ฅผ `docker-compose.yml`์— ๋ฐ˜์˜ํ•ฉ๋‹ˆ๋‹ค. + + - `${{ env.DOCKERHUB_NAMESPACE }}/deepguard-react:${{ steps.bump.outputs.new_tag }}` + branch: bump/docker-compose-react + delete-branch: true diff --git a/.github/workflows/docker-bump-push-redis.yml b/.github/workflows/docker-bump-push-redis.yml index 1bfd5ef9..e150fd59 100644 --- a/.github/workflows/docker-bump-push-redis.yml +++ b/.github/workflows/docker-bump-push-redis.yml @@ -15,12 +15,16 @@ jobs: bump-and-push: runs-on: ubuntu-latest permissions: - contents: read + contents: write packages: write + pull-requests: write steps: - name: Checkout uses: actions/checkout@v7 + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v4 @@ -61,9 +65,26 @@ jobs: with: context: . file: docker/redis/Dockerfile + platforms: linux/amd64,linux/arm64 tags: | ${{ env.DOCKERHUB_NAMESPACE }}/deepguard-redis:${{ steps.bump.outputs.new_tag }} ${{ env.GHCR_NAMESPACE }}/deepguard-redis:${{ steps.bump.outputs.new_tag }} push: true cache-from: type=gha,scope=redis cache-to: type=gha,mode=max,scope=redis + + - name: Update docker-compose.yml image tag + run: | + sed -i -E "s#(image: ${DOCKERHUB_NAMESPACE}/deepguard-redis:)[0-9]+\.[0-9]+\.[0-9]+#\1${{ steps.bump.outputs.new_tag }}#" docker-compose.yml + + - name: Open PR to bump docker-compose.yml + uses: peter-evans/create-pull-request@v8 + with: + commit-message: "๐Ÿณ Bump redis image tag to ${{ steps.bump.outputs.new_tag }} in docker-compose.yml" + title: "๐Ÿณ Bump redis image tag to ${{ steps.bump.outputs.new_tag }}" + body: | + Docker Bump & Push - Redis ์›Œํฌํ”Œ๋กœ์šฐ๊ฐ€ ์ƒˆ๋กœ pushํ•œ ์ด๋ฏธ์ง€ ํƒœ๊ทธ๋ฅผ `docker-compose.yml`์— ๋ฐ˜์˜ํ•ฉ๋‹ˆ๋‹ค. + + - `${{ env.DOCKERHUB_NAMESPACE }}/deepguard-redis:${{ steps.bump.outputs.new_tag }}` + branch: bump/docker-compose-redis + delete-branch: true diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 2903c78f..60d5c6a3 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -1,6 +1,8 @@ name: Publish to PyPI # main์— pyproject.toml์ด push๋˜๋ฉด: README ์ด๋ฏธ์ง€ ๊ฒฝ๋กœ๋ฅผ ์ ˆ๋Œ€ URL๋กœ ์น˜ํ™˜ -> ๋นŒ๋“œ -> PyPI์— ๋ฐ”๋กœ ๋ฐฐํฌ. +# job์— environment๋ฅผ ์ง€์ •ํ•˜๋ฉด GitHub์ด ๋ฐฐํฌ(Deployment)๋ฅผ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•˜๊ณ  +# ์ง„ํ–‰ ์ƒํƒœ(in_progress/success/failure)๊นŒ์ง€ ๊ฐฑ์‹ ํ•ด์ค€๋‹ค. on: push: @@ -15,8 +17,12 @@ permissions: jobs: publish: runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/deepguard/ permissions: - id-token: write # PyPI Trusted Publishing(OIDC)์— ํ•„์š” - API ํ† ํฐ ๋ถˆํ•„์š” + id-token: write # PyPI Trusted Publishing(OIDC)์— ํ•„์š” - API ํ† ํฐ ๋ถˆํ•„์š” + deployments: write # GitHub Deployment ์ƒ์„ฑ/์ƒํƒœ ์—…๋ฐ์ดํŠธ์— ํ•„์š” steps: - name: Checkout uses: actions/checkout@v7 diff --git a/README.md b/README.md index 8320b37a..5334b301 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,7 @@ We provide training scripts for both `ms_eff_vit` and `ms_eff_gcvit`. We recomme | Model Variant | Test@Acc | Test@Auc | Test@log_loss | Download | Train Config | | ------------- | -------- | -------- | ---------- | -------- | ------ | | ms_eff_gcvit_b0 | 0.9655 | 0.9792 | 0.1237 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b0_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b0/celeb_df_v2.yaml) | -| ms_eff_gcvit_b5 | 0.9850 | 0.9974 | 0.0492 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b5_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b5/celeb_df_v2.yaml) | +| ms_eff_gcvit_b5 | 0.9792 | 0.9831 | 0.0692 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b5_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b5/celeb_df_v2.yaml) | ## ๐Ÿ’ป Model Usage @@ -330,6 +330,11 @@ Every checkpoint is also mirrored to the [Hugging Face Hub under `KoreaPeter`](h > ๐Ÿ’› Find a checkpoint useful? Please leave a โค๏ธ like on its model card โ€” it means a lot to us! +| Model | Celeb-DF-v2 | FaceForensics++ | KoDF | +| ----- | :---------: | :--------------: | :---: | +| โšก ms_eff_gcvit_b0 | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-celeb-df-v2&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-celeb-df-v2) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-ff-plus-plus&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-ff-plus-plus) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-kodf&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-kodf) | +| ๐Ÿ”ฅ ms_eff_gcvit_b5 | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-celeb-df-v2&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-celeb-df-v2) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-ff-plus-plus&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-ff-plus-plus) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-kodf&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-kodf) | + ```python from transformers import pipeline @@ -594,6 +599,8 @@ The jupyter notebooks themselves can be found under the tutorials folder in the | 6 | [`deepfake-detection-project-v4`](https://github.com/ameencaslam/deepfake-detection-project-v4) | Multiple Deep Learning Models by Ameen Caslam | | 7 | [`Awesome-Deepfake-Detection`](https://github.com/Daisy-Zhang/Awesome-Deepfakes-Detection) | A curated list of tools, papers and code by Daisy Zhang | | 8 | [`Pytorch-Grad-Cam`](https://github.com/jacobgil/pytorch-grad-cam) | Advanced Visual Explanations for PyTorch Models | +| 9 | [`DeepfakeBench`](https://github.com/SCLBD/DeepfakeBench) | A Comprehensive Benchmark of Deepfake Detection by SCLBD | +| 10 | [`Effort-AIGI-Detection`](https://github.com/YZY-stack/Effort-AIGI-Detection) | Official Implementation of Effort (ICML 2025 Oral) by YZY-stack | ## โš–๏ธ License diff --git a/README_JP.md b/README_JP.md index 882bb365..ef7dea9a 100644 --- a/README_JP.md +++ b/README_JP.md @@ -288,7 +288,7 @@ pip install -r requirements.txt | ใƒขใƒ‡ใƒซใƒใƒผใ‚ธใƒงใƒณ | Test@Acc | Test@Auc | Test@log_loss | ใƒ€ใ‚ฆใƒณใƒญใƒผใƒ‰ | ๅญฆ็ฟ’ใƒฌใ‚ทใƒ” | | ------------- | -------- | -------- | ---------- | -------- | ------ | | ms_eff_gcvit_b0 | 0.9655 | 0.9792 | 0.1237 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b0_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b0/celeb_df_v2.yaml) | -| ms_eff_gcvit_b5 | 0.9850 | 0.9974 | 0.0492 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b5_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b5/celeb_df_v2.yaml) | +| ms_eff_gcvit_b5 | 0.9792 | 0.9831 | 0.0692 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b5_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b5/celeb_df_v2.yaml) | ## ๐Ÿ’ป ใƒขใƒ‡ใƒซใฎไฝฟใ„ๆ–น @@ -327,6 +327,11 @@ model = timm.create_model("ms_eff_gcvit_b5", pretrained=True, dataset="kodf") > ๐Ÿ’› ใƒใ‚งใƒƒใ‚ฏใƒใ‚คใƒณใƒˆใŒๅฝนใซ็ซ‹ใฃใŸใ‚‰ใ€ใƒขใƒ‡ใƒซใ‚ซใƒผใƒ‰ใซ โค๏ธ ใ„ใ„ใญใ‚’ใŠ้ก˜ใ„ใ—ใพใ™ โ€” ใจใฆใ‚‚ๅŠฑใฟใซใชใ‚Šใพใ™! +| Model | Celeb-DF-v2 | FaceForensics++ | KoDF | +| ----- | :---------: | :--------------: | :---: | +| โšก ms_eff_gcvit_b0 | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-celeb-df-v2&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-celeb-df-v2) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-ff-plus-plus&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-ff-plus-plus) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-kodf&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-kodf) | +| ๐Ÿ”ฅ ms_eff_gcvit_b5 | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-celeb-df-v2&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-celeb-df-v2) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-ff-plus-plus&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-ff-plus-plus) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-kodf&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-kodf) | + ```python from transformers import pipeline @@ -586,6 +591,8 @@ JupyterใƒŽใƒผใƒˆใƒ–ใƒƒใ‚ฏใฏใ€gitใƒชใƒใ‚ธใƒˆใƒชใฎtutorialsใƒ•ใ‚ฉใƒซใƒ€ๅ†…ใซ | 6 | [`deepfake-detection-project-v4`](https://github.com/ameencaslam/deepfake-detection-project-v4) | Ameen Caslam ใซใ‚ˆใ‚‹่ค‡ๆ•ฐใฎใƒ‡ใ‚ฃใƒผใƒ—ใƒฉใƒผใƒ‹ใƒณใ‚ฐใƒขใƒ‡ใƒซ | | 7 | [`Awesome-Deepfake-Detection`](https://github.com/Daisy-Zhang/Awesome-Deepfakes-Detection) | Daisy Zhang ใŒใพใจใ‚ใŸใƒ„ใƒผใƒซใƒป่ซ–ๆ–‡ใƒปใ‚ณใƒผใƒ‰ใฎใ‚ญใƒฅใƒฌใƒผใ‚ทใƒงใƒณใƒชใ‚นใƒˆ | | 8 | [`Pytorch-Grad-Cam`](https://github.com/jacobgil/pytorch-grad-cam) | PyTorch ใƒขใƒ‡ใƒซใฎใŸใ‚ใฎ้ซ˜ๅบฆใช่ฆ–่ฆš็š„่ชฌๆ˜Žใƒ„ใƒผใƒซ | +| 9 | [`DeepfakeBench`](https://github.com/SCLBD/DeepfakeBench) | SCLBD ใซใ‚ˆใ‚‹ๅŒ…ๆ‹ฌ็š„ใชใƒ‡ใ‚ฃใƒผใƒ—ใƒ•ใ‚งใ‚คใ‚ฏๆคœๅ‡บใƒ™ใƒณใƒใƒžใƒผใ‚ฏ | +| 10 | [`Effort-AIGI-Detection`](https://github.com/YZY-stack/Effort-AIGI-Detection) | YZY-stack ใซใ‚ˆใ‚‹ Effort๏ผˆICML 2025 Oral๏ผ‰ใฎๅ…ฌๅผๅฎŸ่ฃ… | ## โš–๏ธ ใƒฉใ‚คใ‚ปใƒณใ‚น diff --git a/README_KR.md b/README_KR.md index 3f0a8464..decec284 100644 --- a/README_KR.md +++ b/README_KR.md @@ -288,7 +288,7 @@ pip install -r requirements.txt | ๋ชจ๋ธ ๋ฒ„์ „ | Test@Acc | Test@Auc | Test@log_loss | ๋‹ค์šด๋กœ๋“œ | ํ•™์Šต ๋ ˆ์‹œํ”ผ | | ------------- | -------- | -------- | ---------- | -------- | ------ | | ms_eff_gcvit_b0 | 0.9655 | 0.9792 | 0.1237 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b0_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b0/celeb_df_v2.yaml) | -| ms_eff_gcvit_b5 | 0.9850 | 0.9974 | 0.0492 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b5_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b5/celeb_df_v2.yaml) | +| ms_eff_gcvit_b5 | 0.9792 | 0.9831 | 0.0692 | [model](https://github.com/HanMoonSub/DeepGuard/releases/download/v0.2.0/ms_eff_gcvit_b5_kodf.bin) | [recipe](deepguard/config/ms_eff_gcvit_b5/celeb_df_v2.yaml) | ## ๐Ÿ’ป ๋ชจ๋ธ ์‚ฌ์šฉ๋ฒ• @@ -327,6 +327,11 @@ model = timm.create_model("ms_eff_gcvit_b5", pretrained=True, dataset="kodf") > ๐Ÿ’› ์ฒดํฌํฌ์ธํŠธ๊ฐ€ ์œ ์šฉํ•˜์…จ๋‹ค๋ฉด ๋ชจ๋ธ ์นด๋“œ์— โค๏ธ ์ข‹์•„์š”๋ฅผ ๋‚จ๊ฒจ์ฃผ์„ธ์š” โ€” ํฐ ํž˜์ด ๋ฉ๋‹ˆ๋‹ค! +| Model | Celeb-DF-v2 | FaceForensics++ | KoDF | +| ----- | :---------: | :--------------: | :---: | +| โšก ms_eff_gcvit_b0 | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-celeb-df-v2&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-celeb-df-v2) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-ff-plus-plus&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-ff-plus-plus) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b0-kodf&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b0-kodf) | +| ๐Ÿ”ฅ ms_eff_gcvit_b5 | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-celeb-df-v2&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-celeb-df-v2) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-ff-plus-plus&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-ff-plus-plus) | [![](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fhuggingface.co%2Fapi%2Fmodels%2FKoreaPeter%2Fms-eff-gcvit-deepfake-b5-kodf&query=%24.downloads&label=downloads&color=FFD21E&logoColor=black)](https://huggingface.co/KoreaPeter/ms-eff-gcvit-deepfake-b5-kodf) | + ```python from transformers import pipeline @@ -586,6 +591,8 @@ result = explainer.display_heatmap_bbox_on_image( | 6 | [`deepfake-detection-project-v4`](https://github.com/ameencaslam/deepfake-detection-project-v4) | Ameen Caslam์˜ ๋‹ค์ค‘ ๋”ฅ๋Ÿฌ๋‹ ๋ชจ๋ธ | | 7 | [`Awesome-Deepfake-Detection`](https://github.com/Daisy-Zhang/Awesome-Deepfakes-Detection) | Daisy Zhang์ด ์ •๋ฆฌํ•œ ๋„๊ตฌ, ๋…ผ๋ฌธ, ์ฝ”๋“œ ํ๋ ˆ์ด์…˜ ๋ชฉ๋ก | | 8 | [`Pytorch-Grad-Cam`](https://github.com/jacobgil/pytorch-grad-cam) | PyTorch ๋ชจ๋ธ์„ ์œ„ํ•œ ๊ณ ๊ธ‰ ์‹œ๊ฐ์  ์„ค๋ช… ๋„๊ตฌ | +| 9 | [`DeepfakeBench`](https://github.com/SCLBD/DeepfakeBench) | SCLBD์˜ ํฌ๊ด„์ ์ธ ๋”ฅํŽ˜์ดํฌ ํƒ์ง€ ๋ฒค์น˜๋งˆํฌ | +| 10 | [`Effort-AIGI-Detection`](https://github.com/YZY-stack/Effort-AIGI-Detection) | YZY-stack์˜ Effort(ICML 2025 Oral) ๊ณต์‹ ๊ตฌํ˜„์ฒด | ## โš–๏ธ ๋ผ์ด์„ ์Šค diff --git a/client/Dockerfile b/client/Dockerfile index 67aaadfc..8866f7c4 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -1,4 +1,4 @@ -FROM node:26.7-alpine AS build +FROM node:26.9-alpine AS build WORKDIR /app @@ -9,7 +9,7 @@ COPY . . ENV GENERATE_SOURCEMAP=false RUN npm run build -FROM nginx:1.30-alpine +FROM nginx:1.31-alpine COPY --from=build /app/build /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf diff --git a/client/package-lock.json b/client/package-lock.json index c244b03c..e7fe3cba 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -8,17 +8,17 @@ "name": "client", "version": "0.1.0", "dependencies": { - "@testing-library/dom": "^10.4.1", + "@testing-library/dom": "^10.4.2", "@testing-library/jest-dom": "^6.9.1", - "@testing-library/react": "^16.3.2", - "@testing-library/user-event": "^13.5.0", - "axios": "^1.13.6", + "@testing-library/react": "^16.3.3", + "@testing-library/user-event": "^14.6.6", + "axios": "^1.20.0", "react": "^19.2.4", "react-dom": "^19.2.4", - "react-router-dom": "^7.13.1", + "react-router-dom": "^7.18.4", "react-scripts": "5.0.1", "typescript": "^4.9.5", - "web-vitals": "^2.1.4" + "web-vitals": "^6.2.2" }, "devDependencies": { "http-proxy-middleware": "^3.0.5" @@ -3367,9 +3367,9 @@ } }, "node_modules/@testing-library/dom": { - "version": "10.4.1", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", - "integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.2.tgz", + "integrity": "sha512-yzr2S9HyAIdhz2/6qHgbs665Q7PKVcDF05vsOlHPxG1mo36gKVesdYVeDLnXgfjJ03CrKRk08knc6+E/9m8v2Q==", "license": "MIT", "dependencies": { "@babel/code-frame": "^7.10.4", @@ -3411,9 +3411,9 @@ "license": "MIT" }, "node_modules/@testing-library/react": { - "version": "16.3.2", - "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.3.2.tgz", - "integrity": "sha512-XU5/SytQM+ykqMnAnvB2umaJNIOsLF3PVv//1Ew4CTcpz0/BRyy/af40qqrt7SjKpDdT1saBMc42CUok5gaw+g==", + "version": "16.3.3", + "resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.3.3.tgz", + "integrity": "sha512-Uo193NgQbPMz6lrrhtRQQFcMC6Re/ELLFbbuVL30WDlZxlpZf9/lMHTAVxPRLw1q1iu9OJmR1c2BLiENRstdBg==", "license": "MIT", "dependencies": { "@babel/runtime": "^7.12.5" @@ -3438,15 +3438,12 @@ } }, "node_modules/@testing-library/user-event": { - "version": "13.5.0", - "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-13.5.0.tgz", - "integrity": "sha512-5Kwtbo3Y/NowpkbRuSepbyMFkZmHgD+vPzYB/RJ4oxt5Gj/avFFBYjhw27cqSVPVw/3a67NK1PbiIr9k4Gwmdg==", + "version": "14.6.6", + "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-14.6.6.tgz", + "integrity": "sha512-Jbs9FpkkIDw8FgSc6kOVsOv8JuuqGAL7J4X1oot77JxAoDlkNn2GRkd0aYRVuQ+pVQAiHWVkE4rX/dkF5fBiCw==", "license": "MIT", - "dependencies": { - "@babel/runtime": "^7.12.5" - }, "engines": { - "node": ">=10", + "node": ">=12", "npm": ">=6" }, "peerDependencies": { @@ -4803,9 +4800,9 @@ } }, "node_modules/axios": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.19.0.tgz", - "integrity": "sha512-ht/iuYZXEjFxLH/Hkezgd7m6JKlHHXEUSneaDz8uZe1Gj5QZtCnpyDsckvAiEnT89OEbCLmnte4R4sn7P0EKFw==", + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.20.0.tgz", + "integrity": "sha512-r8aOh8j9cGKpgQAqpzrUHnSIc6a59Y3Xf/cv8sy1DrHCkZHzQGEuoq1tARk6qSyDdtQGSDgpb9kFlruzPvrgwg==", "license": "MIT", "dependencies": { "follow-redirects": "^1.16.0", @@ -13905,9 +13902,9 @@ } }, "node_modules/react-router": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.2.tgz", - "integrity": "sha512-aUVMjFm3GAPTTZL7oYr5E7ETiqfQCHRLH+B+5afnICvf0r7kkK4eR6SMuwbSTJw/7t+12khT/Kahij49fqOCIg==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-7.18.4.tgz", + "integrity": "sha512-PUPQcMhMGRAslLcvtlPz/kmzBEWPhLdgLFrL7pLNepBL6dX0lWj4WD2cUYVgYCuT3jxvghYFg81cDTj44DhetQ==", "license": "MIT", "dependencies": { "cookie": "^1.0.1", @@ -13927,12 +13924,12 @@ } }, "node_modules/react-router-dom": { - "version": "7.18.2", - "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.2.tgz", - "integrity": "sha512-AIKJ/jgGlFb3EbfCXk5Gzshiwt+l3mqbCrNjmEWMMjqQxNJ3svBa6bgzFyCC2Sw3RA0VWF1kg3uQf2OFhxb8hw==", + "version": "7.18.4", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-7.18.4.tgz", + "integrity": "sha512-yrfmJHIpDG7taCpqKjT1G5B6q3O2K+RN8/fgNf0lTjCwiPbQ0ei6vXX9ZjQR+7ld8Tr7Z5xmyMnZ8YJrphWQUw==", "license": "MIT", "dependencies": { - "react-router": "7.18.2" + "react-router": "7.18.4" }, "engines": { "node": ">=20.0.0" @@ -15782,23 +15779,6 @@ } } }, - "node_modules/tailwindcss/node_modules/yaml": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz", - "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==", - "license": "ISC", - "optional": true, - "peer": true, - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - }, - "funding": { - "url": "https://github.com/sponsors/eemeli" - } - }, "node_modules/tapable": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", @@ -16619,9 +16599,9 @@ } }, "node_modules/web-vitals": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-2.1.4.tgz", - "integrity": "sha512-sVWcwhU5mX6crfI5Vd2dC4qchyTqxV8URinzt25XqVh+bHEPGH4C3NPrNionCP7Obx59wrYEbNlw4Z8sjALzZg==", + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/web-vitals/-/web-vitals-6.2.2.tgz", + "integrity": "sha512-oto5x6dLEgrRqfcWed+pZEUb2q6ikbFmqF54CRDhI/QGbn+qxC49b4C4OkbH+kb9C3a8shpFD3SgR9kRcs80ZQ==", "license": "Apache-2.0" }, "node_modules/webidl-conversions": { diff --git a/client/package.json b/client/package.json index fe2d4290..5af13888 100644 --- a/client/package.json +++ b/client/package.json @@ -3,17 +3,17 @@ "version": "0.1.0", "private": true, "dependencies": { - "@testing-library/dom": "^10.4.1", + "@testing-library/dom": "^10.4.2", "@testing-library/jest-dom": "^6.9.1", - "@testing-library/react": "^16.3.2", - "@testing-library/user-event": "^13.5.0", - "axios": "^1.13.6", + "@testing-library/react": "^16.3.3", + "@testing-library/user-event": "^14.6.6", + "axios": "^1.20.0", "react": "^19.2.4", "react-dom": "^19.2.4", - "react-router-dom": "^7.13.1", + "react-router-dom": "^7.18.4", "react-scripts": "5.0.1", "typescript": "^4.9.5", - "web-vitals": "^2.1.4" + "web-vitals": "^6.2.2" }, "scripts": { "start": "react-scripts start", diff --git a/deepguard/MS_EffGCViT.md b/deepguard/MS_EffGCViT.md index bfaee2cd..169740e9 100644 --- a/deepguard/MS_EffGCViT.md +++ b/deepguard/MS_EffGCViT.md @@ -18,13 +18,15 @@ This model is a **frame-level** and **spatial-domain** architecture, designed to ## ๐Ÿ’ฅ News ๐Ÿ’ฅ - -- [**02.28.2026**] ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ We have released **KoDF** fine-tuned **MS-Eff-GCViT B5** model weightes for **384X384** -- [**02.28.2026**] ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ We have released **KoDF** fine-tuned **MS-Eff-GCViT B0** model weightes for **224X224** -- [**02.03.2026**] ๐Ÿ”ฅ๐Ÿ”ฅ We have released **FaceForensics++** fine-tuned **MS-Eff-GCViT B5** model weightes for **384X384** -- [**02.03.2026**] ๐Ÿ”ฅ๐Ÿ”ฅ We have released **Celeb DF(V2)** fine-tuned **MS-Eff-GCViT B5** model weightes for **384X384** -- [**02.03.2026**] ๐Ÿ”ฅ We have released **FaceForensics++** fine-tuned **MS-Eff-GCViT B0** model weightes for **224X224** -- [**02.03.2026**] ๐Ÿ”ฅ We have released **Celeb DF(V2)** fine-tuned **MS-Eff-GCViT B0** model weightes for **224X224** +- [**09.05.2026**] ๐Ÿ”ฅ Released **HIGH-Eff-GCVIT-B5** (384X384) weights for **Celeb DF(V2)**, **FaceForensics++**, **KoDF** +- [**09.05.2026**] ๐Ÿ”ฅ Released **HIGH-Eff-GCVIT-B0** (224X224) weights for **Celeb DF(V2)**, **FaceForensics++**, **KoDF** +- [**09.04.2026**] ๐Ÿ”ฅ Released **LOW-Eff-GCVIT-B5** (384X384) weights for **Celeb DF(V2)**, **FaceForensics++**, **KoDF** +- [**09.04.2026**] ๐Ÿ”ฅ Released **LOW-Eff-GCVIT-B0** (224X224) weights for **Celeb DF(V2)**, **FaceForensics++**, **KoDF** +- [**09.03.2026**] ๐Ÿ”ฅ Released **Eff-B5** (384X384) weights for **Celeb DF(V2)**, **FaceForensics++**, **KoDF** +- [**09.03.2026**] ๐Ÿ”ฅ Released **Eff-B0** (224X224) weights for **Celeb DF(V2)**, **FaceForensics++**, **KoDF** +- [**02.28.2026**] ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ Released **MS-Eff-GCViT-B5** (384X384) and **MS-Eff-GCViT-B0** (224X224) weights for **KoDF** +- [**02.03.2026**] ๐Ÿ”ฅ๐Ÿ”ฅ Released **MS-Eff-GCViT-B5** (384X384) weights for **Celeb DF(V2)**, **FaceForensics++** +- [**02.03.2026**] ๐Ÿ”ฅ Released **MS-Eff-GCViT-B0** (224X224) weights for **Celeb DF(V2)**, **FaceForensics++** ## Model Performance diff --git a/deepguard/config/eff_b0/celeb_df_v2.yaml b/deepguard/config/eff_b0/celeb_df_v2.yaml new file mode 100644 index 00000000..8c8d1dd3 --- /dev/null +++ b/deepguard/config/eff_b0/celeb_df_v2.yaml @@ -0,0 +1,46 @@ +dataset: "Celeb_DF(V2)" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: EfficientNet-only baseline (no GCViT branch) ===== + use_low: False + use_high: False + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/eff_b0/ff++.yaml b/deepguard/config/eff_b0/ff++.yaml new file mode 100644 index 00000000..9892d801 --- /dev/null +++ b/deepguard/config/eff_b0/ff++.yaml @@ -0,0 +1,46 @@ +dataset: "FaceForensics++" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: EfficientNet-only baseline (no GCViT branch) ===== + use_low: False + use_high: False + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/eff_b0/kodf.yaml b/deepguard/config/eff_b0/kodf.yaml new file mode 100644 index 00000000..fd16023a --- /dev/null +++ b/deepguard/config/eff_b0/kodf.yaml @@ -0,0 +1,46 @@ +dataset: "KODF" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: EfficientNet-only baseline (no GCViT branch) ===== + use_low: False + use_high: False + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.0 + + # DataLoader + train_bs: 64 + valid_bs: 128 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/eff_b5/celeb_df_v2.yaml b/deepguard/config/eff_b5/celeb_df_v2.yaml new file mode 100644 index 00000000..2c9c59ca --- /dev/null +++ b/deepguard/config/eff_b5/celeb_df_v2.yaml @@ -0,0 +1,46 @@ +dataset: "Celeb_DF(V2)" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: EfficientNet-only baseline (no GCViT branch) ===== + use_low: False + use_high: False + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/eff_b5/ff++.yaml b/deepguard/config/eff_b5/ff++.yaml new file mode 100644 index 00000000..73c4a9d1 --- /dev/null +++ b/deepguard/config/eff_b5/ff++.yaml @@ -0,0 +1,46 @@ +dataset: "FaceForensics++" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: EfficientNet-only baseline (no GCViT branch) ===== + use_low: False + use_high: False + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-5 + h_block_lr: 8e-5 + l_block_lr: 2e-5 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 2e-4 + h_block_wd: 1e-4 + l_block_wd: 2e-4 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/eff_b5/kodf.yaml b/deepguard/config/eff_b5/kodf.yaml new file mode 100644 index 00000000..36e7272e --- /dev/null +++ b/deepguard/config/eff_b5/kodf.yaml @@ -0,0 +1,46 @@ +dataset: "KODF" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: EfficientNet-only baseline (no GCViT branch) ===== + use_low: False + use_high: False + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.125 + cutout_prob: 0.0 + + # DataLoader + train_bs: 64 + valid_bs: 128 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/high_eff_gcvit_b0/celeb_df_v2.yaml b/deepguard/config/high_eff_gcvit_b0/celeb_df_v2.yaml new file mode 100644 index 00000000..a6e17e6f --- /dev/null +++ b/deepguard/config/high_eff_gcvit_b0/celeb_df_v2.yaml @@ -0,0 +1,60 @@ +dataset: "Celeb_DF(V2)" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: high-level GCViT branch only ===== + use_low: False + use_high: True + + # ===== Transformer Dimensions (High) ===== + h_dim: 256 # Dimension for high-block transformer + h_depths: [4] # Number of transformer layers (High) + + # ===== Attention Settings (High) ===== + h_windows: [7] # Window Size for Attention (High) + h_heads: [4] # Multi Head Attention (High) + h_ratio: [4] # MLP expansion ratio (High) + + # ===== Reqularization (Dropout, High) ===== + h_drop: 0.05 # Pos dropout, Mlp dropout, Proj dropout (High) + h_attn_drop: 0 # Attention Dropout (High) + h_drop_path: 0.05 # Stochastic depth rate (High) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/high_eff_gcvit_b0/ff++.yaml b/deepguard/config/high_eff_gcvit_b0/ff++.yaml new file mode 100644 index 00000000..aa00b462 --- /dev/null +++ b/deepguard/config/high_eff_gcvit_b0/ff++.yaml @@ -0,0 +1,60 @@ +dataset: "FaceForensics++" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: high-level GCViT branch only ===== + use_low: False + use_high: True + + # ===== Transformer Dimensions (High) ===== + h_dim: 256 # Dimension for high-block transformer + h_depths: [4] # Number of transformer layers (High) + + # ===== Attention Settings (High) ===== + h_windows: [7] # Window Size for Attention (High) + h_heads: [4] # Multi Head Attention (High) + h_ratio: [4] # MLP expansion ratio (High) + + # ===== Reqularization (Dropout, High) ===== + h_drop: 0.05 # Pos dropout, Mlp dropout, Proj dropout (High) + h_attn_drop: 0 # Attention Dropout (High) + h_drop_path: 0.05 # Stochastic depth rate (High) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/high_eff_gcvit_b0/kodf.yaml b/deepguard/config/high_eff_gcvit_b0/kodf.yaml new file mode 100644 index 00000000..8e919657 --- /dev/null +++ b/deepguard/config/high_eff_gcvit_b0/kodf.yaml @@ -0,0 +1,60 @@ +dataset: "KODF" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: high-level GCViT branch only ===== + use_low: False + use_high: True + + # ===== Transformer Dimensions (High) ===== + h_dim: 256 # Dimension for high-block transformer + h_depths: [4] # Number of transformer layers (High) + + # ===== Attention Settings (High) ===== + h_windows: [7] # Window Size for Attention (High) + h_heads: [4] # Multi Head Attention (High) + h_ratio: [4] # MLP expansion ratio (High) + + # ===== Reqularization (Dropout, High) ===== + h_drop: 0.05 # Pos dropout, Mlp dropout, Proj dropout (High) + h_attn_drop: 0 # Attention Dropout (High) + h_drop_path: 0.05 # Stochastic depth rate (High) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.0 + + # DataLoader + train_bs: 64 + valid_bs: 128 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/high_eff_gcvit_b5/celeb_df_v2.yaml b/deepguard/config/high_eff_gcvit_b5/celeb_df_v2.yaml new file mode 100644 index 00000000..9498dbda --- /dev/null +++ b/deepguard/config/high_eff_gcvit_b5/celeb_df_v2.yaml @@ -0,0 +1,60 @@ +dataset: "Celeb_DF(V2)" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: high-level GCViT branch only ===== + use_low: False + use_high: True + + # ===== Transformer Dimensions (High) ===== + h_dim: 512 # Dimension for high-block transformer + h_depths: [6] # Number of transformer layers (High) + + # ===== Attention Settings (High) ===== + h_windows: [12] # Window Size for Attention (High) + h_heads: [16] # Multi Head Attention (High) + h_ratio: [3] # MLP expansion ratio (High) + + # ===== Reqularization (Dropout, High) ===== + h_drop: 0.1 # Pos dropout, Mlp dropout, Proj dropout (High) + h_attn_drop: 0.0 # Attention Dropout (High) + h_drop_path: 0.1 # Stochastic depth rate (High) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/high_eff_gcvit_b5/ff++.yaml b/deepguard/config/high_eff_gcvit_b5/ff++.yaml new file mode 100644 index 00000000..9fc5330f --- /dev/null +++ b/deepguard/config/high_eff_gcvit_b5/ff++.yaml @@ -0,0 +1,60 @@ +dataset: "FaceForensics++" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: high-level GCViT branch only ===== + use_low: False + use_high: True + + # ===== Transformer Dimensions (High) ===== + h_dim: 512 # Dimension for high-block transformer + h_depths: [6] # Number of transformer layers (High) + + # ===== Attention Settings (High) ===== + h_windows: [12] # Window Size for Attention (High) + h_heads: [16] # Multi Head Attention (High) + h_ratio: [3] # MLP expansion ratio (High) + + # ===== Reqularization (Dropout, High) ===== + h_drop: 0.1 # Pos dropout, Mlp dropout, Proj dropout (High) + h_attn_drop: 0.0 # Attention Dropout (High) + h_drop_path: 0.1 # Stochastic depth rate (High) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-5 + h_block_lr: 8e-5 + l_block_lr: 2e-5 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 2e-4 + h_block_wd: 1e-4 + l_block_wd: 2e-4 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/high_eff_gcvit_b5/kodf.yaml b/deepguard/config/high_eff_gcvit_b5/kodf.yaml new file mode 100644 index 00000000..43aae68e --- /dev/null +++ b/deepguard/config/high_eff_gcvit_b5/kodf.yaml @@ -0,0 +1,60 @@ +dataset: "KODF" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index (unused, use_low=False) + h_block_idx: 6 # High-level feature stage index + + # ===== Ablation: high-level GCViT branch only ===== + use_low: False + use_high: True + + # ===== Transformer Dimensions (High) ===== + h_dim: 512 # Dimension for high-block transformer + h_depths: [6] # Number of transformer layers (High) + + # ===== Attention Settings (High) ===== + h_windows: [12] # Window Size for Attention (High) + h_heads: [16] # Multi Head Attention (High) + h_ratio: [3] # MLP expansion ratio (High) + + # ===== Reqularization (Dropout, High) ===== + h_drop: 0.1 # Pos dropout, Mlp dropout, Proj dropout (High) + h_attn_drop: 0.0 # Attention Dropout (High) + h_drop_path: 0.1 # Stochastic depth rate (High) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.125 + cutout_prob: 0.0 + + # DataLoader + train_bs: 64 + valid_bs: 128 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/low_eff_gcvit_b0/celeb_df_v2.yaml b/deepguard/config/low_eff_gcvit_b0/celeb_df_v2.yaml new file mode 100644 index 00000000..3ffd7d51 --- /dev/null +++ b/deepguard/config/low_eff_gcvit_b0/celeb_df_v2.yaml @@ -0,0 +1,60 @@ +dataset: "Celeb_DF(V2)" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index + h_block_idx: 6 # High-level feature stage index (unused, use_high=False) + + # ===== Ablation: low-level GCViT branch only ===== + use_low: True + use_high: False + + # ===== Transformer Dimensions (Low) ===== + l_dim: 24 # Dimension for low-block transformer + l_depths: [2,2,4,2] # Number of transformer layers (Low) + + # ===== Attention Settings (Low) ===== + l_windows: [7,7,14,7] # Window Size for Attention (Low) + l_heads: [1,2,4,8] # Multi Head Attention (Low) + l_ratio: [4,4,4,4] # MLP expansion ratio (Low) + + # ===== Reqularization (Dropout, Low) ===== + l_drop: 0 # Pos dropout, Mlp dropout, Proj dropout (Low) + l_attn_drop: 0.05 # Attention Dropout (Low) + l_drop_path: 0.1 # Stochastic depth rate (Low) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/low_eff_gcvit_b0/ff++.yaml b/deepguard/config/low_eff_gcvit_b0/ff++.yaml new file mode 100644 index 00000000..d8c5b885 --- /dev/null +++ b/deepguard/config/low_eff_gcvit_b0/ff++.yaml @@ -0,0 +1,60 @@ +dataset: "FaceForensics++" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index + h_block_idx: 6 # High-level feature stage index (unused, use_high=False) + + # ===== Ablation: low-level GCViT branch only ===== + use_low: True + use_high: False + + # ===== Transformer Dimensions (Low) ===== + l_dim: 24 # Dimension for low-block transformer + l_depths: [2,2,4,2] # Number of transformer layers (Low) + + # ===== Attention Settings (Low) ===== + l_windows: [7,7,14,7] # Window Size for Attention (Low) + l_heads: [1,2,4,8] # Multi Head Attention (Low) + l_ratio: [4,4,4,4] # MLP expansion ratio (Low) + + # ===== Reqularization (Dropout, Low) ===== + l_drop: 0 # Pos dropout, Mlp dropout, Proj dropout (Low) + l_attn_drop: 0.05 # Attention Dropout (Low) + l_drop_path: 0.1 # Stochastic depth rate (Low) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/low_eff_gcvit_b0/kodf.yaml b/deepguard/config/low_eff_gcvit_b0/kodf.yaml new file mode 100644 index 00000000..f4175206 --- /dev/null +++ b/deepguard/config/low_eff_gcvit_b0/kodf.yaml @@ -0,0 +1,60 @@ +dataset: "KODF" + +model: + model_name: "tf_efficientnet_b0.ns_jft_in1k" + img_size: [224,224] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index + h_block_idx: 6 # High-level feature stage index (unused, use_high=False) + + # ===== Ablation: low-level GCViT branch only ===== + use_low: True + use_high: False + + # ===== Transformer Dimensions (Low) ===== + l_dim: 24 # Dimension for low-block transformer + l_depths: [2,2,4,2] # Number of transformer layers (Low) + + # ===== Attention Settings (Low) ===== + l_windows: [7,7,14,7] # Window Size for Attention (Low) + l_heads: [1,2,4,8] # Multi Head Attention (Low) + l_ratio: [4,4,4,4] # MLP expansion ratio (Low) + + # ===== Reqularization (Dropout, Low) ===== + l_drop: 0 # Pos dropout, Mlp dropout, Proj dropout (Low) + l_attn_drop: 0.05 # Attention Dropout (Low) + l_drop_path: 0.1 # Stochastic depth rate (Low) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.0 + + # DataLoader + train_bs: 64 + valid_bs: 128 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/low_eff_gcvit_b5/celeb_df_v2.yaml b/deepguard/config/low_eff_gcvit_b5/celeb_df_v2.yaml new file mode 100644 index 00000000..c37118d2 --- /dev/null +++ b/deepguard/config/low_eff_gcvit_b5/celeb_df_v2.yaml @@ -0,0 +1,60 @@ +dataset: "Celeb_DF(V2)" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index + h_block_idx: 6 # High-level feature stage index (unused, use_high=False) + + # ===== Ablation: low-level GCViT branch only ===== + use_low: True + use_high: False + + # ===== Transformer Dimensions (Low) ===== + l_dim: 48 # Dimension for low-block transformer + l_depths: [2,2,6,2] # Number of transformer layers (Low) + + # ===== Attention Settings (Low) ===== + l_windows: [12,12,24,12] # Window Size for Attention (Low) + l_heads: [2,4,8,16] # Multi Head Attention (Low) + l_ratio: [3,3,3,3] # MLP expansion ratio (Low) + + # ===== Reqularization (Dropout, Low) ===== + l_drop: 0.0 # Pos dropout, Mlp dropout, Proj dropout (Low) + l_attn_drop: 0.1 # Attention Dropout (Low) + l_drop_path: 0.15 # Stochastic depth rate (Low) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/low_eff_gcvit_b5/ff++.yaml b/deepguard/config/low_eff_gcvit_b5/ff++.yaml new file mode 100644 index 00000000..419b59d1 --- /dev/null +++ b/deepguard/config/low_eff_gcvit_b5/ff++.yaml @@ -0,0 +1,60 @@ +dataset: "FaceForensics++" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index + h_block_idx: 6 # High-level feature stage index (unused, use_high=False) + + # ===== Ablation: low-level GCViT branch only ===== + use_low: True + use_high: False + + # ===== Transformer Dimensions (Low) ===== + l_dim: 48 # Dimension for low-block transformer + l_depths: [2,2,6,2] # Number of transformer layers (Low) + + # ===== Attention Settings (Low) ===== + l_windows: [12,12,24,12] # Window Size for Attention (Low) + l_heads: [2,4,8,16] # Multi Head Attention (Low) + l_ratio: [3,3,3,3] # MLP expansion ratio (Low) + + # ===== Reqularization (Dropout, Low) ===== + l_drop: 0.0 # Pos dropout, Mlp dropout, Proj dropout (Low) + l_attn_drop: 0.1 # Attention Dropout (Low) + l_drop_path: 0.15 # Stochastic depth rate (Low) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.25 + cutout_prob: 0.5 + + # DataLoader + train_bs: 16 + valid_bs: 32 + + # Learning Rate + backbone_lr: 5e-5 + h_block_lr: 8e-5 + l_block_lr: 2e-5 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 2e-4 + h_block_wd: 1e-4 + l_block_wd: 2e-4 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/config/low_eff_gcvit_b5/kodf.yaml b/deepguard/config/low_eff_gcvit_b5/kodf.yaml new file mode 100644 index 00000000..d1365711 --- /dev/null +++ b/deepguard/config/low_eff_gcvit_b5/kodf.yaml @@ -0,0 +1,60 @@ +dataset: "KODF" + +model: + model_name: "tf_efficientnet_b5.ns_jft_in1k" + img_size: [384,384] + + # ===== Feature Extraction Blocks ===== + l_block_idx: 1 # Low-level feature stage index + h_block_idx: 6 # High-level feature stage index (unused, use_high=False) + + # ===== Ablation: low-level GCViT branch only ===== + use_low: True + use_high: False + + # ===== Transformer Dimensions (Low) ===== + l_dim: 48 # Dimension for low-block transformer + l_depths: [2,2,6,2] # Number of transformer layers (Low) + + # ===== Attention Settings (Low) ===== + l_windows: [12,12,24,12] # Window Size for Attention (Low) + l_heads: [2,4,8,16] # Multi Head Attention (Low) + l_ratio: [3,3,3,3] # MLP expansion ratio (Low) + + # ===== Reqularization (Dropout, Low) ===== + l_drop: 0.0 # Pos dropout, Mlp dropout, Proj dropout (Low) + l_attn_drop: 0.1 # Attention Dropout (Low) + l_drop_path: 0.15 # Stochastic depth rate (Low) + +train: + epochs: 10 + use_amp: True # Mixed Precision Training + n_accumulate: 1 # Gradient Accumulation steps + optimizer: "AdamW" + loss: "BCEWithLogitsLoss" + scheduler: "CosineAnnealingLR" + + # Albumentation + mixup_alpha: 0.4 + mixup_prob: 0.125 + cutout_prob: 0.0 + + # DataLoader + train_bs: 64 + valid_bs: 128 + + # Learning Rate + backbone_lr: 5e-4 + h_block_lr: 2e-4 + l_block_lr: 1e-4 + head_lr: 1e-3 + + # Weight Decay + backbone_wd: 1e-3 + h_block_wd: 5e-4 + l_block_wd: 1e-3 + head_wd: 1e-5 + + # Early Stopping + patience: 3 + min_delta: 0.001 diff --git a/deepguard/models/ms_eff_gcvit.py b/deepguard/models/ms_eff_gcvit.py index 5f29e936..3577d327 100644 --- a/deepguard/models/ms_eff_gcvit.py +++ b/deepguard/models/ms_eff_gcvit.py @@ -22,6 +22,24 @@ def _cfg(url='', **kwargs): } default_cfgs = { + 'eff_b0': _cfg( + input_size = (3,224,224) + ), + 'eff_b5': _cfg( + input_size = (3,384,384) + ), + 'low_eff_gcvit_b0': _cfg( + input_size = (3,224,224) + ), + 'low_eff_gcvit_b5': _cfg( + input_size = (3,384,384) + ), + 'high_eff_gcvit_b0': _cfg( + input_size = (3,224,224) + ), + 'high_eff_gcvit_b5': _cfg( + input_size = (3,384,384) + ), 'ms_eff_gcvit_b0': _cfg( input_size = (3,224,224) ), @@ -31,6 +49,36 @@ def _cfg(url='', **kwargs): } weight_registry = { + 'eff_b0': { + 'celeb_df_v2': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/eff_b0_celeb_df_v2.bin', + 'ff++': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/eff_b0_ff++.bin', + 'kodf': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/eff_b0_kodf.bin' + }, + 'eff_b5': { + 'celeb_df_v2': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/eff_b5_celeb_df_v2.bin', + 'ff++': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/eff_b5_ff++.bin', + 'kodf': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/eff_b5_kodf.bin' + }, + 'low_eff_gcvit_b0': { + 'celeb_df_v2': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/low_eff_gcvit_b0_celeb_df_v2.bin', + 'ff++': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/low_eff_gcvit_b0_ff++.bin', + 'kodf': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/low_eff_gcvit_b0_kodf.bin' + }, + 'low_eff_gcvit_b5': { + 'celeb_df_v2': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/low_eff_gcvit_b5_celeb_df_v2.bin', + 'ff++': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/low_eff_gcvit_b5_ff++.bin', + 'kodf': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/low_eff_gcvit_b5_kodf.bin' + }, + 'high_eff_gcvit_b0': { + 'celeb_df_v2': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/high_eff_gcvit_b0_celeb_df_v2.bin', + 'ff++': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/high_eff_gcvit_b0_ff++.bin', + 'kodf': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/high_eff_gcvit_b0_kodf.bin' + }, + 'high_eff_gcvit_b5': { + 'celeb_df_v2': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/high_eff_gcvit_b5_celeb_df_v2.bin', + 'ff++': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/high_eff_gcvit_b5_ff++.bin', + 'kodf': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v1.1.0/high_eff_gcvit_b5_kodf.bin' + }, 'ms_eff_gcvit_b0': { 'celeb_df_v2': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v0.1.0/ms_eff_gcvit_b0_celeb_df_v2.bin', 'ff++': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v0.1.0/ms_eff_gcvit_b0_ff++.bin', @@ -43,13 +91,19 @@ def _cfg(url='', **kwargs): } } +def available_models() -> List[str]: + """Returns the names of available MS-EffGCViT models""" + return list(weight_registry.keys()) + class MultiScaleEffGCViT(nn.Module): def __init__( self, model_name: str, img_size: List[int], - l_block_idx: int = 1, + l_block_idx: int = 1, h_block_idx: int = 6, + use_low: bool = True, + use_high: bool = True, l_dim: int = 24, h_dim: int = 256, l_depths: List[int] = [2,2,4,2], @@ -75,6 +129,10 @@ def __init__( img_size: Input image resolution as [Height, Width]. l_block_idx: Index of the backbone block to extract low-level (high-resolution) features. h_block_idx: Index of the backbone block to extract high-level (low-resolution) features. + use_low: Whether to build and run the low-level GCViT branch. + use_high: Whether to build and run the high-level GCViT branch. + When both are False, the high-level backbone feature map is global-average-pooled + and fed to the head directly (EfficientNet-only baseline). l_dim: Initial feature dimension for the low-level GCViT branch. h_dim: Initial feature dimension for the high-level GCViT branch. l_depths: Number of blocks in each stage of the low-level GCViT branch. @@ -96,46 +154,58 @@ def __init__( """ super().__init__() + self.use_low = use_low + self.use_high = use_high + self.feat_extractor = FeatExtractor( - model_name = model_name, - img_size = img_size, - l_block_idx = l_block_idx, + model_name = model_name, + img_size = img_size, + l_block_idx = l_block_idx, h_block_idx = h_block_idx ) - + self.l_meta = self._build_metadata(img_size, l_block_idx) self.h_meta = self._build_metadata(img_size, h_block_idx) - - self.l_gcvit = GCViT( - in_chs = self.l_meta['in_chs'], - input_resolution = self.l_meta['input_resolution'], - dim = l_dim, - depths = l_depths, - window_size = l_windows, - mlp_ratio = l_ratio, - num_heads = l_heads, - drop = l_drop, - attn_drop = l_attn_drop, - drop_path = l_drop_path, - ) - - self.h_gcvit = GCViT( - in_chs = self.h_meta['in_chs'], - input_resolution = self.h_meta['input_resolution'], - dim = h_dim, - depths = h_depths, - window_size = h_windows, - mlp_ratio = h_ratio, - num_heads = h_heads, - drop = h_drop, - attn_drop = h_attn_drop, - drop_path = h_drop_path, - ) - - final_l_dim = l_dim * (2 ** (len(l_depths) - 1)) - final_h_dim = h_dim * (2 ** (len(h_depths) - 1)) - fusion_dim = final_l_dim + final_h_dim + fusion_dim = 0 + + self.l_gcvit = None + if use_low: + self.l_gcvit = GCViT( + in_chs = self.l_meta['in_chs'], + input_resolution = self.l_meta['input_resolution'], + dim = l_dim, + depths = l_depths, + window_size = l_windows, + mlp_ratio = l_ratio, + num_heads = l_heads, + drop = l_drop, + attn_drop = l_attn_drop, + drop_path = l_drop_path, + ) + fusion_dim += l_dim * (2 ** (len(l_depths) - 1)) + + self.h_gcvit = None + if use_high: + self.h_gcvit = GCViT( + in_chs = self.h_meta['in_chs'], + input_resolution = self.h_meta['input_resolution'], + dim = h_dim, + depths = h_depths, + window_size = h_windows, + mlp_ratio = h_ratio, + num_heads = h_heads, + drop = h_drop, + attn_drop = h_attn_drop, + drop_path = h_drop_path, + ) + fusion_dim += h_dim * (2 ** (len(h_depths) - 1)) + + self.pool = None + if not use_low and not use_high: + self.pool = nn.AdaptiveAvgPool2d(1) + fusion_dim = self.h_meta['in_chs'] + self.head = nn.Sequential( nn.LayerNorm(fusion_dim), nn.Linear(fusion_dim, fusion_dim // 2), @@ -176,18 +246,24 @@ def no_weight_decay_keywords(self): return {'relative_position_bias_table','bn','norm'} def forward(self, x): - + feat = self.feat_extractor(x) # (B,C,H,W) - - l_feat = feat[self.l_meta["feature_idx"]] - h_feat = feat[self.h_meta["feature_idx"]] - - l_out = self.l_gcvit(l_feat) # (B,D_l) - h_out = self.h_gcvit(h_feat) # (B,D_h) - - fusion_out = torch.cat([l_out, h_out], dim=-1) # (B,D_1 + D_h) - - return self.head(fusion_out) # (B,D_1 + D_h) -> (B,1) + + outs = [] + if self.use_low: + l_feat = feat[self.l_meta["feature_idx"]] + outs.append(self.l_gcvit(l_feat)) # (B,D_l) + if self.use_high: + h_feat = feat[self.h_meta["feature_idx"]] + outs.append(self.h_gcvit(h_feat)) # (B,D_h) + + if outs: + fusion_out = torch.cat(outs, dim=-1) if len(outs) > 1 else outs[0] + else: + h_feat = feat[self.h_meta["feature_idx"]] + fusion_out = self.pool(h_feat).flatten(1) # (B,C) + + return self.head(fusion_out) # (B,fusion_dim) -> (B,1) def _get_config_for_type(variant: str, type_key: str) -> dict: @@ -248,21 +324,21 @@ def ms_eff_gcvit_b0(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiS return _create_ms_eff_gcvit(variant, pretrained_cfg=pretrained_cfg, - pretrained=pretrained, + pretrained=pretrained, **model_kwargs) @register_model def ms_eff_gcvit_b5(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiScaleEffGCViT: - + variant = "ms_eff_gcvit_b5" - + kwargs.pop('pretrained_cfg', None) - + model_kwargs = dict( model_name = "tf_efficientnet_b5.ns_jft_in1k", img_size = [384,384], l_dim = 48, - h_dim = 512, + h_dim = 512, l_depths = [2,2,6,2], h_depths = [6], l_windows = [12,12,24,12], @@ -281,8 +357,186 @@ def ms_eff_gcvit_b5(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiS pretrained_cfg = _get_config_for_type(variant, dataset) else: pretrained_cfg = default_cfgs[variant] - + + return _create_ms_eff_gcvit(variant, + pretrained_cfg=pretrained_cfg, + pretrained=pretrained, + **model_kwargs) + +@register_model +def eff_b0(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiScaleEffGCViT: + + variant = "eff_b0" + + kwargs.pop('pretrained_cfg', None) + + model_kwargs = dict( + model_name = "tf_efficientnet_b0.ns_jft_in1k", + img_size = [224,224], + use_low = False, + use_high = False, + **kwargs + ) + + if pretrained: + pretrained_cfg = _get_config_for_type(variant, dataset) + else: + pretrained_cfg = default_cfgs[variant] + + return _create_ms_eff_gcvit(variant, + pretrained_cfg=pretrained_cfg, + pretrained=pretrained, + **model_kwargs) + +@register_model +def eff_b5(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiScaleEffGCViT: + + variant = "eff_b5" + + kwargs.pop('pretrained_cfg', None) + + model_kwargs = dict( + model_name = "tf_efficientnet_b5.ns_jft_in1k", + img_size = [384,384], + use_low = False, + use_high = False, + **kwargs + ) + + if pretrained: + pretrained_cfg = _get_config_for_type(variant, dataset) + else: + pretrained_cfg = default_cfgs[variant] + + return _create_ms_eff_gcvit(variant, + pretrained_cfg=pretrained_cfg, + pretrained=pretrained, + **model_kwargs) + +@register_model +def low_eff_gcvit_b0(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiScaleEffGCViT: + + variant = "low_eff_gcvit_b0" + + kwargs.pop('pretrained_cfg', None) + + model_kwargs = dict( + model_name = "tf_efficientnet_b0.ns_jft_in1k", + img_size = [224,224], + use_low = True, + use_high = False, + l_dim = 24, + l_depths = [2,2,4,2], + l_windows = [7,7,14,7], + l_heads = [1,2,4,8], + l_ratio = [4,4,4,4], + l_attn_drop = 0.05, + l_drop_path = 0.1, + **kwargs + ) + + if pretrained: + pretrained_cfg = _get_config_for_type(variant, dataset) + else: + pretrained_cfg = default_cfgs[variant] + + return _create_ms_eff_gcvit(variant, + pretrained_cfg=pretrained_cfg, + pretrained=pretrained, + **model_kwargs) + +@register_model +def low_eff_gcvit_b5(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiScaleEffGCViT: + + variant = "low_eff_gcvit_b5" + + kwargs.pop('pretrained_cfg', None) + + model_kwargs = dict( + model_name = "tf_efficientnet_b5.ns_jft_in1k", + img_size = [384,384], + use_low = True, + use_high = False, + l_dim = 48, + l_depths = [2,2,6,2], + l_windows = [12,12,24,12], + l_heads = [2,4,8,16], + l_ratio = [3,3,3,3], + l_attn_drop = 0.1, + l_drop_path = 0.15, + **kwargs + ) + + if pretrained: + pretrained_cfg = _get_config_for_type(variant, dataset) + else: + pretrained_cfg = default_cfgs[variant] + + return _create_ms_eff_gcvit(variant, + pretrained_cfg=pretrained_cfg, + pretrained=pretrained, + **model_kwargs) + +@register_model +def high_eff_gcvit_b0(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiScaleEffGCViT: + + variant = "high_eff_gcvit_b0" + + kwargs.pop('pretrained_cfg', None) + + model_kwargs = dict( + model_name = "tf_efficientnet_b0.ns_jft_in1k", + img_size = [224,224], + use_low = False, + use_high = True, + h_dim = 256, + h_depths = [4], + h_windows = [7], + h_heads = [4], + h_ratio = [4], + h_drop = 0.05, + h_drop_path = 0.05, + **kwargs + ) + + if pretrained: + pretrained_cfg = _get_config_for_type(variant, dataset) + else: + pretrained_cfg = default_cfgs[variant] + + return _create_ms_eff_gcvit(variant, + pretrained_cfg=pretrained_cfg, + pretrained=pretrained, + **model_kwargs) + +@register_model +def high_eff_gcvit_b5(pretrained=False, dataset="celeb_df_v2", **kwargs) -> MultiScaleEffGCViT: + + variant = "high_eff_gcvit_b5" + + kwargs.pop('pretrained_cfg', None) + + model_kwargs = dict( + model_name = "tf_efficientnet_b5.ns_jft_in1k", + img_size = [384,384], + use_low = False, + use_high = True, + h_dim = 512, + h_depths = [6], + h_windows = [12], + h_heads = [16], + h_ratio = [3], + h_drop = 0.1, + h_drop_path = 0.1, + **kwargs + ) + + if pretrained: + pretrained_cfg = _get_config_for_type(variant, dataset) + else: + pretrained_cfg = default_cfgs[variant] + return _create_ms_eff_gcvit(variant, pretrained_cfg=pretrained_cfg, - pretrained=pretrained, + pretrained=pretrained, **model_kwargs) diff --git a/deepguard/models/ms_eff_vit.py b/deepguard/models/ms_eff_vit.py index 96b8d99a..4598f01e 100644 --- a/deepguard/models/ms_eff_vit.py +++ b/deepguard/models/ms_eff_vit.py @@ -40,6 +40,11 @@ def _cfg(url='', **kwargs): 'ff++': 'https://github.com/HanMoonSub/DeepGuard/releases/download/v0.1.0/ms_eff_vit_b5_ff++.bin' } } + +def available_models() -> List[str]: + """Returns the names of available MS-EffViT models""" + return list(weight_registry.keys()) + class MultiScaleEffViT(nn.Module): def __init__( self, diff --git a/deepguard/optimizer/build_optimizer.py b/deepguard/optimizer/build_optimizer.py index d5e188d3..e6d2427a 100644 --- a/deepguard/optimizer/build_optimizer.py +++ b/deepguard/optimizer/build_optimizer.py @@ -1,37 +1,45 @@ import torch -def add_to_optim_groups(skip_keywords, - params_list, - base_lr, - base_wd): - +def add_to_optim_groups(skip_keywords, + params_list, + base_lr, + base_wd, + component=None): + """ Filters parameters into decay and no-decay groups. - + Args: skip_keywords (set): Keywords for parameters that should not have weight decay. params_list (list): List of (name, param) tuples. base_lr (float): Learning rate for this specific component. base_wd (float): Weight decay rate for this specific component. + component (str, optional): Tag identifying which model component these + parameters belong to (e.g. "backbone", "l_gcvit"). Stored on each + resulting group as 'name'/'kind' so callers can look groups up by + component instead of by position โ€” needed since some components + (e.g. an ablated branch) may not produce any group at all. """ - + optim_groups = [] decay = [] no_decay = [] - + for name, param in params_list: if not param.requires_grad: continue - + if any(key in name for key in skip_keywords) or name.endswith(".bias"): no_decay.append(param) else: decay.append(param) - + if decay: - optim_groups.append({'params': decay, 'lr': base_lr, 'weight_decay': base_wd}) + optim_groups.append({'params': decay, 'lr': base_lr, 'weight_decay': base_wd, + 'name': component, 'kind': 'decay'}) if no_decay: - optim_groups.append({'params': no_decay, 'lr': base_lr, 'weight_decay': 0.0}) + optim_groups.append({'params': no_decay, 'lr': base_lr, 'weight_decay': 0.0, + 'name': component, 'kind': 'no_decay'}) return optim_groups @@ -125,36 +133,35 @@ def build_ms_eff_gcvit_optimizer(model, cfg): head_params.append((name, param)) all_optim_groups = [] - + all_optim_groups.extend( - add_to_optim_groups(skip_keywords, feat_params, cfg.train.backbone_lr, cfg.train.backbone_wd) + add_to_optim_groups(skip_keywords, feat_params, cfg.train.backbone_lr, cfg.train.backbone_wd, component="backbone") ) all_optim_groups.extend( - add_to_optim_groups(skip_keywords, l_gcvit_params, cfg.train.l_block_lr, cfg.train.l_block_wd) + add_to_optim_groups(skip_keywords, l_gcvit_params, cfg.train.l_block_lr, cfg.train.l_block_wd, component="l_gcvit") ) all_optim_groups.extend( - add_to_optim_groups(skip_keywords, h_gcvit_params, cfg.train.h_block_lr, cfg.train.h_block_wd) + add_to_optim_groups(skip_keywords, h_gcvit_params, cfg.train.h_block_lr, cfg.train.h_block_wd, component="h_gcvit") ) all_optim_groups.extend( - add_to_optim_groups(skip_keywords, head_params, cfg.train.head_lr, cfg.train.head_wd) + add_to_optim_groups(skip_keywords, head_params, cfg.train.head_lr, cfg.train.head_wd, component="head") ) print(f"\n{'='*20} ๐Ÿ“ฆ Parameter Groups Summary {'='*20}") - names = ["Backbone (Decay)", "Backbone (No-Decay)", - "L-GCViT (Decay)", "L-GCViT (No-Decay)", - "H-GCViT (Decay)", "H-GCViT (No-Decay)", - "Head (Decay)", "Head (No-Decay)"] - - for i, group in enumerate(all_optim_groups): - group_name = names[i] if i < len(names) else f"Group {i}" + display_names = {"backbone": "Backbone", "l_gcvit": "L-GCViT", "h_gcvit": "H-GCViT", "head": "Head"} + + for group in all_optim_groups: + label = display_names.get(group.get('name'), group.get('name')) + kind = "Decay" if group.get('kind') == 'decay' else "No-Decay" + group_name = f"{label} ({kind})" params = group['params'] num_tensors = len(params) total_params = sum(p.numel() for p in params) lr = group['lr'] wd = group.get('weight_decay', 0) - + print(f" โ€ข {group_name:<20} | Tensors: {num_tensors:<4} | Size: {total_params/1e6:>6.2f}M | LR: {lr:.1e} | WD: {wd}") - + print(f"{'='*65}\n") - + opt_class = getattr(torch.optim, cfg.train.optimizer) return opt_class(all_optim_groups) \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index cb1c93f5..4a044d22 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ x-app-env: &app-env services: mysql: - image: seoyunje/deepguard-mysql:1.0.6 + image: seoyunje/deepguard-mysql:1.0.7 container_name: deepguard-mysql networks: [deepguard-network] environment: @@ -29,14 +29,14 @@ services: - deepguard-data:/var/lib/mysql redis: - image: seoyunje/deepguard-redis:1.0.6 + image: seoyunje/deepguard-redis:1.0.7 container_name: deepguard-redis networks: [deepguard-network] volumes: - deepguard-memory:/data fastapi: - image: seoyunje/deepguard-fastapi:1.0.15 + image: seoyunje/deepguard-fastapi:1.0.28 container_name: deepguard-fastapi networks: [deepguard-network] environment: @@ -49,7 +49,7 @@ services: - redis celery: - image: seoyunje/deepguard-celery:1.0.15 + image: seoyunje/deepguard-celery:1.0.28 container_name: deepguard-celery networks: [deepguard-network] environment: @@ -62,7 +62,7 @@ services: - redis react: - image: seoyunje/deepguard-react:1.0.7 + image: seoyunje/deepguard-react:1.0.17 container_name: deepguard-react networks: [deepguard-network] ports: diff --git a/inference/README.md b/inference/README.md index 37c13778..2ee59dd9 100644 --- a/inference/README.md +++ b/inference/README.md @@ -167,4 +167,56 @@ To evaluate the generalization and robustness of our deepfake detection model, w | **ms_eff_gcvit_b0** | 20 | conf | 0 | 0.7544 | 0.862 | 0.8829 | | **ms_eff_gcvit_b5** | 20 | conf | 0 | **0.7695** | **0.8821** | **0.7635** | + + +## ๐Ÿงฉ Branch-Ablation Study + +To quantify how much each branch โ€” the **Low-level Branch** and the **High-level Branch** โ€” contributes to MS-EffGCViT's performance, we trained and evaluated 3 variants (`Eff`, `Low-Eff-GCViT`, `High-Eff-GCViT`) in both `b0`/`b5` sizes across all three benchmark datasets. + +## ๐ŸŽฌ Celeb DF(V2) Ablation Evaluation + +
+โœ… Test Data Evaluation + +| ๐Ÿค– Model | ๐ŸŽฏ Accuracy | ๐Ÿ“ˆ AUC | ๐Ÿ“‰ Log Loss | +| :--- | :---: | :---: | :---: | +| EfficientNet B0 | 0.9643 | 0.9754 | 0.0977 | +| EfficientNet B5 | 0.9768 | 0.9837 | 0.0676 | +| low_eff_gcvit_b0 | 0.9788 | 0.9837 | 0.0658 | +| low_eff_gcvit_b5 | 0.9865 | **0.9987** | 0.0150 | +| high_eff_gcvit_b0 | 0.9807 | 0.9884 | 0.0343 | +| **high_eff_gcvit_b5** | **0.9942** | 0.9977 | **0.0101** | + +
+ +## ๐ŸŽฌ FaceForensics++ Ablation Evaluation + +
+โœ… Test Data Evaluation + +| ๐Ÿค– Model | ๐ŸŽฏ Accuracy | ๐Ÿ“ˆ AUC | ๐Ÿ“‰ Log Loss | +| :--- | :---: | :---: | :---: | +| EfficientNet B0 | 0.9202 | 0.9497 | 0.1523 | +| EfficientNet B5 | 0.9660 | 0.9831 | 0.0842 | +| low_eff_gcvit_b0 | 0.8033 | 0.9257 | 0.4148 | +| low_eff_gcvit_b5 | 0.8700 | 0.9486 | 0.3365 | +| high_eff_gcvit_b0 | 0.9783 | 0.9886 | 0.0767 | +| **high_eff_gcvit_b5** | **0.9808** | **0.9956** | **0.0606** | + +
+ +## ๐ŸŽฌ Kodf Ablation Evaluation + +
+โœ… Test Data Evaluation + +| ๐Ÿค– Model | ๐ŸŽฏ Accuracy | ๐Ÿ“ˆ AUC | ๐Ÿ“‰ Log Loss | +| :--- | :---: | :---: | :---: | +| EfficientNet B0 | 0.9180 | 0.9520 | 0.2010 | +| EfficientNet B5 | 0.9601 | 0.9770 | 0.1120 | +| low_eff_gcvit_b0 | 0.8684 | 0.9481 | 0.2843 | +| low_eff_gcvit_b5 | 0.8808 | 0.9596 | 0.2381 | +| high_eff_gcvit_b0 | 0.9462 | 0.9696 | 0.1761 | +| **high_eff_gcvit_b5** | **0.9745** | **0.9911** | **0.0844** | +
\ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 952eaa82..62323caa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" # โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ [project] name = "deepguard" # pip install deepguard ํ•  ๋•Œ ์ด ์ด๋ฆ„ -version = "1.0.0" +version = "1.1.0" description = "Multi-Scale Efficient Global Context Vision Transformer for Robust Deepfake Detection" readme = "README.md" # PyPI ํŽ˜์ด์ง€์— ํ‘œ์‹œ๋  ์„ค๋ช… (๋งˆํฌ๋‹ค์šด) requires-python = ">=3.10" # torch/torchvision/torchmetrics์˜ Requires-Python ํ•˜ํ•œ์ด 3.10์ด๋ผ ์ด ๊ฐ’์„ ๊ทธ๋Œ€๋กœ ๋”ฐ๋ฆ„ diff --git a/requirements.txt b/requirements.txt index 3df354e8..ca5698e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,14 @@ # --- [Core Backend & Server] --- fastapi>=0.141.1 -uvicorn>=0.52.3 +uvicorn>=0.52.4 python-multipart>=0.0.32 -pydantic[email]>=2.13.4 +pydantic[email]>=2.13.5 aiofiles>=25.1.0 itsdangerous>=2.2.0 python-dotenv>=1.2.3 # --- [Database & ORM] --- -sqlalchemy>=2.0.52 +sqlalchemy>=2.0.54 pymysql>=1.2.0 aiomysql>=0.3.2 mysql-connector-python>=26.7.0 @@ -46,4 +46,4 @@ colorama>=0.4.6 celery>=5.6.3 # --- [Linting & Formatting] --- -ruff>=0.16.3 \ No newline at end of file +ruff>=0.16.8 \ No newline at end of file diff --git a/train_eff_gcvit.py b/train_eff_gcvit.py index 3dd529da..8dc66aa3 100644 --- a/train_eff_gcvit.py +++ b/train_eff_gcvit.py @@ -36,11 +36,7 @@ from deepguard.scheduler import ( fetch_scheduler ) -from deepguard.models import ( - MultiScaleEffGCViT, - ms_eff_gcvit_b0, - ms_eff_gcvit_b5 -) +from deepguard.models.ms_eff_gcvit import MultiScaleEffGCViT from colorama import Fore, Style c_ = Fore.BLUE @@ -180,7 +176,10 @@ def fit(self, train_df, valid_df): self.model.load_state_dict(torch.load(ckpt_path, map_location=self.cfg.device)) return self.model - + + def _lr_for(self, component): + return next((g['lr'] for g in self.optimizer.param_groups if g.get('name') == component), None) + def train_one_epoch(self, loader): self.model.train() @@ -223,28 +222,28 @@ def train_one_epoch(self, loader): avg_metrics = self.train_metrics.compute() # ====== Learning Rate ====== - backbone_lr = self.optimizer.param_groups[0]['lr'] - l_gcvit_lr = self.optimizer.param_groups[2]['lr'] - h_gcvit_lr = self.optimizer.param_groups[4]['lr'] - head_lr = self.optimizer.param_groups[6]['lr'] - + lr_by_component = { + 'backbone_lr': self._lr_for('backbone'), + 'l_gcvit_lr': self._lr_for('l_gcvit'), + 'h_gcvit_lr': self._lr_for('h_gcvit'), + 'head_lr': self._lr_for('head'), + } + # ====== Calculate GPU Memory Usage ======= mem = torch.cuda.memory_reserved() / 1E9 if torch.cuda.is_available() else 0 - + # ====== Display Info ====== - pbar.set_postfix( - train_loss = f'{avg_loss:.4f}', - train_acc = f'{avg_metrics["train_acc"]:.4f}', - train_auc = f'{avg_metrics["train_auc"]:.4f}', - train_precision = f'{avg_metrics["train_precision"]:.4f}', - train_recall = f'{avg_metrics["train_recall"]:.4f}', - train_f1 = f'{avg_metrics["train_f1"]:.4f}', - backbone_lr = f'{backbone_lr:.1e}', - l_gcvit_lr = f'{l_gcvit_lr:.1e}', - h_gcvit_lr = f'{h_gcvit_lr:.1e}', - head_lr = f'{head_lr:.1e}', - gpu_mem = f'{mem:.1f} GB' - ) + postfix = { + 'train_loss': f'{avg_loss:.4f}', + 'train_acc': f'{avg_metrics["train_acc"]:.4f}', + 'train_auc': f'{avg_metrics["train_auc"]:.4f}', + 'train_precision': f'{avg_metrics["train_precision"]:.4f}', + 'train_recall': f'{avg_metrics["train_recall"]:.4f}', + 'train_f1': f'{avg_metrics["train_f1"]:.4f}', + **{k: f'{v:.1e}' for k, v in lr_by_component.items() if v is not None}, + 'gpu_mem': f'{mem:.1f} GB', + } + pbar.set_postfix(postfix) torch.cuda.empty_cache() return avg_loss, avg_metrics @@ -300,7 +299,10 @@ def main(): parser = argparse.ArgumentParser(description="Multi-Scale EffGCViT Training") parser.add_argument("--root-dir", required=True) - parser.add_argument("--model-ver", default="ms_eff_gcvit_b0", choices=['ms_eff_gcvit_b0','ms_eff_gcvit_b5']) + parser.add_argument("--model-ver", default="ms_eff_gcvit_b0", choices=[ + 'ms_eff_gcvit_b0', 'high_eff_gcvit_b0', 'low_eff_gcvit_b0', 'eff_b0', + 'ms_eff_gcvit_b5', 'high_eff_gcvit_b5', 'low_eff_gcvit_b5', 'eff_b5', + ]) parser.add_argument("--dataset", default="celeb_df_v2", choices=["celeb_df_v2","ff++","kodf"]) parser.add_argument("--seed", default=2025, type=int) diff --git a/train_eff_vit.py b/train_eff_vit.py index 1553ff0b..182a569c 100644 --- a/train_eff_vit.py +++ b/train_eff_vit.py @@ -36,11 +36,7 @@ from deepguard.scheduler import ( fetch_scheduler ) -from deepguard.models import ( - MultiScaleEffViT, - ms_eff_vit_b0, - ms_eff_vit_b5 -) +from deepguard.models.ms_eff_vit import MultiScaleEffViT from colorama import Fore, Style c_ = Fore.BLUE