# ICLight

Relight any image with AI-powered illumination control.

{% hint style="success" %}
All examples can be run on GPU servers rented through [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

{% hint style="info" %}
All examples in this guide can be run on GPU servers rented through [CLORE.AI Marketplace](https://clore.ai/marketplace) marketplace.
{% endhint %}

## Renting on CLORE.AI

1. Visit [CLORE.AI Marketplace](https://clore.ai/marketplace)
2. Filter by GPU type, VRAM, and price
3. Choose **On-Demand** (fixed rate) or **Spot** (bid price)
4. Configure your order:
   * Select Docker image
   * Set ports (TCP for SSH, HTTP for web UIs)
   * Add environment variables if needed
   * Enter startup command
5. Select payment: **CLORE**, **BTC**, or **USDT/USDC**
6. Create order and wait for deployment

### Access Your Server

* Find connection details in **My Orders**
* Web interfaces: Use the HTTP port URL
* SSH: `ssh -p <port> root@<proxy-address>`

## What is IC-Light?

IC-Light by lllyasviel enables:

* Relight images with text descriptions
* Change lighting direction and color
* Add or remove shadows
* Create studio lighting effects
* Foreground/background relighting

## Resources

* **GitHub:** [lllyasviel/IC-Light](https://github.com/lllyasviel/IC-Light)
* **HuggingFace:** [lllyasviel/IC-Light](https://huggingface.co/lllyasviel/IC-Light)
* **Demo:** [HuggingFace Space](https://huggingface.co/spaces/lllyasviel/IC-Light)
* **Paper:** Based on ControlNet architecture

## Recommended Hardware

| Component | Minimum       | Recommended   | Optimal       |
| --------- | ------------- | ------------- | ------------- |
| GPU       | RTX 3060 12GB | RTX 4080 16GB | RTX 4090 24GB |
| VRAM      | 8GB           | 12GB          | 16GB          |
| CPU       | 4 cores       | 8 cores       | 16 cores      |
| RAM       | 16GB          | 32GB          | 64GB          |
| Storage   | 30GB SSD      | 50GB NVMe     | 100GB NVMe    |
| Internet  | 100 Mbps      | 500 Mbps      | 1 Gbps        |

## Quick Deploy on CLORE.AI

**Docker Image:**

```
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
```

**Ports:**

```
22/tcp
7860/http
```

**Command:**

```bash
cd /workspace && \
git clone https://github.com/lllyasviel/IC-Light.git && \
cd IC-Light && \
pip install -r requirements.txt && \
python gradio_demo.py
```

## Accessing Your Service

After deployment, find your `http_pub` URL in **My Orders**:

1. Go to **My Orders** page
2. Click on your order
3. Find the `http_pub` URL (e.g., `abc123.clorecloud.net`)

Use `https://YOUR_HTTP_PUB_URL` instead of `localhost` in examples below.

## Installation

```bash
git clone https://github.com/lllyasviel/IC-Light.git
cd IC-Light
pip install -r requirements.txt

# Models download automatically on first run
```

## What You Can Create

### Product Photography

* Perfect lighting for e-commerce
* Consistent catalog images
* Studio-quality results without studio

### Portrait Enhancement

* Fix bad lighting in photos
* Add dramatic lighting effects
* Create professional headshots

### Creative Projects

* Mood transformation
* Day-to-night conversion
* Artistic lighting effects

### Video Production

* Match lighting across scenes
* Create VFX-ready footage
* Fix on-location lighting issues

### Marketing Materials

* Hero image creation
* Consistent brand imagery
* Quick photo retouching

## Basic Usage

### Foreground Relighting (FC Mode)

Relight subject with background intact:

```python
import torch
from PIL import Image
from diffusers import StableDiffusionPipeline
from ic_light import ICLightFC

# Load model
model = ICLightFC.from_pretrained("lllyasviel/IC-Light-FC")
model.to("cuda")

# Load image
image = Image.open("portrait.jpg")

# Relight with text prompt
result = model.relight(
    image=image,
    prompt="golden hour sunlight from the left",
    num_inference_steps=25
)

result.save("relit_portrait.jpg")
```

### Background Conditioned (FBC Mode)

Relight foreground to match new background:

```python
from ic_light import ICLightFBC
from PIL import Image

model = ICLightFBC.from_pretrained("lllyasviel/IC-Light-FBC")
model.to("cuda")

# Load foreground and new background
foreground = Image.open("person.png")  # With transparent background
background = Image.open("sunset_scene.jpg")

# Relight to match background
result = model.relight(
    foreground=foreground,
    background=background,
    prompt="warm sunset lighting",
    num_inference_steps=25
)

result.save("composited.jpg")
```

## Lighting Prompts

### Direction-Based Lighting

```python
prompts = [
    "bright light from the left side",
    "soft light from above",
    "dramatic backlight from behind",
    "rim lighting from the right",
    "front facing diffused light",
    "low angle light from below"
]
```

### Color-Based Lighting

```python
prompts = [
    "warm golden sunlight",
    "cool blue twilight",
    "neon pink light",
    "green ambient light",
    "orange sunset glow",
    "white studio lighting"
]
```

### Environment-Based Lighting

```python
prompts = [
    "outdoor daylight, bright sun",
    "indoor window light, soft shadows",
    "night city lights, neon reflections",
    "candlelight, warm flickering",
    "cloudy day, diffused lighting",
    "studio softbox, professional"
]
```

## Batch Processing

```python
import os
from PIL import Image
from ic_light import ICLightFC

model = ICLightFC.from_pretrained("lllyasviel/IC-Light-FC")
model.to("cuda")

input_dir = "./images"
output_dir = "./relit"
os.makedirs(output_dir, exist_ok=True)

lighting_prompt = "professional studio lighting, soft shadows"

for filename in os.listdir(input_dir):
    if not filename.endswith(('.jpg', '.png')):
        continue

    image = Image.open(os.path.join(input_dir, filename))

    result = model.relight(
        image=image,
        prompt=lighting_prompt,
        num_inference_steps=25
    )

    result.save(os.path.join(output_dir, f"relit_{filename}"))
    print(f"Processed: {filename}")
```

## Multiple Lighting Variations

```python
from ic_light import ICLightFC
from PIL import Image
import os

model = ICLightFC.from_pretrained("lllyasviel/IC-Light-FC")
model.to("cuda")

image = Image.open("product.jpg")

lighting_variations = {
    "daylight": "bright natural daylight, clean white background",
    "dramatic": "dramatic side lighting, dark shadows",
    "warm": "warm golden hour, soft orange glow",
    "cool": "cool blue lighting, modern aesthetic",
    "studio": "professional studio softbox, even lighting"
}

os.makedirs("./variations", exist_ok=True)

for name, prompt in lighting_variations.items():
    result = model.relight(
        image=image,
        prompt=prompt,
        num_inference_steps=25
    )
    result.save(f"./variations/{name}.jpg")
    print(f"Generated: {name}")
```

## Gradio Interface

```python
import gradio as gr
from PIL import Image
from ic_light import ICLightFC

model = ICLightFC.from_pretrained("lllyasviel/IC-Light-FC")
model.to("cuda")

def relight_image(image, prompt, steps, seed):
    generator = torch.Generator("cuda").manual_seed(seed) if seed > 0 else None

    result = model.relight(
        image=image,
        prompt=prompt,
        num_inference_steps=steps,
        generator=generator
    )

    return result

demo = gr.Interface(
    fn=relight_image,
    inputs=[
        gr.Image(type="pil", label="Input Image"),
        gr.Textbox(
            label="Lighting Prompt",
            value="professional studio lighting",
            placeholder="Describe the desired lighting..."
        ),
        gr.Slider(10, 50, value=25, step=5, label="Steps"),
        gr.Number(value=-1, label="Seed (-1 for random)")
    ],
    outputs=gr.Image(label="Relit Image"),
    title="IC-Light - AI Image Relighting",
    description="Change lighting in any image with text descriptions. Running on CLORE.AI GPU servers.",
    examples=[
        ["example.jpg", "golden hour sunlight from the left", 25, -1],
        ["example.jpg", "dramatic rim lighting, dark background", 25, -1],
        ["example.jpg", "soft window light, gentle shadows", 25, -1]
    ]
)

demo.launch(server_name="0.0.0.0", server_port=7860)
```

## ComfyUI Integration

IC-Light is available as ComfyUI nodes:

```bash
cd ComfyUI/custom_nodes
git clone https://github.com/kijai/ComfyUI-IC-Light.git
```

### ComfyUI Workflow

1. Load your image
2. Add IC-Light Loader node
3. Connect to IC-Light Apply node
4. Set lighting prompt
5. Connect to KSampler
6. Output to Save Image

## With Background Removal

```python
from ic_light import ICLightFBC
from rembg import remove
from PIL import Image

# Remove background first
original = Image.open("photo.jpg")
foreground = remove(original)

# Load new background
background = Image.open("studio_bg.jpg")

# Relight to match
model = ICLightFBC.from_pretrained("lllyasviel/IC-Light-FBC")
model.to("cuda")

result = model.relight(
    foreground=foreground,
    background=background,
    prompt="studio lighting matching background",
    num_inference_steps=25
)

result.save("composited.jpg")
```

## Performance

| Mode            | Resolution | GPU      | Speed |
| --------------- | ---------- | -------- | ----- |
| FC (foreground) | 512x512    | RTX 3090 | 3s    |
| FC (foreground) | 512x512    | RTX 4090 | 2s    |
| FBC (composite) | 512x512    | RTX 4090 | 3s    |
| FC (foreground) | 1024x1024  | A100     | 4s    |

## Model Variants

| Model        | Description                      | Use Case                     |
| ------------ | -------------------------------- | ---------------------------- |
| IC-Light-FC  | Foreground Consistent            | Single image relighting      |
| IC-Light-FBC | Foreground-Background Consistent | Compositing with backgrounds |

## Common Problems & Solutions

### Lighting Doesn't Change

**Problem:** Output looks similar to input

**Solutions:**

* Use more descriptive lighting prompts
* Increase inference steps to 30-40
* Try different seed values
* Use stronger contrast in prompt (e.g., "dramatic" vs "soft")

```python

# More descriptive prompt
result = model.relight(
    image=image,
    prompt="extremely bright dramatic spotlight from upper left, dark shadows on right side",
    num_inference_steps=35
)
```

### Artifacts on Face/Details

**Problem:** Face or details look distorted

**Solutions:**

* Lower strength/guidance scale
* Use more inference steps
* Keep lighting changes subtle
* Post-process with face restoration

### Color Shift Issues

**Problem:** Unwanted color changes

**Solutions:**

* Be specific about color in prompt
* Add "preserve original colors" to prompt
* Use color-neutral lighting descriptions
* Post-process color correction

### Background Changes

**Problem:** Background changes when only foreground should

**Solutions:**

* Use FC mode (foreground consistent)
* Pre-process with background removal
* Use mask to isolate subject

### Inconsistent Results

**Problem:** Same prompt gives very different results

**Solutions:**

* Set fixed seed for reproducibility
* Increase inference steps for stability
* Use simpler, more direct prompts

```python

# Consistent results with fixed seed
result = model.relight(
    image=image,
    prompt=prompt,
    num_inference_steps=30,
    generator=torch.Generator("cuda").manual_seed(42)
)
```

## Troubleshooting

### Relighting looks unnatural

* Match lighting direction with scene
* Use appropriate light intensity
* Consider shadows in original image

### Background affected

* Use foreground mask properly
* Segment subject from background first
* Adjust light falloff settings

### Output too dark/bright

* Adjust light intensity values
* Use HDR output if available
* Post-process with curves

### Model not loading

* Download all required checkpoints
* Check file integrity
* Verify CUDA compatibility

## Cost Estimate

Typical CLORE.AI marketplace rates (as of 2024):

| GPU       | Hourly Rate | Daily Rate | 4-Hour Session |
| --------- | ----------- | ---------- | -------------- |
| RTX 3060  | \~$0.03     | \~$0.70    | \~$0.12        |
| RTX 3090  | \~$0.06     | \~$1.50    | \~$0.25        |
| RTX 4090  | \~$0.10     | \~$2.30    | \~$0.40        |
| A100 40GB | \~$0.17     | \~$4.00    | \~$0.70        |
| A100 80GB | \~$0.25     | \~$6.00    | \~$1.00        |

*Prices vary by provider and demand. Check* [*CLORE.AI Marketplace*](https://clore.ai/marketplace) *for current rates.*

**Save money:**

* Use **Spot** market for flexible workloads (often 30-50% cheaper)
* Pay with **CLORE** tokens
* Compare prices across different providers

## Next Steps

* [TripoSR](/guides/3d-generation/triposr.md) - Convert relit images to 3D
* Stable Diffusion - Generate images to relight
* ComfyUI - Advanced workflow integration
* [Fooocus](/guides/image-generation/fooocus-simple-sd.md) - Simple image generation


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/image-processing/iclight.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
