Rex-Arnab/image-generation

Local AI image generation with FLUX.2-klein-4B — Flask backend, React frontend, MCP server

0

stars

8

commits

HTML

primary language

Mar 21, 2026

updated

README

FLUX.2 Klein 4B — Local Image Generation

A fully local AI image generation app powered by FLUX.2-klein-4B, running on your Mac (Apple Silicon / MPS) or CPU. Includes a Flask API backend, a React frontend, and an MCP server for Claude Code integration.

Features

  • Text-to-image generation
  • Image-to-image and multi-reference modes (up to 4 reference images)
  • Configurable resolution, steps, guidance scale, seed, and batch size (up to 4 images)
  • GGUF-quantized model (Q4_K_M by default, ~2.6 GB) for low memory usage
  • All generated images saved locally to outputs/ with metadata
  • MCP server exposes generation tools directly to Claude Code

Requirements

  • Python 3.10+
  • Node.js 18+
  • ~3–8 GB free RAM (depending on quantization level)
  • Apple Silicon recommended (MPS acceleration); CPU fallback supported

Setup

bash setup.sh

This will:

  1. Create a Python virtual environment and install dependencies
  2. Install frontend dependencies and build the React app

The GGUF model (~2.6 GB for Q4_K_M) is downloaded automatically from HuggingFace on the first generation request.

Running

Production (serves the built React frontend):

source venv/bin/activate
python app.py
# Open http://localhost:5001

Development (hot reload):

# Terminal 1
source venv/bin/activate && python app.py

# Terminal 2
cd frontend && npm run dev
# Open http://localhost:3000

Quantization

Control memory usage via the FLUX_QUANT environment variable:

QuantSizeQuality
Q8_0~7.75 GBHigher
Q4_K_M~2.6 GBDefault
FLUX_QUANT=Q8_0 python app.py

API

EndpointMethodDescription
GET /statusGETModel load status and device info
/generatePOSTGenerate image(s)

Generate request body:

{
  "prompt": "a cat on the moon",
  "mode": "txt2img",
  "width": 768,
  "height": 768,
  "steps": 4,
  "guidance_scale": 4.0,
  "seed": null,
  "num_images": 1,
  "images": []
}

MCP Integration

The MCP server (mcp_server.py) exposes image generation tools to Claude Code. Configure it in .mcp.json to use the tools directly from your Claude session.

License

MIT

Contributors

Rex-Arnab

1 commits

Rex-Arnab/image-generation

Local AI image generation with FLUX.2-klein-4B — Flask backend, React frontend, MCP server

0

stars

8

commits

HTML

primary language

Mar 21, 2026

updated

README

FLUX.2 Klein 4B — Local Image Generation

A fully local AI image generation app powered by FLUX.2-klein-4B, running on your Mac (Apple Silicon / MPS) or CPU. Includes a Flask API backend, a React frontend, and an MCP server for Claude Code integration.

Features

  • Text-to-image generation
  • Image-to-image and multi-reference modes (up to 4 reference images)
  • Configurable resolution, steps, guidance scale, seed, and batch size (up to 4 images)
  • GGUF-quantized model (Q4_K_M by default, ~2.6 GB) for low memory usage
  • All generated images saved locally to outputs/ with metadata
  • MCP server exposes generation tools directly to Claude Code

Requirements

  • Python 3.10+
  • Node.js 18+
  • ~3–8 GB free RAM (depending on quantization level)
  • Apple Silicon recommended (MPS acceleration); CPU fallback supported

Setup

bash setup.sh

This will:

  1. Create a Python virtual environment and install dependencies
  2. Install frontend dependencies and build the React app

The GGUF model (~2.6 GB for Q4_K_M) is downloaded automatically from HuggingFace on the first generation request.

Running

Production (serves the built React frontend):

source venv/bin/activate
python app.py
# Open http://localhost:5001

Development (hot reload):

# Terminal 1
source venv/bin/activate && python app.py

# Terminal 2
cd frontend && npm run dev
# Open http://localhost:3000

Quantization

Control memory usage via the FLUX_QUANT environment variable:

QuantSizeQuality
Q8_0~7.75 GBHigher
Q4_K_M~2.6 GBDefault
FLUX_QUANT=Q8_0 python app.py

API

EndpointMethodDescription
GET /statusGETModel load status and device info
/generatePOSTGenerate image(s)

Generate request body:

{
  "prompt": "a cat on the moon",
  "mode": "txt2img",
  "width": 768,
  "height": 768,
  "steps": 4,
  "guidance_scale": 4.0,
  "seed": null,
  "num_images": 1,
  "images": []
}

MCP Integration

The MCP server (mcp_server.py) exposes image generation tools to Claude Code. Configure it in .mcp.json to use the tools directly from your Claude session.

License

MIT

Contributors

Rex-Arnab

1 commits

Languages

HTML

44.4%

JavaScript

40.0%

Python

12.7%

CSS

1.6%

Shell

1.2%