# ImageGen

Adopt this skill: https://proskills.md/skills/design/imagegen

Page: https://proskills.md/skills/design/imagegen
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: LICENSE
upstream: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/LICENSE

Content is not inlined in the catalog. Read the upstream file: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/LICENSE

## File: README.md
upstream: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/README.md

````text
# imagegen

`imagegen` is a local image-generation skill that leverages an NVIDIA GPU in your system for OpenClaw.

It uses:

- an NVIDIA GPU with CUDA available through PyTorch
- a local Python runtime
- Hugging Face `diffusers`
- the `black-forest-labs/FLUX.2-klein-4B` model

The generated image must be written under:

```bash
$HOME/.openclaw/media/outbound/
```

for the Agent to be able to handle the images and embed them elsewhere.

## Files

- `SKILL.md`: skill instructions and usage rules
- `run_image_model.sh`: shell wrapper used by the skill
- `run_image_model.py`: Python entrypoint that loads the model and saves the image

## Requirements

Before using this skill, make sure the host has:

- Python 3.10+
- `bash`
- an NVIDIA GPU
- working CUDA support in PyTorch
- internet access on first run to download model weights from Hugging Face

Python packages required by this skill:

- `torch`
- `diffusers`
- `transformers`
- `accelerate`
- `safetensors`
- `huggingface_hub`
- `sentencepiece`
- `Pillow`

## Preferred Install: `.venv`

This is the recommended setup.

It matches the current wrapper, which expects a Python runtime in:

```bash
$HOME/.venv/bin/python
```

### 1. Create the virtual environment

```bash
python3 -m venv "$HOME/.venv"
```

### 2. Activate it

```bash
source "$HOME/.venv/bin/activate"
```

### 3. Upgrade packaging tools

```bash
python -m pip install --upgrade pip setuptools wheel
```

### 4. Install PyTorch with CUDA support

Install the CUDA-enabled PyTorch build appropriate for the machine. Example:

```bash
pip install torch --index-url https://download.pytorch.org/whl/cu124
```

If the host uses a different CUDA build, use the matching PyTorch install command instead.

### 5. Install the remaining dependencies

```bash
pip install diffusers transformers accelerate safetensors huggingface_hub sentencepiece Pillow
```

### 6. Verify the environment

```bash
"$HOME/.venv/bin/python" -c "import torch; import diffusers; print(torch.cuda.is_available())"
```

If this prints `True`, the runtime is ready.

## Alternative Install: local Python, no virtual environment

This option installs packages into the local Python environment instead of a dedicated `.venv`.

### Important note

The current `run_image_model.sh` script is configured to use:

```bash
$HOME/.venv/bin/python
```

If you install dependencies without a virtual environment, you must also update `run_image_model.sh` so `VENV_PYTHON` points to your local Python, for example:

```bash
VENV_PYTHON="/usr/bin/python3"
```

### 1. Upgrade packaging tools

```bash
python3 -m pip install --upgrade pip setuptools wheel
```

### 2. Install PyTorch with CUDA support

Example:

```bash
python3 -m pip install torch --index-url https://download.pytorch.org/whl/cu124
```

Use the correct CUDA build for the host if it differs.

### 3. Install the remaining dependencies

```bash
python3 -m pip install diffusers transformers accelerate safetensors huggingface_hub sentencepiece Pillow
```

### 4. Verify the environment

```bash
python3 -c "import torch; import diffusers; print(torch.cuda.is_available())"
```

## Example usage

```bash
$HOME/.openclaw/workspace-pixy/skills/imagegen/run_image_model.sh \
  flux2-klein-4b \
  "A sunset over the ocean" \
  $HOME/.openclaw/media/outbound/flux2-sunset.png \
  1024 \
  768 \
  4 \
  42
```

## Notes

- The first generation may take longer because model weights may need to be downloaded.
- The wrapper creates and uses cache directories under `$HOME/.cache/`.
- The skill currently supports one model only: `flux2-klein-4b` but it can easily modify to leverage other models. Just ask your Agent.
````

## File: SKILL.md
upstream: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/SKILL.md

Content is not inlined in the catalog. Read the upstream file: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/SKILL.md

## File: run_image_model.py
upstream: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/run_image_model.py

Content is not inlined in the catalog. Read the upstream file: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/run_image_model.py

## File: run_image_model.sh
upstream: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/run_image_model.sh

Content is not inlined in the catalog. Read the upstream file: https://github.com/mindloom-labs/local-image-generation-skill-for-openclaw-nvidia-gpu/blob/HEAD/run_image_model.sh
