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30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
---
license: apache-2.0
task_categories:
- image-to-image
- object-detection
language:
- en
tags:
- industry
- synthetic
- spills
size_categories:
- 1K<n<10K
pretty_name: 'SynSpill: Improved Spill Detection with Synthetic Data'
---
Paper: https://arxiv.org/abs/2508.10171
Project Page: https://synspill.vercel.app

## SynSpill Reproduction Guide

Create a conda environment and install the dependencies (Python 3.12).

### 1. Environment Setup

```bash
# Clone and setup
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI

# Install dependencies
pip install -r requirements.txt

# Install PyTorch (NVIDIA GPU)
pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu128

```bash
# Manual ComfyUI Manager installation
cd custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Manager.git
cd ..

# Install custom nodes
./install_custom_nodes.sh
```

### 2. Download Required Models

#### Model Directory Structure
```
models/
├── checkpoints/     # Base diffusion models (.safetensors)
├── vae/            # VAE models
├── loras/          # LoRA weights
├── controlnet/     # ControlNet models
├── clip_vision/    # CLIP vision models
└── ipadapter/      # IP-Adapter models
```

#### Required Models for Research Reproduction

**Base Models:**

```bash
# Create directories
mkdir -p models/checkpoints models/loras models/ipadapter models/clip_vision

# SDXL-Turbo Inpainting Model
wget -P models/checkpoints/ https://huggingface.co/stabilityai/sdxl-turbo/resolve/main/sd_xl_turbo_1.0_fp16.safetensors
```

**IP-Adapter Components:**

```bash
# IP Composition Adapter - Download specific files
wget -P models/ipadapter/ https://huggingface.co/ostris/ip-composition-adapter/resolve/main/ip_plus_composition_sd15.safetensors
# Or for SDXL version:
wget -P models/ipadapter/ https://huggingface.co/ostris/ip-composition-adapter/resolve/main/ip_plus_composition_sdxl.safetensors

# CLIP ViT-H/14 LAION-2B - Download model files
wget -P models/clip_vision/ https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K/resolve/main/open_clip_pytorch_model.bin
wget -P models/clip_vision/ https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K/resolve/main/config.json
```

**Manual Downloads Required:**

- **Interior Scene XL**: Visit https://civitai.com/models/715747/interior-scene-xl and download the model file to `models/checkpoints/`
- **Factory Model** (optional): Visit https://civitai.com/models/77373/factory for additional scene generation

**Note:** Some models from CivitAI require account registration and manual download due to licensing agreements.

### 3. Custom Nodes Installation

#### Automated Installation (Recommended)

We provide a comprehensive installation script that clones all the custom nodes used in this research:

```bash
# Make the script executable (if not already)
chmod +x install_custom_nodes.sh

# Run the installation script
./install_custom_nodes.sh
```

**Installed Custom Nodes Include:**

- **ComfyUI Manager** - Essential for managing nodes and models
- **ComfyUI IPAdapter Plus** - IP-Adapter functionality for composition
- **ComfyUI Impact Pack/Subpack** - Advanced image processing and segmentation
- **ComfyUI Inspire Pack** - Additional workflow utilities
- **ComfyUI Custom Scripts** - Workflow enhancements and UI improvements
- **ComfyUI Dynamic Prompts** - Dynamic prompt generation
- **ComfyUI KJNodes** - Various utility nodes for image processing
- **ComfyUI Ultimate SD Upscale** - Advanced upscaling capabilities
- **ComfyUI GGUF** - Support for GGUF model format
- **ComfyUI Image Filters** - Comprehensive image filtering nodes
- **ComfyUI Depth Anything V2** - Depth estimation capabilities
- **ComfyUI RMBG** - Background removal functionality
- **ComfyUI FizzNodes** - Animation and scheduling nodes
- **RGThree ComfyUI** - Advanced workflow management
- **WAS Node Suite** - Comprehensive collection of utility nodes
- **And more...**

### 4. Using ComfyUI Manager

After installing ComfyUI Manager, you can easily install missing nodes and models:

```bash
# Start ComfyUI first
python main.py --listen 0.0.0.0 --port 8188
```

**In the ComfyUI Web Interface:**

1. **Access Manager**: Click the "Manager" button in the ComfyUI interface
2. **Install Missing Nodes**: 
   - Load any workflow that uses custom nodes
   - Click "Install Missing Custom Nodes" to automatically install required nodes
3. **Install Models**: 
   - Go to "Model Manager" tab
   - Search and install models directly from the interface
   - Supports HuggingFace, CivitAI, and other model repositories

**Alternative Model Installation via Manager:**

- **Checkpoints**: Search for "SDXL" or "Stable Diffusion" models
- **IP-Adapters**: Search for "IP-Adapter" in the model manager
- **ControlNets**: Browse and install ControlNet models as needed
- **LoRAs**: Install LoRA models directly through the interface

**Benefits of using ComfyUI Manager:**

- Automatic dependency resolution
- One-click installation of missing nodes
- Model browser with direct download
- Version management
- Automatic updates

### 5. Start ComfyUI Server

```bash
# Local access
python main.py

# Network access (for cluster/remote)
python main.py --listen 0.0.0.0 --port 8188

# With latest frontend
python main.py --front-end-version Comfy-Org/ComfyUI_frontend@latest
```

Access at: `http://localhost:8188`

## Research-Specific Features

### Custom Guidance Methods

- **FreSca**: Frequency-dependent scaling guidance (`comfy_extras/nodes_fresca.py`)
- **PAG**: Perturbed Attention Guidance (`comfy_extras/nodes_pag.py`) 
- **SAG**: Self Attention Guidance (`comfy_extras/nodes_sag.py`)
- **SLG**: Skip Layer Guidance (`comfy_extras/nodes_slg.py`)
- **APG**: Adaptive Patch Guidance (`comfy_extras/nodes_apg.py`)
- **Mahiro**: Direction-based guidance scaling (`comfy_extras/nodes_mahiro.py`)

### Advanced Sampling

- Custom samplers and schedulers (`comfy_extras/nodes_custom_sampler.py`)
- Token merging optimization (`comfy_extras/nodes_tomesd.py`)
- Various diffusion model sampling methods

## Research Configuration

### Key Hyperparameters for Synthetic Image Generation

The following table summarizes the key hyperparameters used in our synthetic image generation pipeline:

| Parameter | Value / Configuration |
|-----------|----------------------|
| **Scene Generation Specifics** | |
| Base Model | Stable Diffusion XL 1.0 |
| Image Resolution | 1024 × 1024 |
| Sampler | DDPM-SDE-2m-GPU |
| Scheduler | Karras |
| Sampling Steps | 64 |
| CFG Scale | 8 |
| LoRA Strength | 0.2–0.4 |
| IP-Adapter | IP Composition+CLIP-ViT-H |
| IP-Adapter Strength | 0.6 |
| **Inpainting Specifics** | |
| Inpainting Model | SDXL-Turbo Inpainting |
| Differential Diffusion | Enabled |
| Mask Feathering | 50 pixels |
| Mask Opacity | 75% |
| Denoise Strength | 0.5-0.6 |

### Model References

- **Interior Scene XL**: https://civitai.com/models/715747/interior-scene-xl
- **SDXL-Turbo**: https://huggingface.co/stabilityai/sdxl-turbo
- **IP Composition Adapter**: https://huggingface.co/ostris/ip-composition-adapter
- **CLIP ViT-H/14 LAION-2B**: https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K

### Configuration in ComfyUI

When setting up workflows in ComfyUI, ensure the following nodes are configured with the specified parameters:

**KSampler/KSampler Advanced:**

- Steps: 64
- CFG: 8.0
- Sampler: ddpm_sde_gpu (or ddpm_sde if GPU version unavailable)
- Scheduler: karras

**LoRA Loader:**

- Strength Model: 0.2-0.4 range
- Strength CLIP: 0.2-0.4 range

**IPAdapter:**

- Weight: 0.6
- Weight Type: composition (for IP Composition Adapter)

**Inpainting Specific:**

- Denoise: 0.5-0.6
- Use differential diffusion when available
- Mask feathering: 50 pixels
- Mask opacity: 0.75

## Running Experiments

### Load Research Workflows

1. Navigate to ComfyUI interface
2. Load workflows from `user/default/workflows/`:
   - `IMG-SDTune-Lightning-RD.json`
   - `Inpaint.json` 
   - `IP-Adapter.json`
   - `Test Factory.json`

**Using ComfyUI Manager with Workflows:**

- When loading workflows, if nodes are missing, ComfyUI Manager will show a popup
- Click "Install Missing Custom Nodes" to automatically install required nodes
- Restart ComfyUI after installation
- Reload the workflow to verify all nodes are available

### For Cluster Usage

See `CLUSTER_ACCESS_README.md` for detailed SLURM cluster setup with SSH tunneling.

### API Usage

```python
# Basic API example
python script_examples/basic_api_example.py

# WebSocket examples  
python script_examples/websockets_api_example.py
```

## Troubleshooting

**CUDA Issues:**

```bash

pip uninstall torch
pip install torch --extra-index-url https://download.pytorch.org/whl/cu128
```

**Memory Issues:**

```bash
python main.py --cpu  # CPU fallback
python main.py --force-fp32  # Lower precision
```

**Custom Nodes Not Loading:**

- Check `custom_nodes/` directory
- Restart ComfyUI after installing new nodes
- Check logs for dependency issues
- Use ComfyUI Manager to reinstall problematic nodes
- Try "Update All" in ComfyUI Manager for compatibility fixes

**ComfyUI Manager Issues:**

- If Manager button doesn't appear, restart ComfyUI
- Check that ComfyUI-Manager is properly cloned in `custom_nodes/`
- For model download failures, try manual wget commands provided above
- Clear browser cache if Manager interface doesn't load properly

**Custom Nodes Installation Script Issues:**

- If script fails with permission errors, run: `chmod +x install_custom_nodes.sh`
- For network issues, try running the script again (it will skip existing installations)
- If specific nodes fail to clone, check your internet connection and GitHub access
- Some nodes may require additional dependencies - check individual node README files
- After running the script, restart ComfyUI to load all new nodes

## Directory Structure

After setup, your ComfyUI directory should look like this:

```
ComfyUI/
├── models/
│   ├── checkpoints/
│   │   ├── [SDXL models]
│   │   └── [Inpainting models]
│   ├── loras/
│   │   └── [LoRA models]
│   ├── controlnet/
│   │   └── [ControlNet models]
│   ├── ipadapter/
│   │   └── [IP-Adapter models]
│   └── [other model directories]
├── custom_nodes/
│   ├── ComfyUI-Manager/
│   ├── ComfyUI-IPAdapter-Plus/
│   └── [other extensions]
└── [other ComfyUI files]
```

## SynSpill Integration

After ComfyUI is set up:

1. Clone the SynSpill repository
2. Copy the provided ComfyUI workflows to your ComfyUI directory
3. Configure the data paths in the workflow files
4. Run the synthetic data generation pipeline

# Data Directory

This directory contains datasets and annotations for the SynSpill project.

## Structure

- `synthetic/` - Generated synthetic spill images and annotations
- `real/` - Real-world industrial CCTV footage (test set)
- `annotations/` - Ground truth labels and bounding boxes

## Synthetic Data

The synthetic dataset is generated using our AnomalInfusion pipeline:

- Stable Diffusion XL for base image generation
- IP adapters for style conditioning
- Inpainting for precise spill placement

## Citation

If you use this data in your research, please cite our ICCV 2025 paper.
=======
# SynSpill Data Directory

This directory contains datasets, annotations, and workflow configurations for the SynSpill project - a comprehensive dataset for industrial spill detection and synthesis.

## Directory Structure

```text
data/
├── README.md                    # This file
├── generation_workflow.json    # ComfyUI workflow for synthetic image generation
├── inpainting_workflow.json    # ComfyUI workflow for inpainting operations
├── release/                     # Full dataset release
│   ├── annotation_masks/        # Binary masks for spill regions (PNG format)
│   ├── annotations/             # Ground truth annotations and metadata
│   └── generated_images/        # Complete set of synthetic spill images
└── samples/                     # Sample data for preview and testing
    ├── annotation_masks/        # Sample binary masks
    ├── generated_images/        # Sample synthetic images
    └── inpainted_images/        # Sample inpainted results
```

## Dataset Contents

### Release Dataset (`release/`)

- **Generated Images**: High-quality synthetic industrial spill scenarios
- **Annotation Masks**: Pixel-perfect binary masks identifying spill regions
- **Annotations**: Structured metadata including bounding boxes, class labels, and scene descriptions

### Sample Dataset (`samples/`)

A subset of the full dataset for quick evaluation and testing purposes, containing:

- Representative examples from each category
- Various spill types and industrial environments
- Both generated and inpainted image samples

### Workflow Configurations

- **`generation_workflow.json`**: ComfyUI workflow for generating base synthetic images using Stable Diffusion XL
- **`inpainting_workflow.json`**: ComfyUI workflow for precise spill placement and inpainting operations

## Synthetic Data Generation

The synthetic dataset is created using our AnomalInfusion pipeline:

1. **Base Generation**: Stable Diffusion XL creates industrial environment images
2. **Style Conditioning**: IP adapters ensure consistent visual style across scenes
3. **Spill Synthesis**: Controlled inpainting places realistic spills in specified locations
4. **Mask Generation**: Automated creation of precise segmentation masks

## Usage

The data is organized for direct use with computer vision frameworks:

- Images are in standard formats (PNG/JPG)
- Masks are binary images (0 = background, 255 = spill)
- Annotations follow standard object detection formats

## Citation

If you use this dataset in your research, please cite our ICCV 2025 paper:

```bibtex
@inproceedings{baranwal2025synspill,
    title={SynSpill: Improved Industrial Spill Detection With Synthetic Data},
    author={Baranwal, Aaditya and Bhatia, Guneet and Mueez, Abdul and Voelker, Jason and Vyas, Shruti},
    booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision - Workshops (ICCV-W)},
    year={2025}
}
```


# Troubleshooting

### Common Issues

- **CUDA out of memory**: Reduce batch size or use model offloading
- **Missing models**: Ensure all models are downloaded and placed in correct directories
- **Extension conflicts**: Check ComfyUI Manager for compatibility issues

### Performance Optimization

- Use `--lowvram` flag if you have limited GPU memory
- Consider using `--cpu` for CPU-only inference (slower)
- Enable model offloading for better memory management