{"id":18993524,"url":"https://github.com/infinitode/deepdefend","last_synced_at":"2025-04-22T12:44:29.097Z","repository":{"id":184280080,"uuid":"671637844","full_name":"Infinitode/DeepDefend","owner":"Infinitode","description":"DeepDefend is an open-source Python library for adversarial attacks and defenses in deep learning models, enhancing the security and robustness of AI systems.","archived":false,"fork":false,"pushed_at":"2025-02-24T09:12:03.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T08:18:45.183Z","etag":null,"topics":["adversarial-attacks","adversarial-defenses","ai","ai-attack","ai-defense","ml","models","perturbations","perturbations-library","tensorflow"],"latest_commit_sha":null,"homepage":"https://infinitode.netlify.app","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Infinitode.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-27T19:31:06.000Z","updated_at":"2025-02-24T09:12:08.000Z","dependencies_parsed_at":"2024-12-11T08:32:32.553Z","dependency_job_id":null,"html_url":"https://github.com/Infinitode/DeepDefend","commit_stats":null,"previous_names":["infinitode/deepdefend"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Infinitode%2FDeepDefend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Infinitode%2FDeepDefend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Infinitode%2FDeepDefend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Infinitode%2FDeepDefend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Infinitode","download_url":"https://codeload.github.com/Infinitode/DeepDefend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250242956,"owners_count":21398244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adversarial-attacks","adversarial-defenses","ai","ai-attack","ai-defense","ml","models","perturbations","perturbations-library","tensorflow"],"created_at":"2024-11-08T17:21:46.134Z","updated_at":"2025-04-22T12:44:29.074Z","avatar_url":"https://github.com/Infinitode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeepDefend\n![Python Version](https://img.shields.io/badge/python-3.13-blue.svg)\n![Code Size](https://img.shields.io/github/languages/code-size/infinitode/deepdefend)\n![Downloads](https://pepy.tech/badge/deepdefend)\n![License Compliance](https://img.shields.io/badge/license-compliance-brightgreen.svg)\n![PyPI Version](https://img.shields.io/pypi/v/deepdefend)\n\nAn open-source Python library for adversarial attacks and defenses in deep learning models, enhancing the security and robustness of AI systems.\n\n## Changes in 0.1.3:\n- 5 new functions in `defenses.py`, including: Randomized Smoothing, Feature Denoising, Thermometer Encoding, Adversarial Logit Pairing (ALP), and Spatial Smoothing.\n\n\u003e [!NOTE]\n\u003e Updates to DeepDefend's attack module will be less frequent due to the potential misuse of adversarial attacks on AI models.\n\n## Changes in 0.1.2:\nWe've updated DeepDefend, here's what's new:\n- 3 new functions under `deepdefend.attacks`\n- 3 new functions under `deepdefend.defenses`\n\n## Installation\n\nYou can install DeepDefend using pip:\n\n```bash\npip install deepdefend\n```\n\n## Supported Python Versions\n\nDeepDefend supports the following Python versions:\n\n- Python 3.6\n- Python 3.7\n- Python 3.8\n- Python 3.9\n- Python 3.10\n- Python 3.11 or later\n\nPlease ensure that you have one of these Python versions installed before using DeepDefend. DeepDefend may not work as expected on lower versions of Python than the supported.\n\n## Features\n\n- Adversarial Attacks: Generate adversarial examples to evaluate model vulnerabilities.\n- Adversarial Defenses: Employ various methods to protect models against adversarial attacks.\n\n## Usage\n\n### Adversarial Attacks\n\n```python\nimport tensorflow as tf\nfrom deepdefend.attacks import fgsm, pgd, bim, cw, deepfool, jsma\n\n# Load a pre-trained TensorFlow model\nmodel = ...\n\n# Load example input and label data (replace this with your own data loading code)\nx_example = ...  # example input data\ny_example = ...  # true label\n\n# Perform FGSM attack on the example data\nadversarial_example_fgsm = fgsm(model, x_example, y_example, epsilon=0.01)\n\n# Perform PGD attack on the example data\nadversarial_example_pgd = pgd(model, x_example, y_example, epsilon=0.01, alpha=0.01, num_steps=10)\n\n# Perform BIM attack on the example data\nadversarial_example_bim = bim(model, x_example, y_example, epsilon=0.01, alpha=0.01, num_steps=10)\n\n# Perform CW attack on the example data\nadversarial_example_cw = cw(model, x_example, y_example, epsilon=0.01, c=1, kappa=0, num_steps=10, alpha=0.01)\n\n# Perform Deepfool attack on the example data\nadversarial_example_deepfool = deepfool(model, x_example, y_example, num_steps=10)\n\n# Perform JSMA attack on the example data\nadversarial_example_jsma = jsma(model, x_example, y_example, theta=0.1, gamma=0.1, num_steps=10)\n```\n\n### Adversarial Defenses\n\n```python\nimport tensorflow as tf\nfrom deepdefend.defenses import adversarial_training, feature_squeezing, gradient_masking, input_transformation, defensive_distillation\n\n# Load a pre-trained TensorFlow model\nmodel = ...\n\n# Teacher model for distillation\nteacher_model = ...\n\n# Load training data\nx_train, y_train = ...  # training data and labels\n\n# Adversarial training to defend against attacks\ndefended_model = adversarial_training(model, x_train, y_train, epsilon=0.01)\n\n# Feature squeezing defense\ndefended_model_squeezed = feature_squeezing(model, bit_depth=4)\n\n# Gradient masking defense\ndefended_model_masking = gradient_masking(model, mask_threshold=0.1)\n\n# Input transformation defense\ndefended_model_transformation = input_transformation(model, transformation_function=None)\n\n# Defensive distillation defense\ndefended_model_distillation = defensive_distillation(model, teacher_model, temperature=2)\n```\n\n## Contributing\n\nContributions are welcome! If you encounter any issues, have suggestions, or want to contribute to DeepDefend, please open an issue or submit a pull request on [GitHub](https://github.com/infinitode/deepdefend).\n\n## License\n\nDeepDefend is released under the terms of the **MIT License (Modified)**. Please see the [LICENSE](https://github.com/infinitode/deepdefend/blob/master/LICENSE) file for the full text.\n\n**Modified License Clause**\n\n\n\nThe modified license clause grants users the permission to make derivative works based on the DeepDefend software. However, it requires any substantial changes to the software to be clearly distinguished from the original work and distributed under a different name.\n\nBy enforcing this distinction, it aims to prevent direct publishing of the source code without changes while allowing users to create derivative works that incorporate the code but are not exactly the same.\n\nPlease read the full license terms in the [LICENSE](https://github.com/infinitode/deepdefend/blob/master/LICENSE) file for complete details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitode%2Fdeepdefend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfinitode%2Fdeepdefend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfinitode%2Fdeepdefend/lists"}