# How to Generate Utility Model Patent Disclosures with Structure Schematics and Parts Numbering

> Automate utility model patent disclosures with handsomestWei/patent-disclosure-skill. Generate schematics and part numbering for your mechanical inventions easily.

- Repository: [handsomestWei/patent-disclosure-skill](https://github.com/handsomestWei/patent-disclosure-skill)
- Tags: how-to-guide
- Published: 2026-09-06

---

**The handsomestWei/patent-disclosure-skill repository automates the creation of utility model patent disclosures by validating technical briefs, generating vector line-art schematics, and overlaying numbered leader-lines for every mechanical part.**

This open-source pipeline converts raw assembly descriptions into publication-ready patent figures through a structured workflow involving schema validation, AI-powered image generation, and precise geometric callout placement. The system specifically targets **utility model** patents—sometimes called "petty patents" or "utility innovations"—which require clear structural diagrams with numbered component labels.

## Core Components of the Patent Disclosure Pipeline

The automation relies on three distinct stages that separate validation from rendering.

### Structure-Lineart Gate

Located at [`skills/patent-disclosure/tools/structure_lineart_gate.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-disclosure/tools/structure_lineart_gate.py), the gate acts as the entry validator and job orchestrator. It parses [`structure_schema.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_schema.yaml) and [`structure_lineart_brief.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_lineart_brief.yaml) to ensure every part ID in the legend exists in the schema and that the patent type is explicitly set to `utility_model`. The `validate_brief()` function enforces these constraints, checking for missing reference images and mismatched part definitions before allowing generation to proceed.

### Structure-Lineart Compose

After the diffusion model generates raw contour PNGs, the composition logic—implemented within the job payload—vectorizes these rasters into a single SVG file. Each mechanical part becomes a separate `<g>` element keyed by its part ID (e.g., `<g id="A1">`), enabling independent manipulation during the callout phase without requiring full image re-rendering.

### Structure-Callout Overlay

The final stage uses [`skills/patent-disclosure/tools/structure_callout_overlay.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/skills/patent-disclosure/tools/structure_callout_overlay.py) to read the composed SVG groups and the [`structure_callout_anchors.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_callout_anchors.yaml) manifest. It positions numbered leader-lines at coordinates determined by a vision model, outputting a finalized PNG or SVG that combines the clean line-art with precise parts numbering.

## Configuring the Assembly Schema and Brief

Before running the pipeline, you must define the mechanical assembly and generation parameters.

### Defining Parts in structure_schema.yaml

Create a case directory (e.g., `outputs/my_case`) and place a schema file that declares every component with a unique identifier and human-readable name:

```yaml
parts:
  - id: A1
    name: "外壳"
  - id: B2
    name: "螺丝"
  - id: C3
    name: "内部支架"

```

This schema serves as the single source of truth for all downstream validation.

### Writing the Line-Art Brief

The [`structure_lineart_brief.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_lineart_brief.yaml) file controls which views to generate and how to handle parts numbering:

```yaml
enabled: true
patent_type: utility_model
callout_mode: overlay          # Options: overlay, in_prompt, contour_only

parts_legend:
  - id: A1
    name: 外壳
  - id: B2
    name: 螺丝
views:
  - view_name: 正视图
    source_paths:
      - ref_front.jpg
      - ref_detail.png

```

Set `callout_mode: overlay` to add numbers after generation, or `in_prompt` to instruct the diffusion model to embed numbers directly during the initial render.

## Validating Inputs and Building Generation Jobs

The gate tool ensures data integrity before committing GPU resources.

### Running Validation Checks

Execute the gate in check mode to verify schema compliance and file existence:

```bash
python skills/patent-disclosure/tools/structure_lineart_gate.py \
  --case-dir outputs/my_case \
  --check

```

This invokes the `validate_brief()` logic to report any missing fields, absent source images, or part ID mismatches between the legend and schema.

### Preparing the Job Manifest

After validation, generate the execution payload:

```bash
python skills/patent-disclosure/tools/structure_lineart_gate.py \
  --case-dir outputs/my_case \
  --prepare-jobs

```

The `build_jobs()` function outputs [`lineart_assist/structure_lineart_jobs.json`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/lineart_assist/structure_lineart_jobs.json), containing one job per view with fully formed **img2img** prompts (or **txt2img** fallbacks) and output paths. When using `overlay` mode, these prompts request pure contour line-art without text.

## Composing Vector Graphics and Overlaying Callouts

Once the diffusion model produces the raw PNGs, the pipeline finalizes the schematic.

### Vectorizing and Grouping Parts

The implicit [`structure_lineart_compose.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_lineart_compose.py) step converts the generated PNGs into `structure_lineart_compose.svg`. Each part defined in your schema becomes an isolated SVG group, preserving the contour geometry while enabling selective access for anchor detection.

### Detecting Anchors and Placing Numbers

A vision model analyzes the composed SVG to write [`structure_callout_anchors.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_callout_anchors.yaml), mapping each part ID to optimal leader-line coordinates. Execute the overlay tool to finalize the schematic:

```bash
python skills/patent-disclosure/tools/structure_callout_overlay.py \
  --case-dir outputs/my_case

```

This produces `*_callouts.png` files displaying the assembly with numbered leader-lines pointing to each respective part, satisfying utility model disclosure requirements.

## Summary

- **Data-driven validation** through [`structure_lineart_gate.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_lineart_gate.py) prevents generation errors by enforcing schema compliance before image synthesis begins.
- **Separation of concerns** between contour generation, SVG composition, and callout overlay allows flexible swapping of diffusion backends or vector processing libraries.
- **Dual callout modes** (`overlay` vs `in_prompt`) provide control over whether part numbers are added post-processing or generated natively by the AI model.
- **Structured output** produces patent-ready diagrams with numbered leader-lines stored in standard PNG/SVG formats suitable for inclusion in utility model applications.

## Frequently Asked Questions

### What image formats are supported for source reference files?

The pipeline accepts standard raster formats including **JPEG**, **PNG**, and **WebP** for the `source_paths` defined in [`structure_lineart_brief.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_lineart_brief.yaml). The gate tool verifies file existence during the validation phase but does not enforce specific extensions, relying on the underlying image generation framework to handle decoding.

### How does the callout_mode setting affect the final schematic?

Setting `callout_mode: overlay` generates clean contour images first, then uses [`structure_callout_overlay.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_callout_overlay.py) to add leader-lines programmatically, ensuring precise typography and positioning. Conversely, `in_prompt` instructs the diffusion model to paint the numbers directly onto the image during generation, which is faster but offers less control over placement and font consistency.

### Can this pipeline generate disclosures for invention patents instead of utility models?

While the tool specifically checks for `patent_type: utility_model` in the brief validation logic, the underlying schematic generation and parts numbering system works for any mechanical assembly diagram. You would need to modify the `validate_brief()` function in [`structure_lineart_gate.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_lineart_gate.py) to accept additional patent type enums, as the current implementation restricts processing to utility models during the gate phase.

### Where are the final numbered schematics stored?

After running the overlay tool, finalized images are written to the `lineart_assist/` directory within your case folder, typically named with the pattern `{view_name}_callouts.png` or `{view_name}_callouts.svg`. The composed vector file `structure_lineart_compose.svg` remains available in the same location for manual editing or archival purposes.