Fooocus: Free Offline SDXL Image Generator & Installation Guide

6月25日 Published inImage Tools

Fooocus is an offline image generator built on the Stable Diffusion XL (SDXL) architecture. Much like online platforms such as Midjourney, it removes the need for complex parameter tweaking, allowing you to focus entirely on your prompts and the resulting art. The installation process is remarkably straightforward: from the initial download to your first generated image, you only need to click three times. The software requires a minimum of 4GB of Nvidia GPU memory.

Fooocus is designed to rival mainstream image generators. Below is a breakdown of how it compares to Midjourney and LeonardoAI.

Midjourney Features, Matched

Midjourney Fooocus
High-quality text-to-image without heavy prompt engineering or parameter tuning Equivalent. Fooocus utilizes an offline GPT-2 prompt processing engine alongside various sampling optimizations. Whether using short prompts like "a house in a garden" or detailed 1,000-word descriptions, the results are consistently high-quality.
V1 V2 V3 V4 (Variations) Input image → Upscale or variation → Variation (subtle) / Variation (strong)
U1 U2 U3 U4 (Upscaling) Input image → Upscale or variation → Upscale (1.5x) / Upscale (2x)
Inpaint / up / down / left / right (pan) Input image → Inpaint or expand → Inpaint / up / down / left / right. Fooocus employs its own specialized inpainting algorithm and model, producing results that surpass standard SDXL inpainting software.
Image prompt Input image → Image prompt. Fooocus uses a proprietary image prompt algorithm that exceeds the quality and prompt-understanding capabilities of standard IP-Adapter or Revisions tools.
--style Advanced → Style
--stylize Advanced → Advanced → Guidance
--niji Multiple specialized launchers: run.bat, run_anime.bat, and run_realistic.bat. Fooocus also supports SDXL models from Civitai.
--quality Advanced → Quality
--repeat Advanced → Image Number
Multi-prompt (::) Simply use multiple lines for your prompts.
Prompt weights Use the format (happy:1.5). Fooocus implements the A1111 reweighting algorithm. When copying prompts from Civitai, Fooocus often yields better results than ComfyUI. For embeddings, use (embedding:filename:1.1).
--no (Negative Prompt) Advanced → Negative Prompt
--ar (Aspect Ratio) Advanced → Aspect Ratio
InsightFace Input image → Image prompt → Advanced → FaceSwap
Describe Input image → Describe

LeonardoAI Features, Matched

LeonardoAI Fooocus
Prompt Magic Advanced → Style → Fooocus V2
Advanced sampling (contrast, sharpness, etc.) Advanced → Advanced → Sampling Sharpness / etc.
User-friendly ControlNets Input image → Image prompt → Advanced

Fooocus Installation Guide

Windows

Download the Fooocus archive, unzip it, and execute run.bat. Upon the first launch, the software will automatically download the necessary models to Fooocus\models\checkpoints. Note that different presets utilize different models; you can also choose to download these manually in advance.

The first time you use the inpainting feature, Fooocus will download its specialized inpainting control model (inpaint_v26.fooocus.patch, 1.28GB) to Fooocus\models\inpaint.

Starting with Fooocus version 2.1.60, the package includes run_anime.bat and run_realistic.bat for specific model presets, which will auto-download the required files. From version 2.3.0 onwards, you can switch between these presets directly within the browser interface. To modify default behavior, use these parameters:

  • --disable-preset-selection: Disables the ability to switch presets in the browser.
  • --always-download-new-model: Automatically downloads missing models when switching presets. If disabled, the system falls back to the previous_default_models defined in the preset. Monitor the terminal for status updates.

Colab

Modify the final line of the execution script to: !python entry_with_update.py --share --always-high-vram Or use specific presets:

  • !python entry_with_update.py --share --always-high-vram --preset anime
  • !python entry_with_update.py --share --always-high-vram --preset realistic

These commands launch the default, anime, or realistic versions respectively. While you can change presets within the UI, doing so may trigger a 60-second timeout during downloads. If this occurs, wait for the download to complete, toggle the preset back and forth, or simply refresh the page.

By default, the Colab version disables the "refiner" to accommodate limited free resources. High-demand features like image prompts may occasionally cause a free Colab session to disconnect. However, basic text-to-image functionality is optimized to remain stable. The --always-high-vram flag prioritizes VRAM over RAM, providing the best balance of performance and stability on a standard T4 instance.

Linux

Using Anaconda

  1. Clone the repository: git clone https://github.com/lllyasviel/Fooocus.git
  2. Navigate to the directory: cd Fooocus
  3. Create the environment: conda env create -f environment.yaml
  4. Activate the environment: conda activate fooocus
  5. Install dependencies: pip install -r requirements_versions.txt
  6. Launch and download models: python entry_with_update.py
  7. To enable remote access: python entry_with_update.py --listen
  8. For specific presets: Use --preset anime or --preset realistic.

Using Python Venv

  1. Clone the repository: git clone https://github.com/lllyasviel/Fooocus.git
  2. cd Fooocus
  3. Create a virtual environment: python3 -m venv fooocus_env
  4. Activate it: source fooocus_env/bin/activate
  5. Install dependencies: pip install -r requirements_versions.txt
  6. Launch: python entry_with_update.py
  7. For remote access: python entry_with_update.py --listen

Using Native System Python

  1. git clone https://github.com/lllyasviel/Fooocus.git
  2. cd Fooocus
  3. pip3 install -r requirements_versions.txt
  4. python3 entry_with_update.py

AMD GPU on Linux

To use an AMD GPU, you must swap the standard Torch for the ROCm-compatible version:

pip uninstall torch torchvision torchaudio torchtext functorch xformers
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm5.6

Note: AMD support is currently in beta.

Windows (AMD GPU)

Edit run.bat to include the following:

.\python_embeded\python.exe -m pip uninstall torch torchvision torchaudio torchtext functorch xformers -y
.\python_embeded\python.exe -m pip install torch-directml
.\python_embeded\python.exe -s Fooocus\entry_with_update.py --directml
pause

Launch run.bat to begin. For specific presets, add --preset anime or --preset realistic to the command line. Note: AMD support is currently in beta.

Mac

Fooocus is compatible with Apple Silicon (M1/M2) and macOS Catalina or newer, utilizing PyTorch MPS acceleration. Because Macs use shared memory rather than dedicated GPUs, image generation will take significantly longer than on PC.

Steps:

  1. Install Conda and the PyTorch nightly build. Refer to Apple's developer documentation for accelerating PyTorch on Mac and confirm that PyTorch recognizes the MPS device.
  2. Open the Terminal and clone the repo: git clone https://github.com/lllyasviel/Fooocus.git
  3. cd Fooocus
  4. conda env create -f environment.yaml
  5. conda activate fooocus
  6. pip install -r requirements_versions.txt
  7. Launch: python entry_with_update.py. (M2 users may need the --disable-offload-from-vram flag to improve model loading speeds.)
  8. The first run will download the SDXL model; the duration depends on your internet speed.

Minimum System Requirements

OS GPU Min GPU Memory Min System RAM Swap Performance Note
Windows/Linux Nvidia RTX 4XXX 4GB 8GB Required Fastest performance
Windows/Linux Nvidia RTX 3XXX 4GB 8GB Required Generally faster than 2XXX series
Windows/Linux Nvidia RTX 2XXX 4GB 8GB Required Generally faster than 1XXX series
Windows/Linux Nvidia GTX 1XXX 8GB 8GB Required Slightly faster than CPU alone
Windows/Linux Nvidia GTX 9XX 8GB 8GB Required Performance varies vs. CPU
Windows AMD GPU 8GB 8GB Required Via DirectML; ~3x slower than RTX 3XXX
Linux AMD GPU 8GB 8GB Required Via ROCm; ~1.5x slower than RTX 3XXX
Mac M1/M2 MPS Shared Shared Shared ~9x slower than RTX 3XXX
Windows/Linux/Mac CPU only 0GB 32GB Required ~17x slower than RTX 3XXX

Preset Models

Task Windows Launcher Linux Parameter Primary Model Refiner
General run.bat (Default) juggernautXL_v8Rundiffusion None
Realistic run_realistic.bat --preset realistic realisticStockPhoto_v20 None
Anime run_anime.bat --preset anime animaPencilXL_v500 None

Advanced Features & Customization

Technical Optimizations

  • Fooocus V2: A dynamic style using GPT-2-based prompt expansion, similar to Midjourney’s hidden preprocessing or LeonardoAI’s Prompt Magic.
  • Native Refiner Swapping: Unlike A1111 or ComfyUI, which use separate k-samplers for the base and refiner (often wasting momentum and breaking sampling continuity), Fooocus uses a single k-sampler for a seamless, continuous transition between models.
  • Negative ADM Guidance: By modifying the Average Diffusion Model (ADM) guidance on the positive and negative sides, Fooocus prevents the "plasticky" or overly smooth look often found in standard SDXL outputs.
  • Self-Attention Guidance: A carefully tuned implementation of Self-Attention Guidance ensures that textures remain detailed rather than artificial.
  • LoRA Integration: Testing indicates that using sd_xl_offset_example-lora at weights below 0.5 consistently improves results over base SDXL.
  • Hardcoded Resolutions: Because SDXL uses positional encoding for resolution, specific dimensions yield superior results. Fooocus hardcodes these in the UI to ensure optimal image quality.
  • DPM Sampler Pairing: Fooocus pairs the DPM family of samplers with SDXL to balance dense detail with natural textures.
  • Standardized Prompting: By using the Automatic1111 weighting method, Fooocus allows users to achieve excellent results when using prompts sourced directly from Civitai.

Custom Configuration

Upon the first launch, Fooocus generates Fooocus\config.txt. You can edit this file to redirect model paths or adjust default parameters.

Example configuration:

{
    "path_checkpoints": "D:\\Fooocus\\models\\checkpoints",
    "path_loras": "D:\\Fooocus\\models\\loras",
    "path_embeddings": "D:\\Fooocus\\models\\embeddings",
    "default_model": "realisticStockPhoto_v10.safetensors",
    "default_cfg_scale": 3.0,
    "default_sampler": "dpmpp_2m",
    "default_scheduler": "karras",
    "default_styles": ["Fooocus V2", "Fooocus Photograph", "Fooocus Negative"]
}

If you encounter errors after modifying the config, delete Fooocus\config.txt to restore default settings.

Command Line Flags

Fooocus offers a wide range of flags for performance tuning and environment setup, including --always-high-vram, --share for public links, and --preset for specific styles. Refer to the terminal's -h help command for the full list of available arguments.

Inline Prompt Features

Wildcards

Example: __color__ flower The system replaces the wildcard with a random entry from the corresponding text file in the wildcards folder. Randomness is based on the seed, but can be disabled via the "Read wildcards in order" option in the development debug mode.

Array Processing

Example: [[red, green, blue]] flower This generates a batch of images—one for each element in the array (e.g., a red flower, then a green flower, then a blue flower). Note that arrays cannot be nested.

Inline LoRAs

Example: flower <lora:sunflowers:1.2> This applies a specific LoRA directly via the prompt. Ensure the LoRA file is located in the models/loras directory.

Internationalization

Translation

You can translate the UI by placing a JSON file in the language folder. Example (Fooocus/language/example.json):

{
  "Generate": "生成",
  "Input Image": "入力画像",
  "Advanced": "고급"
}

To load a translation, use the flag --language example. On Windows, you can modify your .bat files to include this flag: .\python_embeded\python.exe -s Fooocus\entry_with_update.py --language example --preset anime

If a file named default.json exists in the language folder, Fooocus will load it automatically upon startup.