Skip to content

ADescribe · segment.semantic

Semantic segmentation (DeepLabV3, 20 classes)

Which pixels of each image show people, animals, vehicles or furniture, and how much of the image does each class cover?

Labels every pixel of every image in a column with one of the 20 Pascal VOC classes (person, cat, car, chair, sofa, …) or background, using a pretrained DeepLabV3 ResNet-50 (torchvision's weights trained on COCO with the VOC classes, converted once to safetensors and a one-time download you approve). Results: the share of pixels each class covers per image and on average, how many images show each class, a gallery with the class masks over the images, and a table with one row per image and class (its mask as COCO run-length encoding, its box, its pixel count and mean confidence) you can save as a dataset. Python and R run the same network and give the same pixels.

Experimental Python and R agree to 6 decimals Also called semantic segmentation, DeepLabV3, pixel classification…

A real result

Example “Defaults small”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Semantic segmentation (DeepLabV3, 20 classes)Recorded · Python and R agreeRecorded 2026-11-25 · 29 values compared
R

3 classes found in 3 of 5 images; background covers 55.9% of an image on average.

Images
5
Classes found
3
Regions
3
Background
55.9%

Plots

Class masksWhat did the detector or segmenter find in each image, and where exactly?
View data
Height (px)ImageClassMask (COCO RLE)Media idMean confidenceWidth (px)x0x1y0y1
160cat.pngcatQ2o2Q200000O100O1O1O1O1N2O1M3N2YOg0H8N2K5LThg0IWXXO1O0000000000O]V1NbiN9I3N3L4M2L5L3XN]OnNg0o0AgNe0V1@`Ng0]1a1M2M4^NQMm0b3N3L3N3J7J;G2M3MSk40eaeb6793ad08de630a090bbf7b187aa30acbc292e63d298d3ff0338cec02a500.966424002090160
160cup.pngdiningtableW1i3W100000O1O10000O1O100O100O1O100O1O100O100O1O1O1O1O100O1O100N200O100N200O1O100O1O1O1O100O1O100O1O1O1O100O10PRm00f2f46f52111cb7dc1a71df8df67fa7af376bf66c5304888c767b881a4c9c6a60.941324002400160
192astronaut.pngpersoniR14c0O\4T1H3L4B?I8I4K5O1N2M3O1N2M300N2O1N2O1M3O1N2N2O100N2O100O1O100O1O1O1O100N2O1N2O1N2O1N2N2N200N2O100O100O1QOQLLP41ULMk31ZLLf32^LLb32aLM_33bLL^33eLJ\35fLI[36hLGY39W100O1O1O100O1O100O1000000O100000000O100000000001O0000001O0000001O1hKO_21aM0^21`M1_2O_M5_2K_M7a2J]M8b2I[M:d2GZM:f2FZM;e2HVM<h2DWM>h2DUM>j2EPM`0n2DlL?S3EfL`0X3X1L1O2N1SOXM`Nh2^1[MaNf2\1\MdNd2Y1bMRNF;i2`1lMZNX2d1S1M4N2M3L4M4M3L3N3N3J5N2M5J3N2M]P:f37291cf2c47100683468e90bd3810c1f03d64d8eb9c51f8972c9160a9de5d220.939219251387192
150shapes.png——fb6409af86ab2ef69eff6ef058e1227929f5a75ad407435a729a370097b2578c—200————
48flat.png——81d0ef9f87003b2a8f4726bd99d84744e070a37fc2ba0a63f1537fd951587a11—64————
Images showing each classHow often does each category occur?
View data
Class
cat
diningtable
person

Assumptions

  • 20 Pascal VOC classes — Pixels of anything outside the 20 classes become background or the nearest class.
  • One class per pixel — Overlapping objects of the same class merge into one region; use instance segmentation to count objects.
  • Labeled at the segmentation size — Classes are decided with the short side at 256 px and enlarged to each image by nearest neighbor.
  • Photos like COCO's — The model learned from everyday photos; other kinds of images need a model trained on them.

Classes

ClassImagesMean share of pixelsMean confidence
cat115.9%0.9664
diningtable119.4%0.9413
person18.8%0.9392

Classes per image

RowFileRegionsClassesBackground
1cat.png1cat20.3%
2cup.png1diningtable3.2%
3astronaut.png1person55.9%
4shapes.png0100.0%
5flat.png0100.0%
  • 1 rows have no path and are left out.
  • 1 files could not be decoded and are left out.
Python

3 classes found in 3 of 5 images; background covers 55.9% of an image on average.

Images
5
Classes found
3
Regions
3
Background
55.9%

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • 20 Pascal VOC classes — Pixels of anything outside the 20 classes become background or the nearest class.
  • One class per pixel — Overlapping objects of the same class merge into one region; use instance segmentation to count objects.
  • Labeled at the segmentation size — Classes are decided with the short side at 256 px and enlarged to each image by nearest neighbor.
  • Photos like COCO's — The model learned from everyday photos; other kinds of images need a model trained on them.

Classes

ClassImagesMean share of pixelsMean confidence
cat115.9%0.9664
diningtable119.4%0.9413
person18.8%0.9392

Classes per image

RowFileRegionsClassesBackground
1cat.png1cat20.3%
2cup.png1diningtable3.2%
3astronaut.png1person55.9%
4shapes.png0100.0%
5flat.png0100.0%
  • 1 rows have no path and are left out.
  • 1 files could not be decoded and are left out.

Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.

Worked examples in the app

  • Defaults smallimg3_photos · image: path
  • Classes min shareimg3_photos · image: path
  • Degenerate all naimg3_photos · image: path
  • No objects foundimg3_photos · image: path
  • Degenerate no readable imageimg3_unreadable · image: path

In the guides

Where it sits in the decision guides

  • Multimodal data exploration (text, image, video) · DS & ML Decision Guide · Describe — summarize and visualize

What you need

Image pathcategorical · 1 column
A column of image file paths, such as the path column of an image folder (Data → Add image folder…). PNG, JPEG, WebP, GIF, BMP and TIFF are read.

Choices you make

options

Segmentation size (short side)default 520

Each image is resized so its short side is this many pixels before labeling (520 is what the model was evaluated at). Smaller is faster and coarser.

Classes to keepdefault

Report only these classes as regions. None selected keeps all 20; pixel shares still count every class.

  • Person — Keep only this Pascal VOC class (people).
  • Airplane — Keep only this Pascal VOC class (vehicles).
  • Bicycle — Keep only this Pascal VOC class (vehicles).
  • Boat — Keep only this Pascal VOC class (vehicles).
  • Bus — Keep only this Pascal VOC class (vehicles).
  • Car — Keep only this Pascal VOC class (vehicles).
  • Motorcycle — Keep only this Pascal VOC class (vehicles).
  • Train — Keep only this Pascal VOC class (vehicles).
  • Bird — Keep only this Pascal VOC class (animals).
  • Cat — Keep only this Pascal VOC class (animals).
  • Cow — Keep only this Pascal VOC class (animals).
  • Dog — Keep only this Pascal VOC class (animals).
  • Horse — Keep only this Pascal VOC class (animals).
  • Sheep — Keep only this Pascal VOC class (animals).
  • Bottle — Keep only this Pascal VOC class (indoor).
  • Chair — Keep only this Pascal VOC class (indoor).
  • Dining table — Keep only this Pascal VOC class (indoor).
  • Potted plant — Keep only this Pascal VOC class (indoor).
  • Sofa — Keep only this Pascal VOC class (indoor).
  • TV or monitor — Keep only this Pascal VOC class (indoor).
Smallest region (share of image)default 0

Regions covering less than this share of an image's pixels are left out of the table (for example 0.01 for 1%). 0 keeps every region.

Advanced

Compute profiledefault parity

How precisely the network runs. Parity matches the other engine; Faster CPU is several times faster and can move edge pixels.

  • Parity(default) — Double precision on one CPU thread: the same pixels in Python and R, run after run (the default).
  • Faster CPU — Single precision on all performance cores; repeatable on this Mac, a few edge pixels can differ from Parity.

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • 20 Pascal VOC classes

    Pixels of anything outside the 20 classes become background or the nearest class.

  • One class per pixel

    Overlapping objects of the same class merge into one region; use instance segmentation to count objects.

  • Labeled at the segmentation size

    Classes are decided at the segmentation size and enlarged to the original by nearest neighbor, so edges are blocky on large images.

  • Photos like COCO's

    The model learned from everyday photos; other kinds of images need a model trained on them.

What it reports

n_rows
Rows whose image file could be decoded; rows without a path and files that can't be decoded are counted and left out.
n_images
Rows whose image file could be decoded; rows without a path and files that can't be decoded are counted and left out.
n_no_path
Rows whose image file could be decoded; rows without a path and files that can't be decoded are counted and left out.
n_unreadable
Rows whose image file could be decoded; rows without a path and files that can't be decoded are counted and left out.
n_objects
Giving every pixel a class (person, cat, sofa…) or background; objects of one class merge into one region.
n_images_with_objects
Giving every pixel a class (person, cat, sofa…) or background; objects of one class merge into one region.
share_with_objects
Giving every pixel a class (person, cat, sofa…) or background; objects of one class merge into one region.
n_classes
Giving every pixel a class (person, cat, sofa…) or background; objects of one class merge into one region.
objects_per_image
Giving every pixel a class (person, cat, sofa…) or background; objects of one class merge into one region.
max_per_image
Giving every pixel a class (person, cat, sofa…) or background; objects of one class merge into one region.
score_mean
The share of an image's pixels given to a class (or to background), averaged over the images.
score_min
The share of an image's pixels given to a class (or to background), averaged over the images.
box_check
The sum of every box corner (and of every area): one number that changes when any box does, used to compare runs.
area_check
The sum of every box corner (and of every area): one number that changes when any box does, used to compare runs.
background_mean
The share of an image's pixels given to a class (or to background), averaged over the images.
model
Giving every pixel a class (person, cat, sofa…) or background; objects of one class merge into one region.
size
The short side, in pixels, each image is resized to before detection (long side at most 1,333). Smaller is faster.

Per group, level or term: n[<class>], images[<class>], mean_score[<class>], pixel_share[<class>]

Python and R

Python and R agree to 6 decimals (relative tolerance 1e-9). Python uses torch, torchvision, safetensors, numpy, pandas, codesplash; R uses torch, torchvision, safetensors, nanoparquet, codesplashr.

Default traps between the two languages

  • Python runs torchvision's modules; R runs the CRAN torchvision modules with torchvision's preset written out (antialiased bilinear resize, normalization, nearest-neighbor enlargement), both on the same converted float32 weights in float64 (Parity profile, one thread) — codesplash.vision.detect ↔ codesplashr R/vision_detect.R. On the fixtures every pixel gets the same class; confidences agree to about 1e-16.
  • Two classes exactly tied at a pixel would take the first in both engines. The Faster CPU profile is labeled and not counted as Python ≡ R (decision 65).
  • Without the downloaded weights the run stops with CS_WEIGHTS_MISSING in both engines; nothing is downloaded automatically.
Python

The exact script CodeSplash ran for example “Defaults small” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Semantic segmentation (DeepLabV3, 20 classes)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method segment.semantic 1.0.0 · spec fd2703dc572f68f7
# Dataset: img3_photos (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os

import numpy as np
import pandas as pd

import codesplash as cs
from codesplash import media as cs_media
from codesplash import ml as csml
from codesplash.deep import core as cs_core
from codesplash.deep import profile as cs_profile
from codesplash.vision import boxes as vbox
from codesplash.vision import detect as vdet

ARCH = "deeplabv3_resnet50"
# %% Images listed in the path column
PATH = "path"
df = pd.read_parquet("tests/parity/fixtures/img3_photos.parquet", columns=[PATH])
if not len(df):
    cs.cs_error("CS_E_NO_ROWS")
warnings = []
# %% Media files (image column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
import json as _media_json
from codesplash import media as cs_media
media = cs_media.setup(_media_json.loads("{\"ids_column\":\"media_id\",\"kind\":\"image\",\"path_column\":\"path\",\"role\":\"image\",\"transform\":{\"filter\":\"triangle\",\"fit\":\"within\",\"mode\":\"rgb\",\"normalize\":\"none\",\"size\":[1333,1333]}}"), "target/academy-parity/run-8142/segment.semantic/defaults_small/out-python", df, "tests/parity/fixtures/img3_photos.parquet")
media_ids = cs_media.ids_of(media, df)


def _text(v):
    return None if pd.isna(v) else str(v)  # None, NaN, pd.NA


has_id = [k for k, m in enumerate(media_ids) if m is not None and _text(df[PATH].iloc[k]) not in (None, "")]
if not has_id:
    cs.cs_error("CS_E_ALL_MISSING", column=PATH)
_status = cs_media.status(media, [media_ids[k] for k in has_id])
ok = [k for k, s in zip(has_id, _status) if s is None]
n_no_path = len(df) - len(has_id)
n_unreadable = len(has_id) - len(ok)
if not ok:
    cs.cs_error("CS_E_INVALID_VALUES", column=PATH, requirement="an image file that can be decoded", count=len(has_id))
if n_no_path:
    warnings.append(f"{n_no_path} rows have no path and are left out.")
if n_unreadable:
    warnings.append(f"{n_unreadable} files could not be decoded and are left out.")
items = [{"media_id": media_ids[k], "file": os.path.basename(str(df[PATH].iloc[k])), "row": k} for k in ok]


def load_image(mid):
    """One decoded image (3, h, w) on 0–1 and its size before decoding (orientation applied)."""
    return cs_media.load(media, [mid])[0], tuple(cs_media.source_size(media, [mid])[0])


# %% Pretrained model and compute profile
cs_profile.configure({"profile": "parity"})
cs_core.torch_init()
model = vdet.load(ARCH, dtype=cs_profile.current().dtype)

# %% Label every pixel (torchvision DeepLabV3 on the converted weights, 20 Pascal VOC classes)
SIZE = 256
CLASSES = [] or None
run = vdet.segment_images(model, items, load_image, size=SIZE, classes=CLASSES, min_share=0)
table = run["table"]
s = vdet.summarize(table, run["images"], semantic=True)
values = {"n_rows": len(df), "n_no_path": n_no_path, "n_unreadable": n_unreadable, **s["values"],
          "model": vdet.MODELS[ARCH]["label"], "size": SIZE}

# %% Artifacts: one row per image and class (mask as COCO RLE) and one row per image
out = csml.out_dir("target/academy-parity/run-8142/segment.semantic/defaults_small/out-python")
vbox.write(table, os.path.join(out, "boxes.parquet"))
per = pd.DataFrame([{"row": r["row"] + 1, "media_id": r["media_id"], "file": r["file"], "width": r["width"],
                     "height": r["height"], "regions": r["objects"], "background": r["background"]} for r in run["images"]],
                   columns=["row", "media_id", "file", "width", "height", "regions", "background"])
per.to_parquet(os.path.join(out, "images.parquet"), index=False)

# %% Result
ov = vdet.overlay_columns(table, run["images"])
charts = [cs.chart("overlay", "image-overlay", "Class masks", {
    "image": cs.col("Image", ov["image"], "categorical"),
    "media_id": cs.col("Media id", ov["media_id"], "categorical"),
    "x0": cs.col("x0", ov["x0"], "numeric"), "y0": cs.col("y0", ov["y0"], "numeric"),
    "x1": cs.col("x1", ov["x1"], "numeric"), "y1": cs.col("y1", ov["y1"], "numeric"),
    "label": cs.col("Class", ov["label"], "categorical"),
    "score": cs.col("Mean confidence", ov["score"], "numeric"),
    "mask": cs.col("Mask (COCO RLE)", ov["mask"], "categorical"),
    "width": cs.col("Width (px)", ov["width"], "numeric"), "height": cs.col("Height (px)", ov["height"], "numeric"),
}, controls={"boxes": False})]
if len(table):
    charts.append(cs.chart("classes", "bar", "Images showing each class", {
        "x": cs.col("Class", [str(v) for v in table["label"].tolist()], "categorical", s["order"])}))
assumptions = [
    {"key": "voc_classes", "label": "20 Pascal VOC classes", "status": "info",
     "detail": "Pixels of anything outside the 20 classes become background or the nearest class."},
    {"key": "one_label", "label": "One class per pixel", "status": "info",
     "detail": "Overlapping objects of the same class merge into one region; use instance segmentation to count objects."},
    {"key": "resolution", "label": "Labeled at the segmentation size", "status": "info",
     "detail": f"Classes are decided with the short side at {SIZE} px and enlarged to each image by nearest neighbor."},
    {"key": "domain", "label": "Photos like COCO's", "status": "info",
     "detail": "The model learned from everyday photos; other kinds of images need a model trained on them."},
] + cs_profile.warning_rows()
image_cols = [{"key": "row", "label": "Row", "type": "integer"}, {"key": "file", "label": "File"},
              {"key": "objects", "label": "Regions", "type": "integer"}, {"key": "classes", "label": "Classes"},
              {"key": "background", "label": "Background", "type": "percent"}]
class_cols = [{"key": "class", "label": "Class"}, {"key": "images", "label": "Images", "type": "integer"},
              {"key": "pixel_share", "label": "Mean share of pixels", "type": "percent"},
              {"key": "mean_score", "label": "Mean confidence", "type": "number"}]
cs.publish({
    "title": "Semantic segmentation (DeepLabV3, 20 classes)",
    "engine": cs.engine_info("torch", "torchvision", "numpy", "pandas"),
    "n": values["n_images"],
    "summary": f"{values['n_classes']} classes found in {values['n_images_with_objects']} of {values['n_images']} images; "
               f"background covers {values['background_mean'] * 100:.1f}% of an image on average.",
    "statistics": [
        {"key": "n_images", "label": "Images", "value": values["n_images"], "format": "integer"},
        {"key": "n_classes", "label": "Classes found", "value": values["n_classes"], "format": "integer"},
        {"key": "n_objects", "label": "Regions", "value": values["n_objects"], "format": "integer"},
        {"key": "background_mean", "label": "Background", "value": values["background_mean"], "format": "percent"},
    ],
    "tables": [
        {"key": "classes", "title": "Classes", "columns": class_cols, "rows": s["classes"]},
        {"key": "images", "title": "Classes per image", "columns": image_cols, "rows": s["images"][:200]},
    ],
    "assumptions": assumptions,
    "charts": charts,
    "values": values,
    "warnings": warnings,
    "artifacts": [{"key": "boxes", "path": os.path.join(out, "boxes.parquet"), "format": "parquet"},
                  {"key": "images", "path": os.path.join(out, "images.parquet"), "format": "parquet"}],
})
R

The exact script CodeSplash ran for example “Defaults small” · R version 4.5.1 (2025-06-13)

# Semantic segmentation (DeepLabV3, 20 classes)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method segment.semantic 1.0.0 · spec fd2703dc572f68f7
# Dataset: img3_photos (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

ARCH <- "deeplabv3_resnet50"
# %% Images listed in the path column
PATH <- "path"
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/img3_photos.parquet", col_select = PATH))
if (!nrow(df)) cs_error("CS_E_NO_ROWS")
warnings <- character(0)
# %% Media files (image column path)
# In the app the files were decoded once into float32 arrays (media.json in the run folder). Elsewhere they are
# decoded here the same way: PNG and WAV give the app's values; JPEG, MP3 and other lossy files can differ slightly.
media <- cs_media_setup(jsonlite::fromJSON("{\"ids_column\":\"media_id\",\"kind\":\"image\",\"path_column\":\"path\",\"role\":\"image\",\"transform\":{\"filter\":\"triangle\",\"fit\":\"within\",\"mode\":\"rgb\",\"normalize\":\"none\",\"size\":[1333,1333]}}", simplifyVector = FALSE), "target/academy-parity/run-8142/segment.semantic/defaults_small/out-r", df,
                        "tests/parity/fixtures/img3_photos.parquet")
media_ids <- cs_media_ids(media, df)

text_ <- function(v) { v <- as.character(v); v[!is.na(v) & !nzchar(v)] <- NA_character_; v }
paths_ <- text_(df[[PATH]])
has_id <- which(!is.na(media_ids) & !is.na(paths_))
if (!length(has_id)) cs_error("CS_E_ALL_MISSING", column = PATH)
status_ <- cs_media_status(media, media_ids[has_id])
ok <- has_id[is.na(status_)]
n_no_path <- nrow(df) - length(has_id)
n_unreadable <- length(has_id) - length(ok)
if (!length(ok)) cs_error("CS_E_INVALID_VALUES", column = PATH, requirement = "an image file that can be decoded", count = length(has_id))
if (n_no_path) warnings <- c(warnings, sprintf("%d rows have no path and are left out.", n_no_path))
if (n_unreadable) warnings <- c(warnings, sprintf("%d files could not be decoded and are left out.", n_unreadable))
items <- lapply(ok, function(k) list(media_id = media_ids[k], file = basename(paths_[k]), row = k - 1L))

# One decoded image (3, h, w) on 0-1 and its size before decoding (orientation applied).
load_image <- function(mid) {
  a <- cs_media_load(media, mid)
  list(image = array(a, dim = dim(a)[-1]), size = cs_media_source_size(media, mid)[[1]])
}

# %% Pretrained model and compute profile
cs_deep_profile_configure(list(profile = "parity"))
cs_deep_torch()
model <- cs_vis_load(ARCH, dtype = cs_deep_profile_current()$dtype)

# %% Label every pixel (torchvision DeepLabV3 on the converted weights, 20 Pascal VOC classes)
SIZE <- 256
CLASSES <- unlist(c())
run <- cs_vis_segment_images(model, items, load_image, size = SIZE, classes = CLASSES, min_share = 0)
table <- run$table
s <- cs_vis_summarize(table, run$images, semantic = TRUE)
values <- c(list(n_rows = nrow(df), n_no_path = n_no_path, n_unreadable = n_unreadable), s$values,
            list(model = cs_vis_model_info(ARCH)$label, size = SIZE))

# %% Artifacts: one row per image and class (mask as COCO RLE) and one row per image
out <- cs_ml_out_dir("target/academy-parity/run-8142/segment.semantic/defaults_small/out-r")
cs_boxes_write(table, file.path(out, "boxes.parquet"))
per <- data.frame(row = vapply(run$images, function(r) r$row + 1L, 0L),
                  media_id = vapply(run$images, function(r) r$media_id, ""),
                  file = vapply(run$images, function(r) r$file, ""),
                  width = vapply(run$images, function(r) r$width, 0L),
                  height = vapply(run$images, function(r) r$height, 0L),
                  regions = vapply(run$images, function(r) as.integer(r$objects), 0L),
                  background = vapply(run$images, function(r) r$background, 0), stringsAsFactors = FALSE)
nanoparquet::write_parquet(per, file.path(out, "images.parquet"))

# %% Result
ov <- cs_vis_overlay_columns(table, run$images)
charts <- list(cs_chart("overlay", "image-overlay", "Class masks", list(
  image = cs_col("Image", ov$image, "categorical"),
  media_id = cs_col("Media id", ov$media_id, "categorical"),
  x0 = cs_col("x0", ov$x0, "numeric"), y0 = cs_col("y0", ov$y0, "numeric"),
  x1 = cs_col("x1", ov$x1, "numeric"), y1 = cs_col("y1", ov$y1, "numeric"),
  label = cs_col("Class", ov$label, "categorical"),
  score = cs_col("Mean confidence", ov$score, "numeric"),
  mask = cs_col("Mask (COCO RLE)", ov$mask, "categorical"),
  width = cs_col("Width (px)", ov$width, "numeric"), height = cs_col("Height (px)", ov$height, "numeric")
), controls = list(boxes = FALSE)))
if (nrow(table)) {
  charts[[length(charts) + 1L]] <- cs_chart("classes", "bar", "Images showing each class", list(
    x = cs_col("Class", as.character(table$label), "categorical", s$order)))
}
assumptions <- c(list(
  list(key = "voc_classes", label = "20 Pascal VOC classes", status = "info",
       detail = "Pixels of anything outside the 20 classes become background or the nearest class."),
  list(key = "one_label", label = "One class per pixel", status = "info",
       detail = "Overlapping objects of the same class merge into one region; use instance segmentation to count objects."),
  list(key = "resolution", label = "Labeled at the segmentation size", status = "info",
       detail = sprintf("Classes are decided with the short side at %d px and enlarged to each image by nearest neighbor.", as.integer(SIZE))),
  list(key = "domain", label = "Photos like COCO's", status = "info",
       detail = "The model learned from everyday photos; other kinds of images need a model trained on them.")
), cs_deep_profile_warning_rows())
image_cols <- list(list(key = "row", label = "Row", type = "integer"), list(key = "file", label = "File"),
                   list(key = "objects", label = "Regions", type = "integer"), list(key = "classes", label = "Classes"),
                   list(key = "background", label = "Background", type = "percent"))
class_cols <- list(list(key = "class", label = "Class"), list(key = "images", label = "Images", type = "integer"),
                   list(key = "pixel_share", label = "Mean share of pixels", type = "percent"),
                   list(key = "mean_score", label = "Mean confidence", type = "number"))
cs_publish(list(
  title = "Semantic segmentation (DeepLabV3, 20 classes)",
  engine = cs_engine_info("torch", "torchvision", "safetensors", "nanoparquet", "codesplashr"),
  n = values$n_images,
  summary = sprintf("%d classes found in %d of %d images; background covers %.1f%% of an image on average.",
                    values$n_classes, values$n_images_with_objects, values$n_images, values$background_mean * 100),
  statistics = list(
    list(key = "n_images", label = "Images", value = values$n_images, format = "integer"),
    list(key = "n_classes", label = "Classes found", value = values$n_classes, format = "integer"),
    list(key = "n_objects", label = "Regions", value = values$n_objects, format = "integer"),
    list(key = "background_mean", label = "Background", value = values$background_mean, format = "percent")
  ),
  tables = list(
    list(key = "classes", title = "Classes", columns = class_cols, rows = s$classes),
    list(key = "images", title = "Classes per image", columns = image_cols, rows = s$images[seq_len(min(200L, length(s$images)))])
  ),
  assumptions = assumptions,
  charts = charts,
  values = values,
  warnings = as.list(warnings),
  artifacts = list(list(key = "boxes", path = file.path(out, "boxes.parquet"), format = "parquet"),
                   list(key = "images", path = file.path(out, "images.parquet"), format = "parquet"))
))

Sources

  • Chen L-C, Papandreou G, Schroff F, Adam H (2017). Rethinking atrous convolution for semantic image segmentation. arXiv:1706.05587.
  • Chen L-C, Papandreou G, Kokkinos I, Murphy K, Yuille AL (2018). DeepLab: semantic image segmentation with deep convolutional nets, atrous convolution, and fully connected CRFs. IEEE TPAMI 40(4):834–848.
  • Everingham M, Van Gool L, Williams CKI, Winn J, Zisserman A (2010). The Pascal visual object classes (VOC) challenge. IJCV 88:303–338.
  • Lin T-Y, Maire M, Belongie S, et al. (2014). Microsoft COCO: common objects in context. ECCV 2014, 740–755.
  • TorchVision maintainers and contributors (2016–). TorchVision: PyTorch's computer vision library (BSD-3-Clause); COCO_WITH_VOC_LABELS_V1 DeepLabV3 weights.

From the CodeSplash method registry · segment.semantic v1.0.0.