{"id":19448004,"url":"https://github.com/dawnofthedebayan/dualbranchnbi","last_synced_at":"2025-06-15T17:36:45.439Z","repository":{"id":204881011,"uuid":"473577081","full_name":"dawnofthedebayan/DualBranchNBI","owner":"dawnofthedebayan","description":null,"archived":false,"fork":false,"pushed_at":"2022-03-24T11:34:09.000Z","size":4676,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-07T23:19:26.914Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dawnofthedebayan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-03-24T11:29:11.000Z","updated_at":"2022-04-11T09:04:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"7059483f-035f-4925-8d11-aad23f62bf7f","html_url":"https://github.com/dawnofthedebayan/DualBranchNBI","commit_stats":null,"previous_names":["dawnofthedebayan/dualbranchnbi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawnofthedebayan%2FDualBranchNBI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawnofthedebayan%2FDualBranchNBI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawnofthedebayan%2FDualBranchNBI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawnofthedebayan%2FDualBranchNBI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawnofthedebayan","download_url":"https://codeload.github.com/dawnofthedebayan/DualBranchNBI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240636664,"owners_count":19832922,"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":[],"created_at":"2024-11-10T16:22:58.100Z","updated_at":"2025-02-25T08:52:15.615Z","avatar_url":"https://github.com/dawnofthedebayan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Learning Robust Representation for Laryngeal CancerClassification in Vocal Folds from Narrow Band Images\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"figures/all.png\" width=\"700\"\u003e\n\u003c/p\u003e\n\nThis repo covers the implementation of the paper submitted to MIDL 2022:  \n(\n## Loss Function\nThe loss function [`SupConLoss`](https://github.com/HobbitLong/SupContrast/blob/master/losses.py#L11) in `losses.py` takes `features` (L2 normalized) and `labels` as input, and return the loss. If `labels` is `None` or not passed to the it, it degenerates to SimCLR.\n\nUsage:\n```python\nfrom losses import SupConLoss\n\n# define loss with a temperature `temp`\ncriterion = SupConLoss(temperature=temp)\n\n# features: [bsz, n_views, f_dim]\n# `n_views` is the number of crops from each image\n# better be L2 normalized in f_dim dimension\nfeatures = ...\n# labels: [bsz]\nlabels = ...\n\n# SupContrast\nloss = criterion(features, labels)\n# or SimCLR\nloss = criterion(features)\n...\n```\n\n## Hyperparameter tuning to find best latent vector dimension for Supervise Contrastive Loss. \n\n|D2 | AUPRC|\n:----:|:---:|\n| 8  | 0.75 | \n| 16 | 0.60 | \n| 32 | 0.69 | \n| 64 | 0.54 | \n\n\n## Hyperparameter tuning to find best latent vector dimension for Cross Entropy Loss.\n\n|D2 | AUPRC|\n:----:|:---:|\n| 8  | 0.71 | \n| 16 | 0.62 | \n| 32 | 0.75 | \n| 64 | 0.70 | \n\n\nThe `--data_folder` must be of form ./path/label/xxx.png folowing https://pytorch.org/docs/stable/torchvision/datasets.html#torchvision.datasets.ImageFolder convension.\n\n\n## Usage\n\n# Training Dual Branch with Supervise Contrastive loss\nExample:\npython main_supcon_scatter.py --augment all --dataset path --train_data_folder //media/debayan/cropped_CVs/1/train/ --val_data_folder //media/debayan/cropped_CVs/1/val/ --batch_size 32 --seed 10 --model_number CV_1\n\n# Testing Dual Branch with Supervise Contrastive loss\nExample:\npython main_supcon_scatter_test.py   --model_folder /media/debayan/NBI/code/SupContrast-master/save/SupConScatter/path_models/SupConScatter_path_resnet18_modelnumber_CV_1_aug_all/ --data_folder //media/debayan/NBI/Dataset/cropped_CVs/1/test/ --expt_name SupCon_wvlet_2\n\n# Training Dual Branch with Cross Entropy Loss\nExample:\npython main_ce_scatter.py --augment all --dataset path --train_data_folder //media/debayan/NBI/Dataset/cropped_CVs/1/train/ --val_data_folder //media/debayan/NBI/Dataset/cropped_CVs/1/val/ --batch_size 32 --seed 10 --model_number CV_1\n\n# Testing Dual Branch with Cross Entropy Loss\nExample:\npython main_ce_scatter_test.py --latent 8 --model_folder /media/debayan/NBI/code/SupContrast-master/save/CEScatterLatentBalanced/path_models/CEScatterLatentBalanced_path_resnet18_modelnumber_CV_1_aug_all_latent_8/ --data_folder //media/debayan/NBI/Dataset/cropped_CVs/1/test/ --expt_name CE_latent_balanced_8\n\n\n\n\n## Acknowledgement\n```\nWe thank the code provided by Khosla et al (https://github.com/HobbitLong/SupContrast). We have used their code and modified it for our experiments. \n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawnofthedebayan%2Fdualbranchnbi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawnofthedebayan%2Fdualbranchnbi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawnofthedebayan%2Fdualbranchnbi/lists"}