Git Product home page Git Product logo

ice's Introduction

ICE: Image Caption Encoding 🧊


Authors contributed equally to this repository, the commit history does not reflect contributions.

Code in this repo uses code from multimodal prompt learning, which in turn uses code from Co-CoOp and CoOp.

⏳ Installation


  • Install dassl library and other requirements.
# Instructions borrowed from https://github.com/KaiyangZhou/Dassl.pytorch#installation

git clone https://github.com/KaiyangZhou/Dassl.pytorch.git
cd Dassl.pytorch/
pip install -r requirements.txt
python setup.py develop
cd ..

pip install open_clip_torch
pip install pytorch_metric_learning
  • Create a directory somewhere called data/. Download all 15 zip files from this shared Google Drive and unzip them into data/. The resulting file tree should look like:
data/
|-- caltech-101
|-- dtd
|-- eurosat
|-- fgvc_aircraft
|-- food-101
|-- imagenet
|-- imagenet-adversarial
|-- imagenet-rendition
|-- imagenet-sketch
|-- imagenetv2
|-- oxford_flowers
|-- oxford_pets
|-- stanford_cars
|-- sun397
|-- ucf101

Alternatively, follow the download instructions here (some dataset links are stale; may also need to reorganize the directory structure): installing datasets

Modify the following two lines in argparse_parameters.py to reflect where you have your data/ dir and where you want the pretrained CLIP weights to be cached (which could be many gigabytes)

parser.add_argument('--cache_dir', default = "", type =str) # set to directory where you want large pretrained model weights to be cached
parser.add_argument('--data_dir', default = "", type =str)  # set to parent directory of data/

🧪 Experiements


(1) Generate Captions

ICE works with any captioner or VLM. We tried CoCa, BLIP-2, and LLAVA. We provide three example captions for each image in each dataset in the captions/ folder. These can be used directly. However, if you want to generate them yourself, you can run:

Run: sh run_make_captions.sh

The above script generates three captions per image per dataset, for CoCa, BLIP-2 and LLAVA.

For LLAVA, the conda environment should be setup according to their github repo: here

(2) Run ICE with Generated Captions

Run: sh run_ice.sh

🧊 Results


See ICE_results.xlsx.

🧪 Ablation Experiements


Ablation Description Command to run
Caption features zero-shot scripts/run_caption_features_zs.sh
Image features zero-shot scripts/run_image_features_zs.sh
Varying lambdas scripts/run_varying_lam.sh
ICE with different captioner-image encoder combos run_scaling_law.sh

ice's People

Contributors

chris210634 avatar

Stargazers

 avatar Yong Sun avatar zhuzhu804 avatar Theodoros Tsiligkaridis avatar Wu Zihan avatar  avatar

Watchers

 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.