Command-Line Parameters

May 28, 2026 ยท View on GitHub

This document summarizes the parameters used when running the sldgen.py script. The CLI is organized into sections below, with the most important parameters highlighted first.

Notes:

  • Output folders are created automatically under <output-dir>/<target-stem>/<experiment-name>/.
  • When --experiment-name is omitted, a timestamp is used.
  • When CUDA is unavailable, the code automatically falls back to CPU.
  • The target image must exist before running.

Most Important Parameters

These are the parameters you are most likely to tune when running the pipeline.

ParameterTypeDefaultDescription
--targetstrrequiredPath to the image used as the target for single-line drawing generation.
--captionstr""Text prompt used for SDS guidance.
--experiment-namestrgenerated automaticallyName of the experiment folder. If not provided, a timestamp is used.
--num-iterint4000Number of optimization iterations.
--widthfloat or str1.0Stroke width, or the optim special mode for varying line width.
--fixed-endpointsflagFalseKeep endpoints fixed during optimization to make it easier to connect drawings.
--n-control-pointsint385Number of control points used to initialize the line.
--save-intervalint100Frequency for saving intermediate results.

Special cases

To generate the particular configurations of single-line drawings presented in the paper, use one of the following commands:

Single-line drawing with varying width

python sldgen.py --target ./data/firefighter.png --width optim

Single-line drawing with fixed endpoints for easier connection

python sldgen.py --target ./data/firefighter.png --fixed-endpoints

All parameters

General Parameters

ParameterTypeDefaultDescription
--output-dirstr./output/Directory where results are saved.
--experiment-namestrgenerated automaticallyName of the experiment folder. If not provided, a timestamp is used.
--use-cpuflagFalseForce CPU execution even if CUDA is available.
--seedint0Random seed for Python, NumPy, and PyTorch.
--verboseflagFalsePrint loss values during optimization.
--debugflagFalseEnable debug mode. Print additional debug information.

Target Image Parameters

ParameterTypeDefaultDescription
--targetstrrequiredTarget image path. The file must exist.
--object-size-ratiofloat0.75Maximum size of the object relative to the render size, used to rescale the target.
--render-sizeint512Output render size in pixels.
--calligraphyflagFalseTreat the target as a calligraphy image or letter. Changes how the mask is created.

Optimization Parameters

ParameterTypeDefaultDescription
--num-iterint4000Total number of optimization iterations.
--lrfloat0.8Base learning rate for the optimizer.
--save-intervalint100Save intermediate outputs every N iterations.

Curve Parameters

ParameterTypeDefaultDescription
--sampling-rateint5000Number of points sampled from the curve for rendering.
--no-optimize-cp-weightsflagoptimize_cp_weights = TrueDisable optimization of B-spline control-point weights.
--keep-low-weightsflagprune_low_weights = TrueKeep low weights instead of pruning them.
--init-methodstrtspInitialization method for the single line: trefoil, contour, or tsp.
--n-control-pointsint385Number of control points at the start of optimization.
--widthfloat or str1.0Stroke width, or the optim special mode for varying line width.
--fixed-endpointsflagFalseKeep endpoints fixed during optimization for easier connection between drawings.

SDS Guidance Parameters

ParameterTypeDefaultDescription
--captionstr""Text prompt used for semantic guidance.
--conditioning-scalefloat0.5Conditioning scale used in the SDS guidance objective.
--conditionstrdepthGuidance conditioning type, either depth or canny.
--lora-modelstr./SLDgen/guidance/sld-lora.safetensorsPath to the LoRA weights used for guidance.
--lora-weightfloat0.1Strength of the LoRA adapter. Set to 0 to disable its effect.

Loss Parameters

ParameterTypeDefaultDescription
--repulsion-loss-weightfloat0.004Weight of the repulsion loss.
--sparse-loss-weightfloat2000.0Weight of the sparsity loss.
--sparse-loss-typefloat1.0Degree of the sparsity loss; 0.0 corresponds to a standard deviation loss.
--sparse-loss-progressivestrlinearProgressive sparse-loss mode. Any value other than linear disables the progressive schedule.
--length-shortening-loss-weightfloat0.1Weight of the length-shortening loss.

Metrics Parameters

ParameterTypeDefaultDescription
--aesthetic-predictor-model-pathstr./SLDgen/metrics/aesthetic_predictor_v2_5.pthPath to the aesthetic predictor model weights.

Fixed Runtime Settings

These values are set internally by SLDgen/config.py after argument parsing and are not exposed as CLI flags.

SettingValueDescription
diffusion_modelstabilityai/stable-diffusion-3.5-mediumDiffusion model used for guidance.
diffusion_timesteps1000Number of diffusion timesteps.
diffusion_guidance_scale100Guidance scale used for diffusion sampling.
vae_pathmadebyollin/taesd3VAE used by the guidance pipeline.
multisteps1Number of multistep passes.
negative_caption""Negative prompt passed to the guidance model.