Skip to content

Sweetfish is a UIImageView wrapper library for removing backgrounds using Vision Framework's Image Segmentation 📸 🎣

License

Notifications You must be signed in to change notification settings

YamatoOtaka/Sweetfish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sweetfish

Sweetfish is a UIImageView wrapper library for removing backgrounds using Vision Framework's Image Segmentation.

Swift5 Carthage Lincense

.object(objectType: .human) .selectTouch .selectValue(value: 12)

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Sweetfish into your Xcode project using Carthage, specify it in your Cartfile:

github "YamatoOtaka/Sweetfish"

Run carthage bootstrap to build the framework in your repository's Carthage directory. You can then include it in your target's carthage copy-frameworks build phase. For more information on this, please see Carthage's documentation.

Usage

(see sample Xcode project in /Demo)

Setup

Content mode for SweetfishImageView must be .scaleAspectFit. Also, the default setting of Sweetfish uses the CoreMLModels provided by Apple.

let sweetfishImageView = SweetfishImageView()
sweetfishImageView.mlModelType = .deepLabV3
sweetfishImageView.contentMode = .scaleAspectFit
sweetfishImageView.image = UIImage(named: "fish")
sweetfishImageView.delegate = self

Remove background from image

There are 3 segmentation types for Sweetfish.

  • object : You can use this if you want to use the sampled object type.

    sweetfishImageView.clipping(clippingMethod: .object(objectType: .human))
  • selectTouch : If you want to tap a segmented area to select it you can use this.

    sweetfishImageView.clipping(clippingMethod: .selectTouch)
  • selectValue : If you want to segment by value you can use this

    sweetfishImageView.clipping(clippingMethod: .selectValue(value: 16))

Other

// When to use a custom Model.
sweetfishImageView.mlModelType = .custom(model: CustomMLModel)

// When you want to reject the selection.
sweetfishImageView.cancelSelectClipping()

License

Sweetfish is distributed under the terms and conditions of the MIT license.

About

Sweetfish is a UIImageView wrapper library for removing backgrounds using Vision Framework's Image Segmentation 📸 🎣

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published