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
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 108.9MB
glibcpy 3.10–3.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)
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`.