Skip to main content

Utils for Computer Vision Deep Learning research

Project description

DOI

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lapixdl-0.7.17.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

lapixdl-0.7.17-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file lapixdl-0.7.17.tar.gz.

File metadata

  • Download URL: lapixdl-0.7.17.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for lapixdl-0.7.17.tar.gz
Algorithm Hash digest
SHA256 3b98b5543fe324a300706e0f66915870adeecd6feef8e71181013e2fe6ed61e1
MD5 08e95b3cd56026266e54040a2cdfe82f
BLAKE2b-256 00b1c36f1a657d552c59ed80145c20254eefb0683052d22ebdc1e84a5e37f3ca

See more details on using hashes here.

File details

Details for the file lapixdl-0.7.17-py3-none-any.whl.

File metadata

  • Download URL: lapixdl-0.7.17-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for lapixdl-0.7.17-py3-none-any.whl
Algorithm Hash digest
SHA256 788eac76be612f5d6c1ae6e2bfbaf14e0d47a672266e97fb5770eb6a7c22a829
MD5 d1255c9b0d94fbb6a5dbdd40e7bf0af2
BLAKE2b-256 b09a8079b3cb394db1fd6089ef6a01645ca32483861de7e36ccd4abab2b54c3c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page