Superpixel Feature Extractor

Dependencies

  • PyTorch
  • Scikit Learn Image
  • OpenAI CLIP
  • Salesforce LAVIS

Parameters

NameDescription
--image_dirThe directory containnig image inputs
--save_dirThe directory to save the npz files to
--num_superpixelsThe number of superpixels to generate per image
--model_idWhich model to use? [BLIP / CLIP / ResNet]
--whole_img(Flag) Generate a single feature for the whole image
--is_masked(Flag) Black out pixels in the superpixel bounding box that aren’t in the original superpixel
--patches(Flag) Generate patch features instead of superpixel features

Warning: The --patches flag will generate $16 \times 16$ patches for an image that is resized to $224 \times 224$, yielding $14 \times 14 = 196$ patches

Example

python3 main.py --image_dir "/homes/hps01/superpixel-features/test_images" \
    --save_dir "/homes/hps01/superpixel-features/test_output/" \
    --is_masked \
    --model_id "BLIP" \
    --num_superpixels 25 \