Coder Social home page Coder Social logo

cub-sam's Introduction

Segmenting Birds with SAM

This repository provides a very simple pipeline for calling the segment everything model (SAM) on the well-known Caltech-UCSD Birds-200-2011 (CUB-200-2011) dataset.

CUB-200-2011 dataset includes 11788 images of 200 different bird species, with annotations on 15 part locations and 1 bounding box representing the whole bird. These parts, e.g., bird beaks, are demonstrated to play a key role in fine-grained bird recognition. In the original annotation, part locations were marked by key points - this repository aims at presenting the bird parts with segmentation masks. This is done by employing the key point coordinates as prompts in the SAM model pre-trained on large-scale datasets. Besides, we tried to adopt the provided bounding box as prompts, which generated binary segmentation on the bird and the image background.

Dependencies

  • SAM dependencies following SAM
  • imgviz

Hands-on the model

Prepare dataset
Download the CUB-200-2011 dataset, and unzip it in data/. The directory should be like:
data/
  CUB_200_2011/
   attributes/
   images/
   parts/
   images.txt
   bounding_boxes.txt
   ...

Generate segmentation masks with SAM

python3 sam_segmentation.py --prompt=<prompt> --model=<model>

prompt means the type of SAM prompts, which can be 'box', 'point', or 'click'. 'box' is associated with the bounding box annotation of birds. This option leads to a binary segmentation prediction. 'point' refers to the key point annotations of part locations, where each location is annotated with one key point, while 'click' includes multiple points on each bird part (from multiple annotators).

model represents the model type of SAM backbone, which can be 'vit_b', 'vit_l', or 'vit_h'.

Segmentation results can be found under 'segmentation/'.

License

MIT License

cub-sam's People

Contributors

mmmmimic avatar

Stargazers

Morten Bo Svendsen avatar  avatar Lin Manhui 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.