{"id":13422250,"url":"https://github.com/hytseng0509/CrossDomainFewShot","last_synced_at":"2025-03-15T11:31:30.574Z","repository":{"id":51566988,"uuid":"234003721","full_name":"hytseng0509/CrossDomainFewShot","owner":"hytseng0509","description":"Cross-Domain Few-Shot Classification via Learned Feature-Wise Transformation (ICLR 2020 spotlight)","archived":false,"fork":false,"pushed_at":"2020-04-12T11:14:23.000Z","size":73,"stargazers_count":323,"open_issues_count":30,"forks_count":62,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-07-31T23:45:04.670Z","etag":null,"topics":["domain-generalization","few-shot-learning","iclr2020","meta-learning"],"latest_commit_sha":null,"homepage":null,"language":"Python","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/hytseng0509.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}},"created_at":"2020-01-15T05:15:19.000Z","updated_at":"2024-07-04T05:55:43.000Z","dependencies_parsed_at":"2022-08-21T18:10:07.822Z","dependency_job_id":null,"html_url":"https://github.com/hytseng0509/CrossDomainFewShot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hytseng0509%2FCrossDomainFewShot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hytseng0509%2FCrossDomainFewShot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hytseng0509%2FCrossDomainFewShot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hytseng0509%2FCrossDomainFewShot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hytseng0509","download_url":"https://codeload.github.com/hytseng0509/CrossDomainFewShot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221572074,"owners_count":16845574,"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":["domain-generalization","few-shot-learning","iclr2020","meta-learning"],"created_at":"2024-07-30T23:00:40.500Z","updated_at":"2024-10-26T19:32:40.534Z","avatar_url":"https://github.com/hytseng0509.png","language":"Python","funding_links":[],"categories":["Cross-Domain Few-Shot Classification. ICLR 2020","Python"],"sub_categories":[],"readme":"# Cross-Domain Few-Shot Classification via Learned Feature-Wise Transformation \n[[Project Page]](http://vllab.ucmerced.edu/ym41608/projects/CrossDomainFewShot)[[Paper]](https://arxiv.org/abs/2001.08735)\n\nPytorch implementation for our cross-domain few-shot classification method. With the proposed learned feature-wise transformation layers, we are able to:\n\n1. improve the performance of exisiting few-shot classification methods under **cross-domain** setting\n2. achieve stat-of-the-art performance under **single-domain** setting.\n\nContact: Hung-Yu Tseng (htseng6@ucmerced.edu)\n\n## Paper\nPlease cite our paper if you find the code or dataset useful for your research.\n\nCross-Domain Few-Shot Classification via Learned Feature-Wise Transformation\u003cbr\u003e\n[Hung-Yu Tseng](https://sites.google.com/site/hytseng0509/), [Hsin-Ying Lee](http://vllab.ucmerced.edu/hylee/), [Jia-Bin Huang](https://filebox.ece.vt.edu/~jbhuang/), [Ming-Hsuan Yang](http://faculty.ucmerced.edu/mhyang/)\u003cbr\u003e\nInternational Conference on Learning Representations (ICLR), 2020 (**spotlight**)\n```\n@inproceedings{crossdomainfewshot,\n  author = {Tseng, Hung-Yu and Lee, Hsin-Ying and Huang, Jia-Bin and Yang, Ming-Hsuan},\n  booktitle = {International Conference on Learning Representations},\n  title = {Cross-Domain Few-Shot Classification via Learned Feature-Wise Transformation},\n  year = {2020}\n}\n```\n\n## Usage\n\n### Prerequisites\n- Python \u003e= 3.5\n- Pytorch \u003e= 1.3 and torchvision (https://pytorch.org/)\n- You can use the `requirements.txt` file we provide to setup the environment via Anaconda.\n```\nconda create --name py36 python=3.6\nconda install pytorch torchvision -c pytorch\npip3 install -r requirements.txt\n```\n\n### Install\nClone this repository:\n```\ngit clone https://github.com/hytseng0509/CrossDomainFewShot.git\ncd CrossDomainFewShot\n```\n\n### Datasets\nDownload 5 datasets seperately with the following commands.\n- Set `DATASET_NAME` to: `cars`, `cub`, `miniImagenet`, `places`, or `plantae`.\n```\ncd filelists\npython3 process.py DATASET_NAME\ncd ..\n```\n- Refer to the instruction [here](https://github.com/wyharveychen/CloserLookFewShot#self-defined-setting) for constructing your own dataset.\n\n### Feature encoder pre-training\nWe adopt `baseline++` for MatchingNet, and `baseline` from [CloserLookFewShot](https://github.com/wyharveychen/CloserLookFewShot) for other metric-based frameworks.\n- Download the pre-trained feature encoders.\n```\ncd output/checkpoints\npython3 download_encoder.py\ncd ../..\n```\n- Or train your own pre-trained feature encoder (specify `PRETRAIN` to `baseline++` or `baseline`).\n```\npython3 train_baseline.py --method PRETRAIN --dataset miniImagenet --name PRETRAIN --train_aug\n```\n\n### Training with multiple seen domains\nBaseline training w/o feature-wise transformations.\n- `METHOD` : metric-based framework `matchingnet`, `relationnet_softmax`, or `gnnnet`.\n- `TESTSET`: unseen domain `cars`, `cub`, `places`, or `plantae`.\n```\npython3 train_baseline.py --method METHOD --dataset multi --testset TESTSET --name multi_TESTSET_ori_METHOD --warmup PRETRAIN --train_aug\n```\nTraining w/ learning-to-learned feature-wise transformations.\n```\npython3 train.py --method METHOD --dataset multi --testset TESTSET --name multi_TESTSET_lft_METHOD --warmup PRETRAIN --train_aug\n```\n\n### Evaluation\nTest the metric-based framework `METHOD` on the unseen domain `TESTSET`.\n- Specify the saved model you want to evaluate with `--name` (e.g., `--name multi_TESTSET_lft_METHOD` from the above example).\n```\npython3 test.py --method METHOD --name NAME --dataset TESTSET\n```\n\n## Note\n- This code is built upon the implementation from [CloserLookFewShot](https://github.com/wyharveychen/CloserLookFewShot).\n- The dataset, model, and code are for non-commercial research purposes only.\n- You can change the number of shot (i.e. 1/5 shots) using the argument `--n_shot`.\n- You need a GPU with 16G memory for training the `gnnnet` approach w/ learning-to-learned feature-wise transformations.\n- 04/2020: We've corrected the code for training with multiple domains. Please find the link [here](http://vllab.ucmerced.edu/ym41608/projects/CrossDomainFewShot/checkpoints/multi_cub_lft_relationnet_softmax.tar.gz) for the model trained with the current implementation on Pytorch 1.4.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhytseng0509%2FCrossDomainFewShot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhytseng0509%2FCrossDomainFewShot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhytseng0509%2FCrossDomainFewShot/lists"}