AGENT SKILL

constraint-generation

Headless iGAN constrained generation from color, mask, and edge images with safe command planning and input validation.

License 许可
MIT
最近更新
2026-09-03
Stars
★ 351
Forks
27

01 前言 Front Matter

name
constraint-generation
license
MIT
metadata
{ "disco-role": "operating" }
description
Headless iGAN constrained generation from color, mask, and edge images with safe command planning and input validation.
disable-model-invocation
true

02 资源文件 5

03 SKILL.md 正文

constraint-generation

Use this sub-skill when the user needs iGAN's non-UI constrained generation workflow. The workflow starts from three image constraints, plans a native command, and explains the legacy backend needed to actually optimize latent vectors. Keep the agent in command-planning and validation mode unless the user has already provided a compatible iGAN checkout, model artifact, and legacy Theano runtime.

Read when

  • The task mentions the script-without-UI path for iGAN.
  • The task supplies a color image, color mask, and edge image.
  • The user wants a command for constrained generation without launching PyQt UI controls.
  • The user asks about batch_size, n_iters, top_k, or d_weight for constrained optimization.
  • The user wants to validate constraint image paths, dimensions, or image headers before a native run.
  • The user needs to plan the output result grid produced by the headless script.
  • The user has an iGAN model file and wants a low-iteration smoke command.
  • A previous native run failed while loading Theano, OpenCV, PyQt4, CUDA, cuDNN, or model artifacts.

Do not use for

  • Interactive brush controls, keyboard shortcuts, drawing pad behavior, candidate clicks, sliders, or UI launch details; route to interactive-ui.
  • Downloading, locating, naming, or checking pretrained DCGAN artifacts beyond passing --model_file; route setup questions to model-inference.
  • Projecting an existing image into latent space with iGAN_predict.py; route to image-projection.
  • Training DCGAN models, creating HDF5 datasets, packing trained caches, or predictor training; route to the training/data sub-skill if present.
  • Claiming that CPU-only validation proves Theano optimization works; it only proves static command and input contracts.

Native workflow summary

  • The headless script loads a DCGAN model class by model_type and an optimizer backend by framework.
  • Default model selection is model_name=outdoor_64, model_type=dcgan_theano, and framework=theano.
  • If --model_file is omitted, the native script derives a model path from the model name and model type.
  • The script reads input_color, input_color_mask, and input_edge images with OpenCV.
  • Each image is resized to the model resolution when its dimensions do not match the model's npx.
  • Color constraints use the RGB color image.
  • Color-mask constraints use the first channel of the color mask after OpenCV loading.
  • Edge constraints use the RGB edge image plus the first channel as the edge mask.
  • Optimization initializes a batch of latent vectors, runs n_iters update steps, keeps the lowest-cost candidates, and writes one visualization image.
  • The visualization contains the three input panels followed by selected generated candidates, then is enlarged by a fixed 2x resize in the native script.

First actions

  1. Ask for the three constraint image paths if any are missing.
  2. Ask whether the user wants only dry planning or has a prepared legacy runtime for native execution.
  3. Validate paths and headers with scripts/validate_constraint_inputs.py before constructing a native command.
  4. Use scripts/build_constraint_command.py to build a deterministic shell command instead of hand-assembling flags.
  5. Send model-file preparation questions to model-inference rather than inventing artifact paths.
  6. If the user requests GUI interaction, stop this route and use interactive-ui.

Bundled references

  • Constraint workflows gives command recipes, dry-run planning, native execution prerequisites, and output grid math.
  • Data formats defines image path, channel, mask, dimension, and resize expectations.
  • Troubleshooting maps concrete failure symptoms to causes and recovery steps for this workflow.
  • Use root troubleshooting for cross-cutting installation failures when the integrated root skill provides it.

Bundled scripts

  • scripts/validate_constraint_inputs.py performs safe existence, readability, header, dimension, and channel-family checks without importing OpenCV, Theano, or PyQt4.
  • scripts/build_constraint_command.py prints a dry native command plus an output-layout plan; it does not run iGAN, import Theano, download files, train models, or touch the GPU.
  • Both scripts support --help and are deterministic for the same arguments.
  • Prefer the scripts over ad hoc shell snippets because they encode the exact CLI flags and validation assumptions for this workflow.

Required inputs

  • --input_color: image containing desired color strokes or regions.
  • --input_color_mask: mask image indicating where the color image should constrain the generator.
  • --input_edge: image containing edge or sketch constraints.
  • --model_name: model configuration name, commonly outdoor_64 for the documented constraint example.
  • --model_type: model implementation name; this repo's headless path uses dcgan_theano.
  • --framework: optimizer backend name; this repo's implemented native backend is theano.
  • --batch_size: number of random latent initializations optimized in parallel.
  • --n_iters: total latent optimization iterations.
  • --top_k: maximum number of low-cost candidates selected for the output visualization.
  • --d_weight: discriminator realism cost weight; 0.0 disables discriminator cost in the native optimizer.
  • --output_result: path for the generated visualization image.

Safe dry-run recipe

python scripts/validate_constraint_inputs.py \
  --input-color input_color.png \
  --input-color-mask input_color_mask.png \
  --input-edge input_edge.png \
  --target-size 64

python scripts/build_constraint_command.py \
  --model-name outdoor_64 \
  --input-color input_color.png \
  --input-color-mask input_color_mask.png \
  --input-edge input_edge.png \
  --output-result results/script_result.png \
  --batch-size 4 \
  --n-iters 3 \
  --top-k 4

Treat the printed command as a plan until the user confirms the legacy runtime and model artifact are present. The low-iteration recipe is for smoke planning, not for quality generation.

Native execution gate

Before running the native headless script, confirm all of the following:

  • A compatible Python environment can import the repo's legacy dependencies.
  • OpenCV is importable in that environment.
  • The Theano backend can compile the model on the requested device.
  • A CUDA/cuDNN stack is present when using the documented GPU flags.
  • The requested model artifact exists and matches the model name/type.
  • The three input images exist and validate under this sub-skill's validator.
  • The output directory exists or can be created by the calling workflow.
  • The user accepts that the native script may compile Theano functions and use the GPU.

If any gate fails, provide the dry command and a concrete blocker instead of attempting execution.

Output layout planning

  • The native visualization begins with three input panels: color image, color mask, and edge image.
  • Generated candidates are concatenated horizontally after those three panels.
  • The maximum generated panel count is bounded by top_k, but the optimizer may keep fewer candidates after cost thresholding.
  • With target size S, worst-case pre-resize width is S * (3 + top_k) and height is S.
  • The native script applies a 2x resize before writing, so worst-case final dimensions are 2*S*(3 + top_k) by 2*S.
  • If top_k > batch_size, warn the user because the batch cannot produce more unique candidates than initialized latent vectors.
  • For quick smoke checks, set batch_size and top_k to a small equal value and use low n_iters.

Constraint semantics

  • The color mask is a soft numeric mask after normalization to [0, 1], but binary black/white masks are easiest to reason about.
  • White or nonzero mask areas increase the effect of the corresponding color image pixels.
  • The edge path contributes both an edge image and an edge mask using its first channel.
  • Edge pixels should be high-contrast; the optimizer compares HOG features under the edge mask.
  • Empty masks make the corresponding constraint weak or ineffective.
  • Fully white masks force global matching and can overwhelm the generator.
  • If the model is grayscale, generated samples are tiled to RGB for visualization.

Parameter guidance

  • Increase batch_size to search more random latent initializations, at higher memory cost.
  • Increase n_iters for tighter constraint fitting, at higher runtime cost.
  • Increase top_k only when the output visualization should show more candidate modes.
  • Keep top_k <= batch_size for meaningful candidate selection.
  • Start with d_weight=0.0 to match the documented script behavior.
  • Try small positive d_weight only when the discriminator model loads successfully and realism should be weighted against constraint loss.
  • Use explicit --model_file when the artifact is outside the native default model location.

Troubleshooting routing

  • Missing image path, mismatched dimensions, unsupported headers, or weak masks: use Data formats and the validator.
  • Missing model artifacts, unknown model names, or sample-generation smoke checks: use model-inference.
  • Python2-era Theano, CUDA, cuDNN, OpenCV, PyQt4, Lasagne, or Fuel failures: use Troubleshooting first, then root troubleshooting if needed.
  • No display, brush behavior, or candidate thumbnail UI issues: route to interactive-ui.
  • iGAN_predict.py solver, AlexNet, or x -> z reconstruction issues: route to image-projection.

Verification stance

  • This sub-skill can be verified statically with helper --help, command generation, and image header validation.
  • Native constrained generation remains an optional CUDA/Theano/model case.
  • The native candidate is the headless script with the documented sample input contract.
  • Do not report native generation as verified unless the command actually writes the requested output image in a compatible runtime.
  • Keep any unavailable legacy backend as an explicit known gap in the parent verification report.

04 同仓库更多 Skills

VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-triton-opt

Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-solve

END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-skill

PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-pattern-fusion

Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-orchestrate

Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.

★ 351
VectorSpaceLab
VectorSpaceLab/AREX-Skill

passnet-feedback

Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).

★ 351