A newer version of the Gradio SDK is available: 6.12.0
title: FGSM 對抗攻擊展示
emoji: 🎯
colorFrom: red
colorTo: blue
sdk: gradio
app_file: app.py
pinned: false
license: mit
🎯 FGSM 對抗攻擊展示
FGSM Adversarial Attack Demonstration
📚 關於此專案 / About This Project
這是國立中興大學「人工智慧與資訊安全」課程的期末專案,展示 FGSM (Fast Gradient Sign Method) 對抗攻擊技術。
This is a final project for the "Artificial Intelligence and Information Security" course at National Chung Hsing University (NCHU), demonstrating the Fast Gradient Sign Method (FGSM) adversarial attack technique.
課程: 人工智慧與資訊安全 學校: 國立中興大學 Course: AI and Information Security University: National Chung Hsing University
🔬 技術背景 / Technical Background
FGSM 是什麼?/ What is FGSM?
FGSM 是一種經典的對抗攻擊方法,透過在影像上加入微小的、人眼難以察覺的擾動,使深度學習模型產生錯誤的預測。
FGSM is a classic adversarial attack method that adds small, imperceptible perturbations to images, causing deep learning models to make incorrect predictions.
核心公式 / Core Formula
x_adv = x + ε · sign(∇ₓ L(f(x), y))
其中 / Where:
x: 原始影像 / Original imageε: 擾動幅度 / Perturbation magnitude∇ₓ L: 損失函數對輸入的梯度 / Gradient of loss w.r.t. inputsign(): 符號函數 / Sign functionx_adv: 對抗樣本 / Adversarial example
🚀 如何使用 / How to Use
步驟 / Steps:
選擇範例圖片 / Select Sample Image
- 點選下方的範例數字圖片 (0-9)
- Click on any sample digit image (0-9) below
調整擾動幅度 / Adjust Epsilon
- 使用滑桿調整 ε 值 (建議 0.1-0.3)
- Use the slider to adjust ε value (recommended 0.1-0.3)
執行攻擊 / Execute Attack
- 點擊「Execute Attack」按鈕
- Click the "Execute Attack" button
觀察結果 / Observe Results
- 查看原始預測 vs 對抗樣本預測
- View original prediction vs adversarial prediction
- 觀察三圖對比 (原始影像 / 擾動 / 對抗樣本)
- Observe three-panel comparison (original / perturbation / adversarial)
📊 實驗結果示例 / Example Results
攻擊成功率: > 80% (當 ε = 0.3)
Attack Success Rate: > 80% (when ε = 0.3)
視覺化: 三圖並排顯示
Visualization: Three-panel side-by-side display
- 原始影像 / Original Image
- 擾動 (放大 10 倍) / Perturbation (10x amplified)
- 對抗樣本 / Adversarial Example
🎓 學術價值 / Academic Value
研究目的 / Research Purpose
理解對抗攻擊 / Understanding Adversarial Attacks
- 深入了解 FGSM 的數學原理
- Deep understanding of FGSM mathematical principles
評估模型脆弱性 / Evaluating Model Vulnerability
- 測試神經網路對對抗樣本的魯棒性
- Test neural network robustness against adversarial examples
提升 AI 安全意識 / Raising AI Security Awareness
- 認識深度學習系統的安全風險
- Recognize security risks in deep learning systems
應用領域 / Applications
- 🔒 模型安全性評估 / Model security assessment
- 🛡️ 對抗訓練 / Adversarial training
- 🔬 魯棒性研究 / Robustness research
- 📚 教育展示 / Educational demonstration
🛠️ 技術架構 / Technical Stack
- 深度學習框架 / Framework: PyTorch 2.0+
- 模型 / Model: CNN (MNIST)
- 介面 / Interface: Gradio 4.44+
- 資料集 / Dataset: MNIST Handwritten Digits
系統組件 / System Components
FGSM Demo
├── src/fgsm.py # FGSM 攻擊核心 / FGSM attack core
├── src/model.py # CNN 模型 / CNN model
├── demo/gradio_app.py # Gradio 介面 / Gradio interface
├── models/mnist_cnn.pth # 預訓練模型 / Pre-trained model
└── demo/samples/ # 範例圖片 / Sample images (0-9)
📖 參考文獻 / References
Goodfellow, I. J., Shlens, J., & Szegedy, C. (2014) Explaining and Harnessing Adversarial Examples arXiv:1412.6572
Madry, A., et al. (2018) Towards Deep Learning Models Resistant to Adversarial Attacks arXiv:1706.06083
PyTorch FGSM Tutorial https://pytorch.org/tutorials/beginner/fgsm_tutorial.html
⚠️ 免責聲明 / Disclaimer
本專案僅供學術研究和教育目的使用。對抗攻擊技術應負責任地使用,不得用於惡意目的。
This project is for academic research and educational purposes only. Adversarial attack techniques should be used responsibly and not for malicious purposes.
📧 聯絡資訊 / Contact
📜 授權 / License
MIT License - 開放給學術和教育用途 MIT License - Open for academic and educational use
建立日期 / Created: 2025-12-22 版本 / Version: 1.0 狀態 / Status: ✅ 運作中 / Active