Registry / ai-ml / lightly-utils

lightly-utils

JSON →
library0.0.2pypypi✓ verified 83d ago

A utility package for the Lightly computer vision framework, providing helper functions primarily for data reformatting, such as preparing bounding box annotations for web visualization. It is currently at version 0.0.2 and has an irregular release cadence, often tied to releases of the main `lightly` library.

pip install lightly-utils
INSTALL
IMPORT
SIG · LIGHTLY-UTILS
L
lightly-utils
ai-mlpythonv0.0.2
Install
4.2s avg
Import
Disk
109MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 108.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 4.2s · import 0.000s · 106MB
109MB installed
● package 109MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

image_processing
from lightly_utils import image_processing
from lightly_utils import reformat_for_web

This quickstart demonstrates how to use the `reformat_for_web` function to convert a list of annotations and an image path into a format suitable for web visualization, saving the output to a specified directory. It creates a dummy image and annotations for a runnable example.

import os import numpy as np from PIL import Image from lightly_utils import reformat_for_web # 1. Create a dummy image file for demonstration image_filename = "dummy_image.jpg" Image.fromarray(np.zeros((100, 100, 3), dtype=np.uint8)).save(image_filename) # 2. Define dummy annotations in the expected format # Each dictionary represents annotations for one image. # 'boxes': list of [x_norm, y_norm, width_norm, height_norm] # 'labels': list of integer class IDs annotations = [ {'boxes': [[0.1, 0.2, 0.3, 0.4], [0.5, 0.6, 0.1, 0.1]], 'labels': [0, 1]}, # In a real scenario, you'd have more entries for more images ] # 3. Define an output directory output_dir = "output_web_visuals" os.makedirs(output_dir, exist_ok=True) # 4. Call the utility function to reformat data for web visualization print(f"Reformatting annotations for image: {image_filename}") reformat_for_web( annotations=annotations, # This assumes one image's annotations for simplicity image_path=image_filename, output_dir=output_dir, ) print(f"Web-ready data (e.g., image.json) has been written to: {os.path.abspath(output_dir)}") # Optional: Clean up created files/directories # os.remove(image_filename) # import shutil # shutil.rmtree(output_dir)
Debug
Known issues
gotchaDespite living in the same GitHub monorepo, `lightly-utils` is a separate PyPI package from the main `lightly` library. Trying to import utilities directly from `lightly.utils` will result in an `AttributeError` or `ModuleNotFoundError`.
fix
Ensure you have `lightly-utils` installed via `pip install lightly-utils` and import directly: `from lightly_utils import ...`.
affects: 0.0.1, 0.0.2
gotchaThe `reformat_for_web` function creates files within the specified `output_dir`. If the directory does not exist or the Python process lacks write permissions, a `FileNotFoundError` or `PermissionError` will occur.
fix
Always ensure the `output_dir` exists before calling `reformat_for_web` using `os.makedirs(output_dir, exist_ok=True)` and verify write permissions for the process.
affects: 0.0.1, 0.0.2
gotchaThe `annotations` parameter for `reformat_for_web` expects a very specific list of dictionaries format, with keys like 'boxes' and 'labels'. Providing an incorrectly structured input will lead to `KeyError` or other runtime errors.
fix
Refer to the function's docstring or source code for the exact expected format. A typical entry looks like `{'boxes': [[x_norm, y_norm, w_norm, h_norm]], 'labels': [0]}`.
affects: 0.0.1, 0.0.2
Upgrade
Version history
0.0.2latest on PyPI · released Jul 8, 2021
Audit
Dependencies
PillowrequiredRequired for image processing operations within `reformat_for_web`.
numpyrequiredRequired for numerical operations, particularly array handling in `reformat_for_web`.
lightlyrequiredThe core Lightly library, which `lightly-utils` complements. Declared in `setup.cfg`.
Agent activity
8 hits · last 30 days
node
8
Resources
lightly-utils — pip install lightly-utils · libregistry