How Vision Models Convert Images into Executable Drawing Code

    Vision models are moving beyond object recognition toward structured generation, producing executable drawing descriptions that can be rendered, modified, and validated. This article explains how to define such tasks, handle occlusion and line styles, evaluate coordinate mapping, paths, fills, and draw order, and assess output quality across spatial reasoning, schema compliance, efficiency, and robustness. It also covers application scenarios, known limitations, and deployment steps, including evaluation sets, prompts, post-processing, and human review.

    From Recognition to Structured Generation

    In the past, the main task of visual understanding models was recognition: what objects, colors, and text are in an image. A new generation of models is beginning to handle another class of problems: spatial relationships between elements, front-to-back occlusion, and perspective structure. The models also write these judgments as structured expressions, such as drawing code, layout descriptions, or 3D scene instructions.

    The value is that outputs can be executed and checked by programs. If a geometric diagram can be converted into coordinates and path instructions, it can be re-rendered, modified, and archived, rather than only producing a textual description.

    Defining a Concrete Task

    Before deployment, write the task as explicit input and output specifications. Take a geometric diagram as an example:

    • Input: an image containing several geometric shapes, with resolution and camera angle noted.
    • Output: an executable drawing description containing each primitive’s type, coordinates, line style, fill, and draw order.
    • Acceptance method: render the output, overlay it on the original image, and compare; count position errors and occlusion errors.

    The more specific the specification, the easier evaluation becomes. If the instruction is only “let the model draw a picture,” there is no way to judge later whether the result is acceptable.

    Occlusion Relationships and Line Styles

    Occlusion handling is the most error-prone part of this type of task. The model must answer three questions: which object is in front, where the boundary of the occluded part is, and which lines should be drawn as dashed.

    The following pseudo-DSL (a domain-specific language used here only for illustration, not the syntax of an existing library) shows how to write the same scene:

    1. rect id=A x=20 y=30 w=120 h=90 stroke=dashed # rear rectangle; occluded parts are dashed
    2. circle id=B cx=120 cy=60 r=40 fill=white stroke=solid # front circle; drawn later and covers A

    This description has two key points. First, the draw order should place rear objects first and front objects later so that the front object’s fill can cover the rear object. Second, line style depends on whether a boundary is visible, not on the object’s shape.

    During evaluation, common errors fall into three categories:

    • Reversed draw order: a rear object covers a front object, so the occlusion relationship in the rendered image is the opposite of the original.
    • Mixed line styles: visible boundaries are drawn as dashed lines, or occluded parts remain solid.
    • Coordinate offset: when the circle center position is off, intersections and occlusion ranges are also wrong.

    Coordinates, Paths, Fills, and Draw Order

    Output quality can be analyzed in four layers.

    Coordinate mapping converts pixel positions into values in a coordinate system. Errors at this layer propagate to all later stages. The spatial attention and positional encoding mentioned in the source material can help at this layer, but the actual benefit needs to be measured on your own test set.

    Path description requires the model to determine line types, including straight lines, curves, and polylines, as well as line width, continuity, and dashed-line spacing. When dashed-line spacing is recognized incorrectly, the problem is hard to notice visually, so it needs a separate check.

    Fill semantics require the model to distinguish a shape’s interior, exterior, and boundary, and to identify differences between fill patterns.

    Draw-order planning determines whether the final image is correct. It is often overlooked. Once the order is wrong, coordinates that were otherwise correct can be covered incorrectly.

    How to Evaluate

    A single accuracy or recall number cannot reflect the full quality of this type of task. A usable evaluation framework should include at least four dimensions, and each dimension should state its measurement method.

    • Spatial reasoning accuracy: compare position errors between the rendered result and the original image, and count occlusion-decision errors. Use consistent units, such as pixels or normalized coordinates.
    • Structured output compliance: count the proportion of outputs that pass syntax validation, and count the number of lines or primitives that require manual correction.
    • Inference efficiency: record the time from image submission to result return, and note hardware, concurrency, and input size. Without these conditions, timing numbers cannot be compared.
    • Robustness: test performance separately under lighting changes, angle changes, and noise interference, and report results separately.

    The evaluation report should state the model version, test set size, metric definitions, and manual correction rate. The demo cases in the source material show that the new generation of models is more accurate at occlusion judgment than the previous generation. However, the public material does not provide the full test set size or metric definitions, so this conclusion should be treated only as directional reference, and teams should rely on their own data.

    Application Scenarios

    Technical documentation automation: if the input is a clear reference image and the graphic type is within the range the model has been validated on, the model can generate a usable first draft of a vector graphic. Before publication, humans still need to check labels, dimensions, and terminology.

    Educational content generation: the model can generate geometry drawing code from a problem description, helping content teams produce diagrams faster. Constraints in the problem need to be checked one by one. If the problem and the diagram conflict, the problem statement takes precedence.

    Design mockup to code: the difficulty in this scenario lies in the frontend technology stack. Component structures, style conventions, and naming habits differ across frameworks, and the output usually needs to be adapted to team conventions. If the team does not have a unified component library, the maintainability of generated code will drop noticeably. Before deployment, pilot on a single page, record rework time, and then decide whether to expand.

    Known Limitations and Trigger Conditions

    In the following cases, model output reliability decreases, and additional checks or human review should be enabled:

    • Complex lighting: the image contains semi-transparent objects, refraction, or soft shadows.
    • Extreme viewpoints: top-down, bottom-up, or other large-angle perspectives.
    • Too many elements: the number of elements in the image exceeds the upper limit the team has validated on its test set.

    Teams should turn these conditions into specific thresholds, such as perspective angle, element count, and lighting level, and prepare alternatives for each level, such as manual tracing or splitting the image. Thresholds need to be determined from your own test set; it is not advisable to copy another team’s numbers directly.

    Deployment Steps

    1. Build an evaluation set. For each sample, record the image type, difficulty label, expected output, pass criteria, and manual correction time. Samples should cover typical inputs and difficult scenarios, not only cases where the model already performs well.
    2. Design prompts. In the prompt, specify the output format, coordinate units, precision, and line-style conventions. The more explicit the constraints, the more stable downstream parsing becomes.
    3. Build a post-processing pipeline. Perform syntax validation, format normalization, and coordinate-range checks in sequence. Outputs that fail validation are returned directly and do not enter downstream stages.
    4. Use human-in-the-loop review. In the early stage, humans review all outputs; later, gradually reduce the human review ratio based on sampling results. The sampling ratio should be determined by evaluation data.

    Conclusion

    Structured output can reduce the workload of repeated drawing, but reliability depends on task specification, evaluation method, and post-processing. The following situations should not go directly into production: no evaluation set, no syntax validation, input beyond validated graphic types, or graphics used in engineering files that require exact dimensions.

    During deployment, keep three human review points: occlusion relationships and line styles; coordinates and dimensions; and consistency between the graphic and the problem statement or design mockup.