Images¶
Most Computer Vision models are trained to identify relevant features and reason about the contents of images. When working with Computer Vision data in 3LC, at least one image column is therefore usually present in the Tables you create.
Creating Tables¶
Tables usually store URL references to images without copying them from their original
locations. In 3LC this is referred to as Bulk Data. The Schema therefore declares that it
is a string with the role "URL/Image" to communicate that it points to an image, such that the Dashboard knows to
visualize it as such.
import tlc
table = tlc.Table.from_dict(
data={"image": ["path/to/image0.png", "path/to/image1.png", ...]},
structure={"image": tlc.ImageUrlSchema()},
)
import tlc
table = tlc.Table.from_dict(
data={"image": ["path/to/image0.png", "path/to/image1.png", ...]},
structure={"image": tlc.Schema(value=tlc.StringValue(string_role=tlc.STRING_ROLE_IMAGE_URL))},
)
import tlc
from PIL import Image
table = tlc.Table.from_dict(
data={"image": [Image.open("path/to/image0.png"), Image.open("path/to/image1.png"), ...]},
structure={"image": tlc.PILImage},
)
Image Format Support
Since 3LC Tables store references to images, rather than the images themselves, any image format can be referenced in the Table. The Dashboard is however limited to displaying the formats supported by your web browser. In practice, this means that most common formats can be displayed. For a useful guideline, see the Wikipedia comparison of web browser image format support.
In addition to those supported by your web browser, 3LC supports on-the-fly transcoding of certain formats such that they can be visualized in the Dashboard. Currently, the following cases are supported:
TIFF: Single-frame TIFF images are transcoded to PNG format.
NumPy: Referenced
.npyfiles are instantiated, and when the array is 2D or 3D with a third dimension of 1 (grayscale), 3 (RGB), or 4 (RGBA) channels, it is transcoded to PNG format.
Note that in all cases, the Schema must declare that the column contains image URLs for transcoding to work. For example, transcoding is not invoked for referenced files without the Image URL role.
Several importer methods create Tables with an image column,
notably tlc.Table.from_image_folder(),
tlc.Table.from_coco() and
tlc.Table.from_yolo(). The free-form methods can also be used by
declaring the image schema and providing the images as a list of URLs, like in the examples above.
Visualization¶
The Dashboard provides several ways to visualize image data.
Charts¶
To create an image chart, select the IMAGE column (click the column header),
RightClick on the IMAGE column header, and select Create 2D Chart on the popup
menu. Alternatively, you can press 2 after selecting the IMAGE column.
Viewing images in the Charts panel is useful when you want to visualize images from a single row, and is often visualized with an overlay of geometric labels or predictions, such as bounding boxes or keypoints.
Grid View¶
It is also possible to change the tabular view of the Rows panel and show the rows as a grid. This shows all of the images in a single grid, allowing you to view several at once.
Virtual Columns¶
While images are mostly used for creating charts alongside additional data, it can be useful to derive the string representation of the image as part of debugging where images are stored, why they are not being displayed or if they have aliases. Check the FAQ for how this can be used.