Giter VIP home page Giter VIP logo

guided_segmentation's Introduction

Few Shot Segmentation

Few-shot segmentation method, using ResNet as encoder and UNetV3 as decoder. UNetV3 is from Pytorch-UNet-2 ResNet is from torchvision.models

Method we use is similar to Integrative Few-Shot Learning for Classification and Segmentation

  1. Feed query image, support image and support mask to the model.
  2. Get layer 1 (L1), layer 2 (L2), layer 3 (L3) and layer 4 (L4) feature maps from ResNet for query(Q) and support images(S)
  3. Check the cosine similarities of pixels from support and query image feature maps.(L1,L2,L3,L4) a. Example: Take one pixel location from L1 of Q and calculate cosine similarity between this pixel and the pixels from L1 of S. Repeat the process for all pixels in Q.
  4. The acquired cosine similarity matrix C is in this size: (Batch Size, Height*Width, Height, Width). And we have 4 cosine similarity matrices in total for L1, L2, L3, and L4.
  5. Concatenate C1, C2, C3, C4. (Cc)
  6. Flatten the support image mask and multiply it with Cc. This is to eliminate the effect of not desired (the pixels which are not in the mask area) pixels.
  7. Put Cc in 2D 1x1 convolution to reduce the Height*Width number of feature maps to predetermined number (N) of feature maps. (Output: B, N, H, W)
  8. Feed this feature map to UNET.
  9. Get the generated mask and calculate BCELoss with generated mask and expected mask of query image.

Results:

Support Image | Support Mask | Query Image | Query Mask | Predicted Mask

1 2 3 4

guided_segmentation's People

Contributors

rootvisionai avatar

Watchers

 avatar  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.