Giter Site home page Giter Site logo

figurecropping's Introduction

Hi! This is an implementation of Segment Anything, a project by Meta AI Research involving the segmentation of 2D images

I added scripts to easily obtain the objects which are segmented from these images.

My files:

  • Preprocessing directory -- My personal attempt at a segmentation algorithm -> Relatively poor results --- Added functionality for resizing images, extracting cropped images of detected faces, and removal of background for 2D images. ---- transparentBackground.py, resize.py, createMask.py and deleteBackground.py are scripts that can be run from terminal

  • cropped_images directory -- Default output folder for cropped 2D image objects

  • test_images -- Default folder for input 2D image objects

  • segment.py & trial.ipynb -- Python and Ipynb notebook I wrote, heavily inspired by "automatic_mask_generator_example.ipynb" given by Meta, that obtains cropped images

How to Use:

  1. Download the "sam_vit_h_4b8939.pth" file from here and place it in the "segment-anything" directory
  2. Install the requirements from requirements.txt using 'pip install -r requirements.txt'
  3. Place test images into 'test_images' folder
  4. Run the command 'python segment.py [file-name]'
  5. See the cropped image in the 'cropped_images' folder

Note: The Segment Anything Model generates multiple images for different masks in the given image. My script only obtains the object contained by the largest mask by size. In order to generate objects by multiple or different masks, edit line 28 to reflect all/other values in 'sorted_anns'

Credits: Meta AI Research, FAIR

Alexander Kirillov, Eric Mintun, Nikhila Ravi, Hanzi Mao, Chloe Rolland, Laura Gustafson, Tete Xiao, Spencer Whitehead, Alex Berg, Wan-Yen Lo, Piotr Dollar, Ross Girshick

[Paper] [Project] [Demo] [Dataset] [Blog] [BibTeX]

SAM design

The Segment Anything Model (SAM) produces high quality object masks from input prompts such as points or boxes, and it can be used to generate masks for all objects in an image. It has been trained on a dataset of 11 million images and 1.1 billion masks, and has strong zero-shot performance on a variety of segmentation tasks.

License

The model is licensed under the Apache 2.0 license.

Contributing

See contributing and the code of conduct.

Contributors

The Segment Anything project was made possible with the help of many contributors (alphabetical):

Aaron Adcock, Vaibhav Aggarwal, Morteza Behrooz, Cheng-Yang Fu, Ashley Gabriel, Ahuva Goldstand, Allen Goodman, Sumanth Gurram, Jiabo Hu, Somya Jain, Devansh Kukreja, Robert Kuo, Joshua Lane, Yanghao Li, Lilian Luong, Jitendra Malik, Mallika Malhotra, William Ngan, Omkar Parkhi, Nikhil Raina, Dirk Rowe, Neil Sejoor, Vanessa Stark, Bala Varadarajan, Bram Wasti, Zachary Winstrom

Citing Segment Anything

If you use SAM or SA-1B in your research, please use the following BibTeX entry.

@article{kirillov2023segany,
  title={Segment Anything},
  author={Kirillov, Alexander and Mintun, Eric and Ravi, Nikhila and Mao, Hanzi and Rolland, Chloe and Gustafson, Laura and Xiao, Tete and Whitehead, Spencer and Berg, Alexander C. and Lo, Wan-Yen and Doll{\'a}r, Piotr and Girshick, Ross},
  journal={arXiv:2304.02643},
  year={2023}
}

figurecropping's People

Contributors

ericmintun avatar hannamao avatar anishfish2 avatar nikhilaravi avatar elm-forest avatar advaybot avatar lmmx avatar spencerwhitehead avatar triple-mu avatar jp-x-g avatar derekray311511 avatar anh-vunguyen avatar endingcredits avatar xrenya avatar pierizvi avatar eltociear avatar calebrob6 avatar

Stargazers

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