This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
Tag: CV
DL0184 Structure from Motion with Deep Learning
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
DL0182 Semantic, Instance, and Panoptic Segmentation
What are the differences between Semantic, Instance, and Panoptic Segmentation, and when is each task formulation used in practice, for example inside an autonomous-driving perception stack?

The Problem: A driving-perception team has budget to annotate 20,000 front-camera frames once, and three downstream modules each ask for the labels in a different shape. These are a free-space module that only asks which pixels are drivable, a vehicle tracker that must follow each car across frames, and a motion planner that wants one map telling it both whether a pixel is drivable and which vehicle it belongs to. Which segmentation formulation should feed each module, and how do the three formulations actually differ?
Answer
The three tasks differ in what a label is allowed to be. Semantic segmentation assigns every pixel exactly one class out of
and has no notion of object identity, so two touching cars collapse into a single connected “car” region. Instance segmentation does the opposite: it detects and masks each countable object separately with a confidence score, but it only covers thing classes, ignores amorphous stuff such as road, sky, and vegetation, and its masks may overlap each other or leave pixels uncovered. Panoptic segmentation is the union of the two: every pixel receives one pair
of class plus instance id, stuff classes get a single segment with no id, things get one segment per object, and the output is a strict partition of the image with no overlaps and no unlabeled pixels except an explicit void region. Which formulation you pick follows the consumer of the output, not fashion. A planner that needs to count and track individual vehicles needs ids, whereas a free-space or sky-replacement module only needs a region mask.
(1) Label Space: semantic returns a class per pixel, instance returns a set of scored binary masks with classes, and panoptic returns a class plus an id per pixel.
(2) Things Versus Stuff: instance segmentation is defined only on countable things; semantic segmentation handles both but cannot separate two instances; panoptic handles both and separates instances.
(3) Overlap Constraint: instance masks are independent and can overlap, while panoptic forces a non-overlapping partition, which means any fusion of two heads must resolve conflicts explicitly.
(4) Metrics Differ In Kind: semantic uses mIoU, instance uses mask AP averaged over IoU thresholds and scores, and panoptic uses PQ at a single fixed matching threshold with no score sweep.
(5) Annotation Cost: stuff-only masks are cheap polygon paint, per-instance boundaries between adjacent same-class objects are the most expensive labels in the dataset.
(6) Practical Selection: use semantic for region questions, instance for counting and tracking, and panoptic when a downstream module needs one consistent scene interpretation per pixel.
Figure 1: One scene, three label spaces. The interesting pixels are the ones on the boundary between the two touching cars: semantic segmentation is structurally unable to place that boundary, instance segmentation places it but may let the two masks overlap and says nothing about road or sky, and panoptic segmentation is required to place it and to label every remaining pixel exactly once.
In practice the formulation is chosen by the consumer. Free-space and drivable-area estimation, land-cover mapping from satellite imagery, portrait or sky matting, and organ or tumor delineation are region questions, so semantic segmentation is sufficient and its cheaper labels are a real advantage. Counting, tracking, and grasping are identity questions: counting cells in a microscopy image, tracking each pedestrian across frames, or picking one item out of a bin all require per-object masks, so instance segmentation (or its video extension) is the right task. Panoptic segmentation earns its extra cost when a single downstream consumer must be handed one coherent interpretation of every pixel, which is why it is the natural output format for driving perception and robot scene understanding, where the same map must answer both “is this pixel drivable” and “which vehicle is this”. A useful diagnostic question is whether two adjacent objects of the same class must ever be told apart. If the answer is no, panoptic annotation is money spent on a distinction nobody reads.
Mathematical Formulation:
Where:
is a pixel,
its class, and
its instance id, which is undefined (shared) for stuff classes and unique per object for thing classes.
is the number of classes, split into disjoint thing and stuff subsets by the dataset definition rather than by the model.
is the
-th predicted binary mask,
its class, and
its confidence; the
masks are independent, so they may overlap and their union need not cover the image.
,
, and
in PQ count segments, not pixels, with a ground-truth segment
and a prediction
matched when
; that threshold makes the matching provably unique because panoptic segments cannot overlap.
is segmentation quality, the mean IoU of matched pairs, and
is recognition quality, the F1 score over segments; PQ is reported per class and then averaged, and often split into
and
.
in mIoU counts pixels of class
, which is why mIoU is blind to how many objects a class region contains.
Worked Example (One Image):
Four matched segments whose IoUs sum to 3.10 give an SQ of 0.775, and two false positives plus two false negatives each contribute a half count to the RQ denominator, so RQ is 0.667 and PQ lands at 0.517. The decomposition is the practically useful part: a high SQ with a low RQ means the masks are accurate but segments are being missed or hallucinated, which points at the classification and duplicate-removal path, while a high RQ with a low SQ means the right objects are found with sloppy boundaries, which points at output resolution and boundary supervision.

Figure 2: PQ is a segment-level bipartite matching followed by a product of two interpretable factors. The pair at IoU 0.38 is the detail that separates candidates who have read the metric from those who have not: it is not a weak match, it is no match at all, and it is charged once as a false positive and once as a false negative.
Property Semantic Instance Panoptic Output per pixel One class id Zero, one, or several scored masks Exactly one (class, instance id) pair Stuff classes Covered Not part of the task Covered as one segment per class Separates same-class objects No Yes Yes, and mandatory Overlapping masks Impossible by construction Allowed and common Forbidden, conflicts must be resolved Standard metric mIoU over pixels Mask AP swept over IoU and score PQ = SQ x RQ at IoU above 0.5 Classic architecture FCN, DeepLab, per-pixel softmax Mask R-CNN, box then mask head Panoptic FPN, or mask-classification with queries Typical use Free space, land cover, matting, organ delineation Counting, tracking, robotic grasping Driving and robot scene understanding, one map for all consumers Login to view more contentDL0162 World Model Object Permanence
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
DL0157 VLA Zero-Shot and Few-Shot Transfer
This is an IntvML Pro interview question. Upgrade to Pro to unlock the full prompt, diagrams, and solution.
DL0142 OCR-Free Document VLM
How do OCR-free Document VLMs process complex multi-column PDFs, tables, and infographics compared to multi-stage OCR pipeline setups?

The Problem: Ledgerline’s document team must pick one parser for a 12,000-page intake batch that mixes two-column research reports, borderless rate tables with spanning headers, and chart-heavy infographics, all feeding an LLM that answers analyst questions. Should they chain OCR, layout and table models, or hand the raw pages to an OCR-free Document VLM?
Answer
A multi-stage pipeline turns a page into a text document before any reasoning happens: rasterize → detect text regions → recognize each crop → classify layout blocks → sort them into reading order → recover table cell structure → serialize to Markdown or HTML → feed a text LLM. An OCR-free Document VLM deletes that entire chain and treats the page as an image: a dynamic-resolution ViT encoder cuts the raster into 14×14 patches, a 2×2 pixel-shuffle merge collapses them into one visual token per 28×28 pixel block, and a decoder-only LLM attends over those tokens to emit the answer, the Markdown, or the HTML table directly. The consequence is that self-attention itself becomes the layout model: column boundaries, cell alignment, chart axes, and legend-to-series association are learned from pixels rather than reconstructed by six independently trained components whose errors multiply. What you gain is robustness on infographics and rotated or borderless tables, where reported scores such as Qwen2.5-VL-72B’s roughly 96 ANLS on DocVQA and roughly 87 on InfographicVQA are far out of reach for a serialized-text pipeline. What you lose is character-level coordinates, per-token confidences, and cheap per-page cost, because a single A4 page at 150 DPI already costs about 2,835 visual tokens and the prefill over them is quadratic.
(1) Pixels In, Structure Out: the model never sees a text layer, so scanned pages, screenshots, and born-digital PDFs with broken embedded fonts all take the identical path.
(2) Dynamic Resolution Tokenization: instead of squashing every page to 224×224, the encoder keeps native aspect ratio and resolution, so an 8 pt footnote survives as its own tokens rather than being blurred away.
(3) Attention Replaces The Reading-Order Module: a three-column paper needs no LayoutReader-style sorter, because the decoder learns column continuation the way a language model learns syntax.
(4) Tables As Generated Markup: structure recognition becomes ordinary autoregressive decoding of HTML or Markdown, which handles borderless and spanning cells but has no per-cell confidence.
(5) No Error Compounding, No Coordinates: the pipeline’s five or six stages multiply their error rates, while the VLM has one loss and one failure surface but cannot tell you where on the page an answer came from.
(6) Token Budget Is The Real Constraint: visual tokens grow with the square of DPI, so resolution, tiling, and page count trade directly against context andprefill.

Figure 1: The same pixels, two failure surfaces. The pipeline produces an intermediate text document with coordinates that any downstream model can consume and any auditor can overlay, at the cost of five models whose accuracies multiply. The VLM is one differentiable stack with one loss, and its output carries no character boxes at all unless the model was explicitly trained to emit them.
The three hard document classes fail differently. On multi-column PDFs, a pipeline’s mistake is almost never recognition, it is serialization: a two-column paper with a full-width figure caption in the middle gets flattened into interleaved half-sentences, and the LLM downstream has no way to recover the intended order because the evidence, the geometry, was discarded. On tables, borderless layouts and spanning header cells break rule-based and detection-based structure recognition, whereas a VLM trained on HTML targets can emit
rowspanandcolspanbecause it saw the whole grid at once. On infographics and charts, OCR returns a bag of strings with no relations, so “which bar is tallest” or “what does the dashed series do after 2021” is unanswerable from the transcript; this is precisely where the ChartQA and InfographicVQA gaps are widest. The pipeline still wins wherever the requirement is verbatim fidelity plus provenance, since a hallucinated digit inside a generated table cell is indistinguishable from a correct one, while a low-confidence OCR crop announces itself.Mathematical Formulation:
Where:
is the number of visual tokens the encoder emits for one page, which is what actually enters the LLM context.
and
are the rasterized page height and width in pixels (
for A4 at 150 DPI), and
is the effective patch stride after a 2×2 merge of 14×14 patches.
is the attention cost before the first output token, quadratic in
and linear in model width
; the KV cache grows linearly, so a 20-page document is a memory problem as well as a compute one.
is the per-page success rate of pipeline stage
and
the number of stages, with
running detection, recognition, layout, reading order, and table structure.
is the end-to-end page accuracy: five stages that each succeed 95% of the time leave only about 77% of pages fully clean, and this multiplicative compounding is the structural argument for a single-stage model.

Figure 2: Resolution is the cost knob. The same A4 page costs 2,835 visual tokens at 150 DPI and 11,214 at 300 DPI, roughly 4x the tokens and 16x the prefill FLOPs, while a serialized OCR transcript of that page stays near 800 tokens whatever the DPI. The 2×2 pixel-shuffle merge is what keeps a full page under the common 16,384-token per-image cap at all.
Property Multi-stage OCR pipeline OCR-free Document VLM Multi-column reading order Explicit sorter over layout blocks; interleaves columns when a full-width element splits the page Learned implicitly by attention over the whole page at once Tables Dedicated structure model emitting cell boxes; weak on borderless and spanning cells Generates HTML with rowspan and colspan; can silently drop or invent rows in long tables Charts and infographics Returns unrelated strings; visual relations such as legend-to-series are lost Reads axes, bar heights, and legends jointly, which is where the accuracy gap is largest Provenance Character and word boxes plus per-crop confidence, usable for redaction and highlighting None by default; needs grounding training to emit absolute coordinates Dominant failure mode Compounding stage errors and serialization scrambling; degrades visibly Fluent hallucination and repetition loops; degrades invisibly Cost per page Small CNN and CTC models, CPU-viable, millions of pages per day cheaply Thousands of visual tokens through a multi-billion-parameter decoder with quadratic prefill Adapting to a new form type Retrain or rewrite whichever stage broke, with per-stage labels Fine-tune once on image and target-string pairs, no intermediate annotation Login to view more content







