image-projection
Project an image into iGAN latent space and reconstruct it with iGAN_predict.py, safe command builders, AlexNet planning, and projection troubleshooting.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- image-projection
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Project an image into iGAN latent space and reconstruct it with iGAN_predict.py, safe command builders, AlexNet planning, and projection troubleshooting.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md7.7 KB
- 参考文档references/projection-workflows.md7.7 KB
- 参考文档references/troubleshooting.md8.3 KB
- 脚本scripts/build_projection_command.py6.3 KB
- 脚本scripts/igan_alexnet_urls.py4.2 KB
03 SKILL.md 正文
iGAN Image Projection Router
Use this sub-skill when the task is to project a real image into the latent space of an iGAN DCGAN model and save the reconstructed image.
This router covers the iGAN_predict.py workflow, the solver choices
cnn, opt, and cnn_opt, the AlexNet conv4 feature dependency used by the
published command, and the model-file requirements for predictor parameters.
Do not use this sub-skill for random sampling, downloading DCGAN model-zoo artifacts, interactive editing, non-UI constraint maps, or training the predictor network. Route those tasks to sibling skills instead.
Read First
- Projection workflow recipes: references/projection-workflows.md
- CLI and internal API facts: references/api-reference.md
- Projection failure modes: references/troubleshooting.md
- Dry projection command builder: scripts/build_projection_command.py
- AlexNet URL/target planner: scripts/igan_alexnet_urls.py
When To Use
Use this sub-skill for tasks such as:
- Build the exact
iGAN_predict.pycommand for a given input image. - Choose between
cnn,opt, andcnn_optprojection solvers. - Explain where the output reconstruction image will be written.
- Preflight required artifacts for projection without running Theano.
- Plan the AlexNet
conv4pickle target without performing a download. - Diagnose missing AlexNet, missing DCGAN model files, or predictor-param errors.
Route Elsewhere
- Random sample grids or DCGAN model-zoo setup: use ../model-inference/SKILL.md.
- Predictor training, HDF5 datasets, batchnorm refresh, or model packing: use ../training-data/SKILL.md.
- Color, mask, edge, or sketch constraints for headless generation: use ../constraint-generation/SKILL.md.
- Interactive PyQt4 drawing workflows: use ../interactive-ui/SKILL.md.
Projection Preconditions
Projection is a legacy native workflow. Before proposing a runtime run, confirm:
- The user has an iGAN runtime checkout or equivalent files containing
iGAN_predict.py. - The Python environment can import Theano, Lasagne, NumPy, SciPy, PIL/Pillow, and iGAN local modules.
- The intended backend is compatible with old Theano CUDA/cuDNN expectations, or the user accepts a slow/experimental CPU attempt.
- The DCGAN model file exists at
models/<model_name>.<model_type>or the user supplies--model_file. - The model file includes generator parameters and, for the current projection script, predictor parameters and predictor batchnorm arrays.
- The AlexNet feature pickle exists at
models/caffe_reference_conv4.pklfor the default feature layer. - The input image is readable by PIL/Pillow; the script resizes it internally to the model resolution and then back to the original dimensions.
If any runtime artifact is missing, use the bundled dry-run helpers and references instead of attempting a native GPU run.
Safe Command Construction
For most tasks, first build a dry command:
python sub-skills/image-projection/scripts/build_projection_command.py \
--model-name shoes_64 \
--input-image pics/shoes_test.png \
--solver cnn_opt
For a custom pure optimization command with an explicit output path:
python sub-skills/image-projection/scripts/build_projection_command.py \
--model-name shoes_64 \
--input-image inputs/shoe.png \
--solver opt \
--output-image outputs/shoe_opt.png
The helper prints a command only. It never imports Theano, opens images, uses a GPU, starts training, or downloads files.
AlexNet Artifact Planning
The documented projection command uses AlexNet conv4 features. Plan the URL
and local target without network side effects:
python sub-skills/image-projection/scripts/igan_alexnet_urls.py --layer conv4
The planner only reports URLs and expected targets. It does not download AlexNet, DCGAN models, or predictor parameters.
Native Runtime Command Pattern
When all artifacts and the legacy runtime are available, the command pattern is:
THEANO_FLAGS='device=gpu0,floatX=float32,nvcc.fastmath=True' \
python iGAN_predict.py \
--model_name shoes_64 \
--input_image pics/shoes_test.png \
--solver cnn_opt
If --output_image is omitted and the input filename contains .png, the
script writes beside the input as <input_stem>_<solver>.png. For example,
pics/shoes_test.png with cnn_opt becomes pics/shoes_test_cnn_opt.png.
Solver Selection
cnn: fastest feed-forward projection through the trained predictor network; requires usable predictor params.opt: L-BFGS-B latent optimization against pixel and feature reconstruction losses; slower and still compiled through the current predictor-aware setup.cnn_opt: default hybrid; starts from the predictor and refines with L-BFGS-B; best documented quality.
Prefer cnn_opt unless the user explicitly requests speed (cnn) or a custom
optimization baseline (opt). Reject unknown solver strings before runtime; the
source script does not validate them robustly.
Output Contract
A successful run prints parsed arguments, reads one image, compiles Theano
functions, loads the model and AlexNet feature network, reconstructs one image,
and saves the result to --output_image or the default solver-suffixed PNG path.
The output image is a reconstructed RGB image resized back to the original input dimensions. The script does not save the optimized latent vector by default.
Validation Checklist
Before telling a user a projection is ready to run, verify or explicitly mark unknown:
iGAN_predict.pyis available in the working runtime checkout.models/<model_name>.<model_type>or the supplied--model_fileexists.models/caffe_reference_conv4.pklexists for the default projection path.lib/ilsvrc_2012_mean.npyexists with the local iGAN library files.- The input image path exists and is a PIL-readable image.
- The environment has Theano/Lasagne/SciPy/PIL and a backend acceptable to the user.
- The model contains predictor params if using
cnnorcnn_opt, and preferably even foroptbecause the original script compiles the predictor unconditionally.
Troubleshooting Entry Points
If native execution fails, classify the symptom first:
- Import errors or syntax/runtime incompatibilities: see references/troubleshooting.md.
- Missing files or wrong targets: see references/troubleshooting.md.
- Predictor-param or solver problems: see references/troubleshooting.md.
- Theano/CUDA/cuDNN compile failures: see references/troubleshooting.md.
Boundary Reminders
Keep this sub-skill focused on image projection only. It may refer to DCGAN model
files and predictor parameters as required inputs, but it does not own model-zoo
downloads, predictor training, or model packing. It may mention AlexNet conv4
because the projection loss depends on it, but network downloads must remain a
manual user action planned by the bundled URL helper.
04 同仓库更多 Skills
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.
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.
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.
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.
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.
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).