CoolFace
Apppublic

onyeonwoo/Anti_AI_Filter

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

Anti AI Filter

FastAPI 기반 이미지 보호 API입니다. 업로드된 이미지를 JND-EoT 필터로 변환하고, 원본/보호본에 대한 AI 분석 결과와 attention heatmap을 반환합니다.

Local Backend

powershell
cd anti-ai-filter
pip install -r requirements.txt
pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
uvicorn main:app --host 0.0.0.0 --port 7860

API 확인:

powershell
curl http://localhost:7860/

Protection Flow

  1. 1.The browser uploads an image and an intensity value to POST /protect.
  2. 2.main.py calls apply_protection_filter and returns the protected PNG as a data URL.
  3. 3.filter.py optimizes a small perturbation in RGB pixel space.
  4. 4.The perturbation is clipped by a JND mask so it stays visually subtle.
  5. 5.The surrogate ResNet input is normalized only at model-evaluation time, not while applying the final pixel noise.
  6. 6.The API also returns original/protected model labels and Grad-CAM style heatmaps for comparison.

This is a defensive protection layer for user-owned images. It can reduce model confidence for the surrogate model, but it should not be treated as a universal guarantee against every training or classification pipeline.

Docker

powershell
docker build -t anti-ai-filter .
docker run --rm -p 7860:7860 anti-ai-filter

The Docker build uses .dockerignore to exclude local caches, frontend build output, sample images, and helper tools from the runtime image.

Frontend

powershell
cd anti-ai-filter/frontend
npm install
npm run build

프론트엔드는 REACT_APP_API_URL 환경변수로 백엔드 URL을 받습니다.

Deployment

GitHub Actions는 anti-ai-filter/ 폴더만 Hugging Face Space 루트로 복사해서 Docker Space에 강제 푸시합니다. 따라서 Hugging Face는 이 폴더의 Dockerfile과 README front matter를 기준으로 빌드합니다.