{"id":28643620,"url":"https://github.com/matteofasulo/hermes","last_synced_at":"2025-08-27T03:05:35.117Z","repository":{"id":298691482,"uuid":"993813683","full_name":"MatteoFasulo/HERMES","owner":"MatteoFasulo","description":"HERMS: Healthcare Ethics \u0026 Robustness in Medical Image Systems","archived":false,"fork":false,"pushed_at":"2025-07-06T13:53:44.000Z","size":58205,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-06T14:38:22.601Z","etag":null,"topics":["adversarial-attacks","adversarial-defense","ethics-in-ai","evasion-attack","medical-image-processing"],"latest_commit_sha":null,"homepage":"https://matteofasulo.github.io/HERMES/report/report.pdf","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatteoFasulo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"github":"MatteoFasulo","custom":"https://www.paypal.me/MatteoFasulo"}},"created_at":"2025-05-31T15:23:39.000Z","updated_at":"2025-07-06T13:53:47.000Z","dependencies_parsed_at":"2025-06-12T11:47:57.067Z","dependency_job_id":null,"html_url":"https://github.com/MatteoFasulo/HERMES","commit_stats":null,"previous_names":["matteofasulo/hermes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MatteoFasulo/HERMES","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoFasulo%2FHERMES","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoFasulo%2FHERMES/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoFasulo%2FHERMES/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoFasulo%2FHERMES/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatteoFasulo","download_url":"https://codeload.github.com/MatteoFasulo/HERMES/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatteoFasulo%2FHERMES/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272283255,"owners_count":24906646,"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","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-defense","ethics-in-ai","evasion-attack","medical-image-processing"],"created_at":"2025-06-12T23:40:15.415Z","updated_at":"2025-08-27T03:05:35.103Z","avatar_url":"https://github.com/MatteoFasulo.png","language":"Jupyter Notebook","funding_links":["https://github.com/sponsors/MatteoFasulo","https://www.paypal.me/MatteoFasulo"],"categories":[],"sub_categories":[],"readme":"# HERMES: Healthcare Ethics \u0026 Robustness in Medical Image Systems\n\n## Description\n\n**HERMES** is a project focused on ensuring healthcare ethics and robustness in medical image systems. It is part of the Ethics in AI course at the [University of Bologna](https://www.unibo.it/en/homepage), and it aims to provide a framework for training and evaluating medical image models with a focus on ethical considerations and robustness.\n\nOur main goal is to create a system that can be used easily to train and evaluate medical image models, while also providing a framework for ethical considerations and robustness. The project is designed to be **modular** and **extensible**, allowing for easy experimentation with different settings, training strategies, and data preprocessing techniques.\n\nMachine Learning Security is crucial in the healthcare domain, thus we opted for a modular approach based on a simple **PyTorch Classifier** built on top of the [**PyTorch Lightning**](https://lightning.ai/docs/pytorch/stable/) framework.\n\nAs for the robustness of the model, we are using the [**Adversarial Robustness Toolbox (ART)**](https://github.com/Trusted-AI/adversarial-robustness-toolbox) by the [**Linux Foundation AI \u0026 Data Foundation**](https://lfaidata.foundation/), which provides a comprehensive suite of tools for **adversarial machine learning**.\n\nAll the code is compatible with the API exposed by ART, allowing for easy integration with other tools and libraries and enabling the use of various adversarial attacks and defenses on the model.\n\nThe main focus of this project is based on **evasion attacks**, specifically the [**Fast Gradient Sign Method (FGSM)**](https://arxiv.org/abs/1412.6572) and the [**Projected Gradient Descent (PGD)**](https://arxiv.org/abs/1706.06083) attacks, which are widely used in the field of adversarial machine learning. The defenses implemented in this project are mainly **preprocessing** techniques, such as [**JPEG compression**](https://arxiv.org/abs/1705.02900), **Gaussian Smoothing**, and [**Spatial Smoothing**](https://arxiv.org/abs/1704.01155), which are designed to reduce the impact of adversarial attacks on the model.\n\n## Notebooks\n\nThe project includes several **notebooks** that you can use to finetune a PyTorch Classifier on a medical image dataset, evaluate the model's performance, and test the robustness of the model against adversarial attacks. The notebooks are designed to be modular and extensible, allowing you to easily experiment with different settings, training strategies, and data preprocessing techniques.\n\nThe notebooks are located in the **`notebooks`**, and they include:\n\n- **`resnet_finetuning.ipynb`**: A notebook for finetuning a ResNet model pretrained on ImageNet on a medical image dataset (**PatchCamelyon - PCAM**). It includes data loading, preprocessing, training, and evaluation steps with PyTorch Lightning for easy model training and evaluation without boilerplate code.\n\n- **`simple_framework.ipynb`**: A notebook for evaluating the robustness of the trained model against adversarial attacks. It includes the implementation of FGSM and PGD attacks from ART, as well as the evaluation of the model's performance on adversarial examples. The notebook also includes preprocessing techniques such as JPEG compression, Gaussian Smoothing, and Spatial Smoothing to reduce the impact of adversarial attacks on the model. The proposed framework allows for easy integration with other defenses from [**`art.defences.preprocessor`**](https://adversarial-robustness-toolbox.readthedocs.io/en/latest/modules/defences/preprocessor.html) but you can find also the code to implement your **own** preprocessing techniques compliant with the ART API.\n\n- **plot.ipynb**: A notebook for plotting the results of the evaluation, including the accuracy of the model on clean and adversarial examples, as well as the impact of preprocessing techniques on the model's performance. It leverages the CSV files generated by the simple framework notebook to plot the results in a clear and concise manner.\n\n- **kaggle-api.ipynb**: A notebook which shows how to download the **PatchCamelyon - PCAM** dataset from Kaggle using the Kaggle API as well as our checkpoint with finetuned ResNet model on PCAM dataset. This notebook is useful if you want to quickly get started with the project and have the dataset ready for training and evaluation with minimal effort.\n\n## Installation\n\nThe project was developed and tested on Python 3.10, and it is recommended to use a virtual environment to avoid conflicts with other projects. You can create a virtual environment using `venv` or `conda`, and then install the project requirements.\n\n\u003e [!TIP]\n\u003e We strongly encourage using [astral-sh/uv](https://github.com/astral-sh/uv) to install the project requirements. This ensures that the correct versions of the dependencies are installed, and it can help avoid conflicts with other projects. Alternatively, you can use `pip` to install the requirements from the `requirements.txt` file.\n\nTo install the project, you can use the following command:\n\n```bash\nuv sync\n```\n\nThis command will install all the required dependencies for the project, including PyTorch, PyTorch Lightning, and the Adversarial Robustness Toolbox (ART).\nIf you prefer to use `pip`, you can install the requirements from the `requirements.txt` file:\n\n```bash\npip install -r requirements.txt\n```\n\n## Authors and acknowledgment\n\nThis project is developed by [Matteo Fasulo](https://github.com/MatteoFasulo), [Luca Babboni](https://github.com/ElektroDuck), and [Maxim Omelchenko](https://github.com/omemaxim) as part of the Ethics in AI course at the [University of Bologna](https://www.unibo.it/en/homepage).\n\nA great shoutout to the community of the [**Linux Foundation AI \u0026 Data Foundation**](https://lfaidata.foundation/) for their work on the [**Adversarial Robustness Toolbox (ART)**](https://github.com/Trusted-AI/adversarial-robustness-toolbox) and for providing a comprehensive suite of tools for adversarial machine learning.\n\nThere are many examples and tutorials available in the [**ART documentation**](https://adversarial-robustness-toolbox.readthedocs.io/en/latest/index.html) but we believe that this project can help you to get started with the framework and to understand how to use it in the context of medical image systems.\n\n## License\n\nThe project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.\n\n## Project status\n\nThe project is currently in active development. We welcome contributions and feedback from the community. If you have any suggestions or issues, please open an issue!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteofasulo%2Fhermes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatteofasulo%2Fhermes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatteofasulo%2Fhermes/lists"}