{"id":28562529,"url":"https://github.com/davidemodolo/homm-domainadaptation","last_synced_at":"2025-08-29T06:04:55.031Z","repository":{"id":291603436,"uuid":"974091462","full_name":"davidemodolo/HoMM-DomainAdaptation","owner":"davidemodolo","description":"Project for \"Deep Learning\" course at UNITN - Unsupervised Domain Adaptation on Adaptiope Dataset","archived":false,"fork":false,"pushed_at":"2025-04-28T08:42:08.000Z","size":7786,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-22T02:59:47.005Z","etag":null,"topics":["adaptiope","computer-vision","deep-learning","domain-adaptation","resnet-34","unsupervised-domain-adaptation"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidemodolo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-04-28T08:41:54.000Z","updated_at":"2025-07-12T13:28:37.000Z","dependencies_parsed_at":"2025-05-05T16:11:12.654Z","dependency_job_id":"79063a39-8ebf-419c-abb7-aa5e4d07bb29","html_url":"https://github.com/davidemodolo/HoMM-DomainAdaptation","commit_stats":null,"previous_names":["davidemodolo/homm-domainadaptation"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/davidemodolo/HoMM-DomainAdaptation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2FHoMM-DomainAdaptation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2FHoMM-DomainAdaptation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2FHoMM-DomainAdaptation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2FHoMM-DomainAdaptation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidemodolo","download_url":"https://codeload.github.com/davidemodolo/HoMM-DomainAdaptation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidemodolo%2FHoMM-DomainAdaptation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272639868,"owners_count":24968517,"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-29T02:00:10.610Z","response_time":87,"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":["adaptiope","computer-vision","deep-learning","domain-adaptation","resnet-34","unsupervised-domain-adaptation"],"created_at":"2025-06-10T12:09:49.394Z","updated_at":"2025-08-29T06:04:55.020Z","avatar_url":"https://github.com/davidemodolo.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HoMM Domain Adaptation\n\nThis project implements an unsupervised domain adaptation model based on the paper \"[HoMM: Higher-order Moment Matching for Unsupervised Domain Adaptation](https://arxiv.org/pdf/1912.11976.pdf)\". The method extends standard discrepancy-based losses (MMD, CORAL) by matching higher-order moments in the feature space.\n\n## Overview\n\n- **Architecture:**  \n  The model uses a ResNet34 backbone with a custom adapted layer (using tanh activation instead of relu) to extract features. An added classification layer produces the final predictions. Two loss components are used:\n\n  - **Domain discrepancy loss (HoMM loss):**  \n    This loss matches higher-order statistics between source and target domains. Several versions are implemented, including direct 3rd-order, grouped 4th-order, and an arbitrary-order variant via random sampling.\n  - **Discriminative clustering loss:**  \n    This loss enforces that pseudo-labeled target samples become closer to their respective class centers. The centers are updated with a moving average.\n\n- **Data:**  \n  A custom `SubsetImageFolder` class is used to load only a subset of classes from the dataset. Two domains are considered, for example, `product_images` and `real_life`.\n\n- **Training:**  \n  Training is performed with two modes:\n\n  - A full UDA training step that combines the classification, HoMM, and clustering losses.\n  - A baseline training step that uses cross-entropy loss only.\n\n  Hyperparameters such as batch size, learning rate, HoMM order, and lambda factors can be tuned. For instance, the script uses a batch size of 128, a learning rate of 0.001, and lambda values to weight the loss contributions.\n\n## Dependencies\n\n- Python with PyTorch and torchvision\n- tqdm\n- Google Colab (for drive mounting if running in Colab)\n- matplotlib (for plotting training curves)\n\n## How to Run\n\n1. **Preparation:**\n\n   - Download the dataset (e.g., `Adaptiope.zip`) and unzip it.\n   - Adjust the `img_root` and subset names as needed.\n\n2. **Running the Experiment:**\n\n   - To run the full UDA model, execute the notebook cells (or run the following via a main function):\n     ```python\n     main()\n     ```\n   - To run the baseline model, call:\n     ```python\n     main(baseline=True)\n     ```\n   - To reverse the domains, use:\n     ```python\n     main(reverse=True)\n     ```\n   - Both reverse and baseline options can be combined:\n     ```python\n     main(reverse=True, baseline=True)\n     ```\n\n3. **Monitoring:**\n   - The training progress is printed and accuracy and loss plots are generated at the end of training.\n\n## Hyperparameters\n\nSome key hyperparameter settings in the main function:\n\n- `batch_size=128`\n- `homm_order=4`\n- `num_samples=350000`\n- `lambda_d=100` (discrepancy loss weight)\n- `lambda_dc=0.1` (clustering loss weight)\n- `alpha=0.7` for center updates\n- `threshold=0.65` for selecting target samples for clustering\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidemodolo%2Fhomm-domainadaptation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidemodolo%2Fhomm-domainadaptation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidemodolo%2Fhomm-domainadaptation/lists"}