Utils for Computer Vision Deep Learning research
Project description
LAPiX DL - Utils for Computer Vision Deep Learning research
This package contains utilitary functions to support train and evaluation of Deep Learning models applied to images.
Three computer vision approaches are covered: Segmentation, Detection and Classification.
How to use
For Model Evaluation
This module exports the following functions for model evaluation:
from lapixdl.evaluation.evaluate import evaluate_segmentation
from lapixdl.evaluation.evaluate import evaluate_detection
from lapixdl.evaluation.evaluate import evaluate_classification
All model evaluation methods need two iterators: one for the ground truth itens and one for the predictions.
These iterators must be sorted equaly, assuring that the ground truth and the prediction of the same sample are at the same position.
Example of segmentation model evaluation using PyTorch:
from lapixdl.evaluation.evaluate import evaluate_segmentation
classes = ['background', 'object']
# Iterator for GT masks
# `dl` is a PyTorch DataLoader
def gt_mask_iterator_from_dl(dl):
for imgs, masks in iter(dl):
for mask in masks:
yield mask
# Iterator for prediction masks
# `predict` a function that, given an image, predicts the mask.
def pred_mask_iterator_from_dl(dl, predict):
for imgs, masks in iter(dl):
for img in imgs:
yield predict(img)
gt_masks = gt_mask_iterator_from_dl(validation_dl)
pred_masks = pred_mask_iterator_from_dl(validation_dl, prediction_function)
# Calculates and shows metrics
eval = evaluate_segmentation(gt_masks, pred_masks, classes)
# Shows confusion matrix and returns its Figure and Axes
fig, axes = eval.show_confusion_matrix()
For Results Visualization
This module exports the following functions for results visualization:
from lapixdl.evaluation.visualize import show_segmentations
from lapixdl.evaluation.visualize import show_classifications
from lapixdl.evaluation.visualize import show_detections
The available color maps are the ones from matplotlib.
For Data Conversion
This module exports the following functions for data conversion:
from lapixdl.convert.labelbox import labelbox_to_coco
Example of conversion from Labelbox to COCO labels format:
import json
from lapixdl.convert.labelbox import labelbox_to_coco
# Loads Labelbox json
with open('./labelbox.json') as in_file:
labelbox_file = json.load(in_file)
# Converts it
coco_dict = labelbox_to_coco(labelbox_file)
# Saves converted json
with open('./coco.json', 'w') as out_file:
json.dump(coco_dict, out_file)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lapixdl-0.7.13.tar.gz
.
File metadata
- Download URL: lapixdl-0.7.13.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee4fa16b6e78f7a767fdb1b7bc262c6064505bd382b7a9b30ee4d7cddc3b6392 |
|
MD5 | 4438f78396b4c12b8d0f7d08221bb29b |
|
BLAKE2b-256 | c26d60d4404d84b0b229b80100f2933739dd0e0b4a51fb38385cc75e01f14393 |
File details
Details for the file lapixdl-0.7.13-py3-none-any.whl
.
File metadata
- Download URL: lapixdl-0.7.13-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68c8be2c8205115910566481660b466e26cce35cecc3e42f53e64da0d88fd297 |
|
MD5 | 9568712e9b05954e493a1769a29b0261 |
|
BLAKE2b-256 | 460b775f9fc4ab2610f543f60c9b33717b1383fa6a2b722a206561ee7400210c |