-
Notifications
You must be signed in to change notification settings - Fork 46
Image
Douglas Blank edited this page Oct 24, 2022
·
8 revisions
class Image(Asset)
An Image asset.
def __init__(data=None,
name=None,
format="png",
scale=1.0,
shape=None,
colormap=None,
minmax=None,
channels="last",
metadata=None,
source=None,
unserialize=False)
Logs the image.
Arguments:
-
data
- Required if source not given. data is one of the following:- a path (string) to an image
- a file-like object containing an image
- a numpy matrix
- a TensorFlow tensor
- a PyTorch tensor
- a list or tuple of values
- a PIL Image
-
name
- String - Optional. A custom name to be displayed on the dashboard. If not provided the filename from thedata
argument will be used if it is a path. -
format
- Optional. String. Default: 'png'. If the data is actually something that can be turned into an image, this is the format used. Typical values include 'png' and 'jpg'. -
scale
- Optional. Float. Default: 1.0. If the data is actually something that can be turned into an image, this will be the new scale of the image. -
shape
- Optional. Tuple. Default: None. If the data is actually something that can be turned into an image, this is the new shape of the array. Dimensions are (width, height) or (width, height, colors) wherecolors
is 3 (RGB) or 1 (grayscale). -
colormap
- Optional. String. If the data is actually something that can be turned into an image, this is the colormap used to colorize the matrix. -
minmax
- Optional. (Number, Number). If the data is actually something that can be turned into an image, this is the (min, max) used to scale the values. Otherwise, the image is autoscaled between (array.min, array.max). -
channels
- Optional. Default 'last'. If the data is actually something that can be turned into an image, this is the setting that indicates where the color information is in the format of the 2D data. 'last' indicates that the data is in (rows, columns, channels) where 'first' indicates (channels, rows, columns).
def to_pil()
Return the image as a Python Image Library (PIL) image.
Example:
>>> import kangas as kg
>>> image = kg.Image("filename.jpg").to_pil()
>>> image.show()
def show()
Show the image.
def convert_to_source(filename=None)
A PNG filename to save the loaded image.
Under development.
def add_regions(label, *regions, score=None)
Add polygon regions to an image.
Arguments:
-
label
- (str) the label for the regions -
regions
- list or tuples of at least 3 points -
score
- (optional, number) a score associated with the region.
Example:
>>> image = Image()
>>> image.add_regions("car", [(x1, y1), ...], [(x2, y2), ...])
def add_bounding_boxes(label, *boxes, score=None)
Add bounding boxes to an image.
Arguments:
-
label
- (str) the label for the regions -
boxes
- list or tuples of exactly 2 points (top-left, bottom-right) -
score
- (optional, number) a score associated with the region.
Example:
>>> image = Image()
>>> box1 = [(x1, y1), (x2, y2)]
>>> box2 = [(x1, y1), (x2, y2)]
>>> image.add_bounding_boxes("Person", box1, box2, ...)
def add_mask(label, image)
Add a mask to an image.
Under development.
Example:
>>> image = Image()
>>> image.add_mask("attention", Image(MASK))
def add_annotations(text, anchor, *points, score=None)
Add an annotation to an image.
Under development.
Example:
>>> image = Image()
>>> image.add_annotations("Tumors", (50, 50), (100, 100), (200, 200), ...)
Kangas DataGrid is completely open source; sponsored by Comet ML
-
Home
- User Guides
- Installation - installing kangas
- Reading data - importing data
- Constructing DataGrids - building from scratch
- Exploring data - exploration and analysis
- Examples - scripts and notebooks
- Kangas Command-Line Interface
- Kangas Python API
- Integrations - with Hugging Face and Comet
- User Interface
- FAQ - Frequently Asked Questions
- Under the Hood
- Security - issues related to security
- Development - setting up a development environment
- Roadmap - plans and known issues
- User Guides