Coder Social home page Coder Social logo

hsme98 / maskcon_cvpr2023 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrchenfeng/maskcon_cvpr2023

0.0 0.0 0.0 11.88 MB

MaskCon: Masked Contrastive Learning for Coarse-Labeled Dataset (CVPR2023)

Home Page: https://openaccess.thecvf.com/content/CVPR2023/html/Feng_MaskCon_Masked_Contrastive_Learning_for_Coarse-Labelled_Dataset_CVPR_2023_paper.html

License: MIT License

Python 98.03% Shell 1.97%

maskcon_cvpr2023's Introduction

MaskCon: Masked Contrastive Learning for Coarse-Labelled Dataset

svg

PWC PWC PWC PWC

This is the official PyTorch implementation of CVPR2023 paper (MaskCon: Masked Contrastive Learning for Coarse-Labelled Dataset). Please find official video here: https://www.youtube.com/watch?v=V4is0vAYNOw.

Abstract

Deep learning has achieved great success in recent years with the aid of advanced neural network structures and large-scale human-annotated datasets. However, it is often costly and difficult to accurately and efficiently annotate large-scale datasets, especially for some specialized domains where fine-grained labels are required. In this setting, coarse labels are much easier to acquire as they do not require expert knowledge. In this work, we propose a contrastive learning method, called Masked Contrastive learning~(MaskCon) to address the under-explored problem setting, where we learn with a coarse-labelled dataset in order to address a finer labelling problem. More specifically, within the contrastive learning framework, for each sample our method generates soft-labels against other samples and another augmented view of the sample in question. By contrast to self-supervised contrastive learning where only the sample's augmentations are considered hard positives, and in supervised contrastive learning where only samples with the same coarse labels are considered hard positives, we propose soft labels based on sample distances, that are masked by the coarse labels. This allows us to utilize both inter-sample relations and coarse labels. We demonstrate that our method can obtain as special cases many existing state-of-the-art works and that it provides tighter bounds on the generalization error. Experimentally, our method achieves significant improvement over the current state-of-the-art in various datasets, including CIFAR10, CIFAR100, ImageNet-1K, Standford Online Products and Stanford Cars196 datasets.

@InProceedings{Feng_2023_CVPR,
    author    = {Feng, Chen and Patras, Ioannis},
    title     = {MaskCon: Masked Contrastive Learning for Coarse-Labelled Dataset},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2023},
    pages     = {19913-19922}
}

Please considering cite our paper and star the repo if you find this repo useful.

Preparation

  • pytorch
  • tqdm
  • wandb

Usage

Example runs on imagenet/SOP/Cars dataset:

python main.py --dataset imagenet32 --data_path ../datasets/imagenet32 --wandb_id imagenet32 --K 16384 --m 0.99 --t0 0.1 --t 0.05 --w 1.0 --mode coins --gpu_id 0 --epochs 100 --aug_q strong --aug_k weak --batch_size 256

python main.py --dataset sop_split1 --data_path ../datasets/Stanford_Online_Products --wandb_id Stanford_Online_Products_Split1 --t0 0.1 --t 0.1 --w 0.8 --mode maskcon --gpu_id 0 --aug_q strong --aug_k weak

python main.py --dataset cars196 --data_path ../datasets/StanfordCars --wandb_id StanfordCars --w 1.0 --t 0.1 --w 1.0 --mode maskcon --gpu_id 1 --aug_q strong --aug_k weak

Visualizations

tSNE visualization of learned features on the CIFARtoy test set:

drawing

Results

Top-10 retrieved images on the Cars196 test set:

drawing

Usage of coarse labels

We provide all the coarse labels of downsampled imagenet dataset and Stanford Online Products dataset in coarse_labels dir.

  • For Cars196 and CIFARtoy dataset, feel free to copy our dataloaders for your project.
  • For SOP dataset, please copy and paste the coarse_labels/sop_split1 and coarse_labels/sop_split2 directory to the dataset path.
  • For ImageNet32 dataset, please copy and paste the coarse_labels/imagenet32/imagenet32_to_fine.json and coarse_labels/imagenet32/imagenet_fine_to_coarse.json files to the dataset path.

License

This project is licensed under the terms of the MIT license.

maskcon_cvpr2023's People

Contributors

hsme98 avatar mrchenfeng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.