tflite_image
Version, currently 1.2.04 versions
- 2.0.0latestSep 20, 2023
- 1.2.0not indexedFeb 22, 2024
- 1.1.0not indexedFeb 22, 2024
- 1.0.0not indexedFeb 22, 2024
github.com/spider-gazelle/tflite_image
image classification and feature detection with tflite and crystal lang
Nothing has been indexed for 1.2.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
tflite_image:
github: spider-gazelle/tflite_image
version: ~> 1.2.0Then run:
shards installshard.yml
No shard.yml has been indexed for 1.2.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
Tensorflow Lite image tools
a library for image classification and feature detection with tflite and crystal lang
Installation
-
Add the dependency to your
shard.yml:dependencies: tflite_image: github: spider-gazelle/tflite_image -
Run
shards install
Usage
Image classification
require "tflite_image"
# init the tensorflow client with your classification model
client = TensorflowLite::Client.new("./models/classifier.tflite")
# init the classifier
classifier = TensorflowLite::Image::Classification.new(client)
# load your image
canvas = StumpyJPEG.read("./some_image.jpg")
# run the model, outputs the scaled image that was run through the model
scaled_canvas, detections = classifier.run canvas
# parse the outputs
puts detections.inspect
Object detection
require "tflite_image"
# init the tensorflow client with your object detection model
client = TensorflowLite::Client.new("./models/detector.tflite")
# init the detector
detector = TensorflowLite::Image::ObjectDetection.new(client, scale_mode: :cover)
# load your image
canvas = StumpyJPEG.read("./some_image.jpg")
# run the model, outputs the scaled image that was run through the model
scaled_canvas, detections = detector.run canvas
# parse the outputs
puts detections.inspect
# markup the image with bounding boxes and save the output:
# ========================================================
# we need to apply offsets to the detections
# as they apply to the scaled_canvas
# so they need adjustment to be mapped back onto the original image
offsets = detector.detection_adjustments(canvas)
detector.markup canvas, detections, *offsets
StumpyPNG.write(canvas, "./bin/detection_output.png")
Pose detection
require "tflite_image"
# init the tensorflow client with your object detection model
client = TensorflowLite::Client.new("./models/pose.tflite")
# init the detector
pose = TensorflowLite::Image::PoseEstimation.new(client)
# load your image
canvas = StumpyJPEG.read("./person_image.jpg")
# run the model, outputs the scaled image that was run through the model
scaled_canvas, detections = pose.run canvas
# parse the outputs
puts detections.inspect
# markup the image with a skeleton and save the output:
# ========================================================
# we need to apply offsets to the detections
# as they apply to the scaled_canvas
# so they need adjustment to be mapped back onto the original image
offsets = pose.detection_adjustments(canvas)
pose.markup canvas, detections, *offsets
StumpyPNG.write(canvas, "./bin/pose_output.png")
Image Segmentation
require "tflite_image"
# init the tensorflow client with your object detection model
client = TensorflowLite::Client.new(
model: URI.parse("https://raw.githubusercontent.com/google-coral/test_data/master/deeplabv3_mnv2_pascal_quant.tflite"),
labels: URI.parse("https://raw.githubusercontent.com/google-coral/test_data/master/pascal_voc_segmentation_labels.txt")
)
# init the segmentation
seg = Segmentation.new(client)
# load your image
canvas = StumpyJPEG.read("./image.jpg")
# run the model, outputs the scaled image that was run through the model
scaled_canvas, detections = seg.run canvas
scaled_mask = seg.build_image_mask detections
# parse the outputs
puts "Unique objects found! pixels: #{detections.pixels.size}, unique: #{detections.labels_detected}"
# scale the mask to match the input image
# ========================================================
# create a mask for the original image
offsets = pose.detection_adjustments(canvas)
mask = seg.scale_image_mask(canvas, scaled_mask, *offsets)
StumpyPNG.write(mask, "./bin/mask.png")
# overlay the mask onto the original image
canvas.paste(mask, 0, 0)
StumpyPNG.write(canvas, "./bin/masked_image.png")
Contributing
- Fork it (https://github.com/spider-gazelle/tflite_image/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Stephen von Takach - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
1.2.0- Tagged
- Feb 22, 2024
- Commit
0f3ef6cedb6e- Indexed
- not yet
Dependents
Repository
github.com/spider-gazelle/tflite_image
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 15, 2026
- Synced
- Aug 15, 2026
- Versions
- 4