Views
No views yet
| Variant | Training | Focus |
|---|---|---|
| UniDG-SFT (this) | Diversity-SFT with complementary sampling | Diverse defect patterns |
| UniDG-RFT | Consistency-RFT with Flow-GRPO + dual rewards | Consistent & faithful defects |
1from unidg import ImageUniDG
2from PIL import Image
3import torch
4
5model = ImageUniDG(
6 flux_model_path="path/to/FLUX.1-Fill-dev",
7 redux_model_path="path/to/FLUX.1-Redux-dev",
8 lora_weights_path="path/to/UniDG-SFT-LoRA/lora_weights.safetensors",
9 device="cuda:0",
10 dtype=torch.bfloat16,
11)
12
13result, mask = model.process_images(
14 target_image=Image.open("target.jpg"),
15 reference_image=Image.open("reference.jpg"),
16 reference_mask=Image.open("reference_mask.png"),
17 target_mask=Image.open("target_mask.png"),
18 num_inference_steps=28,
19 guidance_scale=3.5,
20 seed=42,
21)
22result.save("result.png")1@article{fan2026unidg,
2 title={Large-Scale Universal Defect Generation: Foundation Models and Datasets},
3 author={Fan, Yuanting and Liu, Jun and Gao, Bin-Bin and Chen, Xiaochen and Lin, Yuhuan and Dai, Zhewei and Zhan, Jiawei and Wang, Chengjie},
4 journal={arXiv preprint arXiv:2604.08915},
5 year={2026}
6}