Stingle Object Recognition
Library for detecting objects and recognising faces from image, livePhoto, gif and video using TensorFlow open source library
ImageRecognition is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'ImageRecognition'
How to use
Find or train the best TFLite model file for you and add into your app under assets folder. there are several already trained models to use
Objects recognition examples:
private let objectDetector: ObjectDetector = ObjectDetector()
// runnning object detection on image
self.objectDetector.makePredictions(forImage: image) { predictions in
// ...
}
// runnning object detection on live photo
self.objectDetector.makePredictions(forLivePhoto: livePhoto, maxProcessingImagesCount: 5) { predictions in
// ...
}
// runnning object detection on gif
self.objectDetector.makePredictions(forGIF: url, maxProcessingImagesCount: 5) { predictions in
// ...
}
// runnning object detection on video
let configuration = Configuration(startTime: 0.0, maxProcessingDuration: 1000.0)
self.objectDetector.makePredictions(forVideo: videoURL, configuration: configuration) { predictions in
// ...
}
OR
self.objectDetector.makePredictions(forVideoAsset: asset, configuration: configuration) { predictions in
// ...
}
Face detection examples:
private let faceDetector = FaceDetector()
// runnning face detection on image
self.faceDetector.detectFaces(fromImage: image) { result in
// ...
}
// runnning object detection on live photo
self.faceDetector.detectFaces(fromLivePhoto: livePhoto) { result in
// ...
}
// runnning object detection on gif
self.faceDetector.detectFaces(fromGIF: url) { result in
// ...
}
// runnning object detection on video
let configuration = Configuration(startTime: 0.0, maxProcessingDuration: 1000.0)
self.faceDetector.detectFaces(fromVideo: videoURL, configuration: configuration) { faces in
// ...
}
OR
self.faceDetector.detectFaces(videoAsset: asset, configuration: configuration) { faces in
// ...
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
ImageRecognition is available under the MIT license. See the LICENSE file for more info.