class TensorflowLite::Image::FaceDetection

Included Modules

Defined in:

tflite_image/face_detection.cr

Instance Method Summary

Instance methods inherited from module TensorflowLite::Image::Common

client : Client client, detection_adjustments(image : Canvas, scale_mode : Scale = @scaling_mode)
detection_adjustments(image_width : Int32, image_height : Int32, scale_mode : Scale = @scaling_mode)
detection_adjustments
, input_format : Format input_format, labels : Array(String) labels, resolution : Tuple(Int32, Int32) resolution, run(canvas : Canvas, scale_mode : Scale = @scaling_mode, resize_method : StumpyResize::InterpolationMethod = :bilinear) run, scaling_mode : Scale scaling_mode, scaling_mode=(scaling_mode : Scale) scaling_mode=

Constructor methods inherited from module TensorflowLite::Image::Common

new(client : Client, labels : Array(String) | Nil = nil, scaling_mode : Scale = DEFAULT_SCALE_MODE, input_format : Format | Nil = nil, output_format : Format | Nil = nil) new

Instance Method Detail

def adjust(detections : Array(Output), target_width : Int32, target_height : Int32, offset_left : Int32, offset_top : Int32) : Array(Output) #

adjust the detections so they can be applied directly to the source image (or a scaled version in the same aspect ratio)

you can run detection_adjustments just once and then apply them to detections for each invokation using this function


[View source]
def adjust(detections : Array(Output), image : Canvas, offset_left : Int32, offset_top : Int32) : Array(Output) #

adjust the detections so they can be applied directly to the source image (or a scaled version in the same aspect ratio)

you can run detection_adjustments just once and then apply them to detections for each invokation using this function


[View source]
def anchors : Array(Anchor) #

[View source]
def confidence_threshold : Float32 #

[View source]
def confidence_threshold=(confidence_threshold : Float32) #

[View source]
def generate_anchors(strides : Array(Int32), anchor_offset_x : Float64 = 0.5, anchor_offset_y : Float64 = 0.5, aspect_ratios : Array(Float64) = [1.0], scales_per_octave : Int32 = 2, min_scale : Float64 = 0.1, max_scale : Float64 = 0.9) : Array(Anchor) #

This is a trimmed down version of the C++ code; all irrelevant parts have been removed. (reference: mediapipe/calculators/tflite/ssd_anchors_calculator.cc) also: https://github.com/patlevin/face-detection-tflite/blob/main/fdlite/face_detection.py#L58


[View source]
def intersection_over_union(det1 : Output, det2 : Output) : Float32 #

[View source]
def markup(image : Canvas, detections : Array(Output), minimum_score : Float32 = 0.3_f32, font : PCFParser::Font | Nil = nil) : Canvas #

add the detection details to an image

if marking up the original image, you'll need to take into account how it was scaled


[View source]
def nms_similarity_threshold : Float32 #

[View source]
def nms_similarity_threshold=(nms_similarity_threshold : Float32) #

[View source]
def non_maximum_suppression(detections : Array(Output), iou_threshold : Float32) : Array(Output) #

[View source]
def process(image : Canvas) : Tuple(Canvas, Array(Output)) #

attempts to classify the object, assumes the image has already been prepared


[View source]
def sigmoid(data : Slice(Float32)) : Slice(Float32) #

Mapping to (0,1) score limit is 100 in mediapipe and leads to overflows with IEEE 754 floats this lower limit is safe for use with the sigmoid functions and float32


[View source]