jupyter-paint-segment
Overview
A jupyter widget for interactive drawing segmentation masks.
Brush, rectangle and eraser tools are available. Size of brush and eraser can be changed using slider.
Installation
pip install jupyter_paint_segment
requires: python >= 3.9
Usage
Demo notebook: ./examples/main.ipynb
- Load image into numpy array:
# with PIL:
from PIL import Image
import numpy as np
pilImage = Image.open("./examples/images/sheeps.png")
image = np.array(pilImage)
# or with opencv:
import cv2 as cv
image_bgr = cv.imread("./examples/images/sheeps.png")
image = cv.cvtColor(image_bgr, cv.COLOR_BGR2RGB)
- Define labels and colors (optionally) and create widget:
from jupyter_paint_segment import SegmentWidget
widget = SegmentWidget(
image=image,
labels=["sheep", "dog"],
colors=["red", "blue"],
image_scale=1,
)
widget
- Get segmentation results:
labels_array, labels_map = widget.segmentation_result()
labels_map
# {'sheep': 1, 'dog': 2, 'unlabeled_background': 0}
labels_array
# array([[0, 0, 0, ..., 0, 0, 0],
# [0, 0, 0, ..., 0, 0, 0],
# [0, 0, 0, ..., 0, 0, 0],
# ...,
# [0, 0, 0, ..., 0, 0, 0],
# [0, 0, 0, ..., 0, 0, 0],
# [0, 0, 0, ..., 0, 0, 0]])
import matplotlib.pyplot as plt
plt.imshow(labels_array)
Related projects
This project was highly inspired by jupyter-bbox-widget.
License
This project is licensed under the MIT license.
Metadata
Release files for jupyter_paint_segment 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jupyter_paint_segment-0.1.0.tar.gz | 13.8 kB | Without provenance | Details for jupyter_paint_segment-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jupyter_paint_segment-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for jupyter_paint_segment-0.1.0-py3-none-any.whl |
Total release size: 31.1 kB
Release files / jupyter_paint_segment-0.1.0.tar.gz
| Download URL | jupyter_paint_segment-0.1.0.tar.gz |
|---|---|
| Size | 13.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a9dcc9774f848b301eeaafb122c8aaf4a90a5cabb3f6ab1d6a0933b3571109f
|
|
BLAKE2b-256 checksum How to use checksums |
6032118a465e110f58aaa8c34c920d76f52ae176ca2bbe0a216688e2883a9163
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.8.10 Linux/5.15.167.4-microsoft-standard-WSL2
|
Release files / jupyter_paint_segment-0.1.0-py3-none-any.whl
| Download URL | jupyter_paint_segment-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0f768adf48e758e18b0100cb6eae648af0ba203b90a66eb93dd07cc3b8ec21a
|
|
BLAKE2b-256 checksum How to use checksums |
989cada534246e07734ae2eac97335f54305aea4ac6c38bbf3bc346a3cf2955f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.8.10 Linux/5.15.167.4-microsoft-standard-WSL2
|
Security for jupyter_paint_segment 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.