显示HN:Txt2plotter – 从Flux.2提取的真实中心线向量,用于笔式绘图仪
Show HN: Txt2plotter – True centerline vectors from Flux.2 for pen plotters

原始链接: https://github.com/malvarezcastillo/txt2plotter

## txt2plotter:AI驱动的笔绘工具 txt2plotter 使用AI将文本提示转换为适用于笔绘仪的SVG文件。它采用一个流程:LLM增强提示以优化线条艺术,然后Flux.2-dev生成高对比度图像。该图像随后通过骨骼化和图提取被矢量化为清晰的路径,接着进行路径优化(合并、简化、排序)。 该工具输出可用于笔绘仪的SVG文件,具有可配置的尺寸,并支持从文本文件进行批量处理。用户可以使用种子来控制生成过程以实现可重复性,并可以选择跳过提示增强。 **要求:** Python 3.10+,NVIDIA GPU(推荐24GB VRAM),CUDA 12.x,以及OpenRouter & HuggingFace的API密钥。安装方式是通过Git克隆和pip。输出文件,包括中间调试图像,按提示组织在`output/`目录中。该项目采用MIT许可。

## Txt2plotter:为笔式绘图仪生成的人工智能艺术 一个名为“Txt2plotter”的新项目(github.com/malvarezcastillo)旨在简化从人工智能生成图像创建笔式绘图仪艺术的过程,克服诸如重叠线条和抖动线条等常见问题。 该创建者发现现有的工具,如Potrace和SDXL,不足以用于线条艺术。他们的解决方案采用独特的流程:为Flux.2-dev人工智能模型(以几何精度著称)精心设计提示词,然后使用Lee’s Method进行“骨骼化”,从生成的图像中提取精确的中心线。 然后将该中心线转换为图形,清除噪声,并使用`vpype`优化绘图仪效率。与传统的描摹方法相比,结果是更清晰、更快速的绘图。虽然目前还比较基础,但该项目显示出令人鼓舞的结果,作者计划添加API集成和形状识别等功能,以实现诸如交叉阴影等高级技术。
相关文章

原文

Convert text prompts to pen-plotter-ready SVG files using AI image generation and centerline vectorization.

Pipeline

  1. Prompt Enhancement - LLM rewrites your prompt for optimal line art generation
  2. Raster Generation - Flux.2-dev generates a high-contrast line art image
  3. Vectorization - Skeletonization and graph extraction produce clean paths
  4. Optimization - Paths are merged, simplified, and sorted for efficient plotting
  5. Output - Plotter-ready SVG with configurable dimensions

Examples

fox cat hummingbird

jellyfish monstera coffee cup

mountain waves leaf

Plotted

plotter overview cat closeup

Requirements

Installation

git clone https://github.com/malvarezcastillo/txt2plotter.git
cd txt2plotter

# Create virtual environment
python3.10 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -e .

# Configure API keys
cp .env.example .env
# Edit .env with your keys

Usage

# Basic usage (A3 size)
python main.py "a geometric skull"

# Custom dimensions (A4)
python main.py "circuit board pattern" --width 297 --height 210

# Generate multiple variations
python main.py "mountain landscape" -n 5

# Reproducible generation with seed
python main.py "geometric pattern" --seed 42

# Generate 3 reproducible variations (uses seed, seed+1, seed+2)
python main.py "geometric pattern" -n 3 --seed 42

# Skip prompt enhancement
python main.py "minimalistic line drawing of a cat" --skip-enhance

# Batch mode: process multiple prompts from file
python main.py --batch prompts.txt -n 10

Batch File Format

Create a prompts.txt file (one prompt per line, supports comments):

# My prompts
"Minimalistic isometric impossible cube, thick black lines, technical drawing."
"Single continuous line drawing of a greyhound, Picasso style."

# This is also valid (no quotes)
A geometric skull with clean vector lines

Output is organized by prompt: output/<prompt_slug>/

Output

  • output/*.svg - Final plotter-ready SVGs
  • output/debug/ - Intermediate files for debugging:
    • 01_prompt_enhanced.txt - Enhanced prompt
    • 02_raster_raw.png - Generated image
    • 02_raster_binary.png - Thresholded binary
    • 03_skeleton.png - Skeletonized paths
    • 03_graph_*.png - Graph visualization
    • 03_paths.svg - Raw paths
    • 04_optimized.svg - After optimization

License

MIT

联系我们 contact @ memedata.com