The Abraia SDK and CLI is a Python package which provides a set of tools to develop and deploy advanced Machine Learning image applications on the edge. Moreover, with Abraia DeepLab you can easily annotate and train, your own versions of some of the best state of the art deep learning models, and get them ready to deploy with this Python SDK.
Just install the Abraia SDK and CLI on Windows, Mac, or Linux:
python -m pip install -U abraia
And start working with deep learning models ready to work on your local devices.
Annotate your images and train a state-of-the-art model for classification, detection, or segmentation using DeepLab. You can directly load and run the model on the edge using the browser or this Python SDK.
Detect objects with a pre-trained YOLOv8 model on images, videos, or even camera streams.
from abraia.inference import detect
model_uri = f"multiple/models/yolov8n.onnx"
model = detect.load_model(model_uri)
img = detect.load_image('people-walking.png')
results = model.run(img, conf_threshold=0.5, iou_threshold=0.5)
img = detect.render_results(img, results)
detect.show_image(img)
To run a multi-object detector on video or directly on a camera stream, you just need to use the Video class to process every frame as is done for images.
from abraia.inference import detect
model_uri = f"multiple/models/yolov8n.onnx"
model = detect.load_model(model_uri)
video = detect.Video('people-walking.mp4')
for frame in video:
results = model.run(frame, conf_threshold=0.5, iou_threshold=0.5)
frame = detect.render_results(frame, results)
video.show(frame)
Identify people on images with face recognition as shown bellow.
import os
from abraia.inference import FaceRecognizer
from abraia.utils import load_image, save_image, render_results
img = load_image('images/rolling-stones.jpg')
out = img.copy()
recognition = FaceRecognizer()
results = recognition.represent_faces(img)
index = []
for src in ['mick-jagger.jpg', 'keith-richards.jpg', 'ronnie-wood.jpg', 'charlie-watts.jpg']:
img = load_image(f"images/{src}")
rslt = recognition.represent_faces(img)[0]
index.append({'name': os.path.splitext(src)[0], 'embeddings': rslt['embeddings']})
result = recognition.identify_faces(results, index)
render_results(out, results)
save_image(out, 'images/rolling-stones-identified.jpg')
Automatically recognize car license plates in images and video streams.
from abraia.inference import PlateRecognizer
from abraia.utils import load_image, show_image, render_results
alpr = PlateRecognizer()
img = load_image('images/car.jpg')
results = alpr.detect(img)
results = alpr.recognize(img, results)
results = [result for result in results if len(result['lines'])]
for result in results:
result['label'] = '\n'.join([line.get('text', '') for line in result['lines']])
del result['confidence']
frame = render_results(img, results)
show_image(img)
Model to predict gender and age. It can be useful to anonymize minors faces.
from abraia.inference import FaceRecognizer, FaceAttribute
from abraia.utils import load_image, show_image, render_results
recognition = FaceRecognizer()
attribute = FaceAttribute()
img = load_image('images/image.jpg')
results = recognition.detect_faces(img)
faces = recognition.extract_faces(img, results)
for face, result in zip(faces, results):
gender, age, score = attribute.predict(face)
result['label'] = f"{gender} {age}"
result['confidence'] = score
img = render_results(img, results)
show_image(img)
The Abraia CLI provides access to the Abraia Cloud Platform through the command line. It makes simple to manage your files and enables bulk image editing capabilities. It provides and easy way to resize, convert, and compress your images - JPEG, WebP, or PNG -, and get them ready to publish on the web. Moreover, you can automatically remove the background, upscale, or anonymize your images in bulk.
Remove unwanted objects in images and photos locally. Just click on the object to automatically select and delete it from the image. Finally, press "s" to save the output image.
abraia editing clean dog.jpg
Automatically remove images background and make them transparent in bulk.
abraia editing removebg "*.jpg"
Automatically blur the images background to focus attentioin on the main objects.
abraia editing blur "*.jpg"
Scale up and enhance images in bulk, doubling the size and preserving quality.
abraia editing upscale "*.jpg"
Automatically blur car license plates and faces to anonymize images in bulk.
abraia editing anonymize "*.jpg"
Compress images in bulk specifying the input glob pattern or folder:
abraia editing convert "images/bird*.jpg"
Automatically change the aspect ratio specifying both width
and height
parameters and setting the resize mode
(pad, crop, thumb). Or simply resize images maintaining the aspect ratio just specifying the width
or the height
of the new image:
abraia editing convert images/birds.jpg --width 375 --height 375 --mode pad
abraia editing convert images/birds.jpg --width 375 --height 375
abraia editing convert images/birds.jpg --width 750
So, you can automatically resize all the images in a specific folder preserving the aspect ration of each image just specifying the target width
or height
:
abraia editing convert [src] --width 300
Or, automatically pad or crop all the images contained in the folder specifying both width
and height
:
abraia editing convert [src] --width 300 --height 300 --mode crop
The Multiple extension provides seamless integration of multispectral and hyperspectral images. It has being developed by ABRAIA in the Multiple project to extend the Abraia SDK and Cloud Platform providing support for straightforward HyperSpectral Image (HSI) analysis and classification.
Just click on one of the available Colab's notebooks to directly start testing the multispectral capabilities:
Or install the multiple extension to use the Abraia-Multiple SDK:
python -m pip install -U "abraia[multiple]"
To use the SDK you have to configure your Id and Key as environment variables:
export ABRAIA_ID=user_id
export ABRAIA_KEY=user_key
On Windows you need to use set
instead of export
:
set ABRAIA_ID=user_id
set ABRAIA_KEY=user_key
Then, you will be able to directly load and save ENVI files, and their metadata.
from abraia.multiple import Multiple
multiple = Multiple()
img = multiple.load_image('test.hdr')
meta = multiple.load_metadata('test.hdr')
multiple.save_image('test.hdr', img, metadata=meta)
To start with, we may upload some data directly using the graphical interface, or using the multiple api:
multiple.upload_file('PaviaU.mat')
Now, we can load the hyperspectral image data (HSI cube) directly from the cloud:
img = multiple.load_image('PaviaU.mat')
Hyperspectral images cannot be directly visualized, so we can get some random bands from our HSI cube, and visualize these bands as like any other monochannel image.
from abraia.multiple import hsi
imgs, indexes = hsi.random(img)
hsi.plot_images(imgs, cmap='jet')
A common operation with spectral images is to reduce the dimensionality, applying principal components analysis (PCA). We can get the first three principal components into a three bands pseudoimage, and visualize this pseudoimage.
pc_img = hsi.principal_components(img)
hsi.plot_image(pc_img, 'Principal components')
Two classification models are directly available for automatic identification on hysperspectral images. One is based on support vector machines ('svm') while the other is based on deep image classification ('hsn'). Both models are available under a simple interface like bellow:
n_bands, n_classes = 30, 17
model = hsi.create_model('hsn', (25, 25, n_bands), n_classes)
model.train(X, y, train_ratio=0.3, epochs=5)
y_pred = model.predict(X)
This software is licensed under the MIT License. View the license.