Views
No views yet
inference and training, the other for scoring and evaluation.000279227.aesthetic_score (unused)000279227.caption (string)000279227.height (int)000279227.image (binary; can be read as PNG — we highly recommend saving images locally as .png)000279227.original_key (unused)000279227.segmentation (dict)000279227.url (unused)000279227.width (int)[
{
"gt_image_path": "/your/path/to/000279227.png",
"caption": "000279227.caption",
"height": 000279227.height,
"width": 000279227.width,
"segmentation": 000279227.segmentation,
"image_id": "00027_000279227"
}
// ...
]1conda create -n train python=3.12
2cd ./flux
3pip install -e ".[all]"
4cd ../diffusers
5pip install -e ".[torch]"
6pip install omegaconf transformers==4.52.0 accelerate==1.6.0 datasets==3.5.0 deepspeed==0.17.11conda create -n eval python=3.12
2pip install image-reward
3pip install hpsv2==1.2.0
4pip install open-clip-torch==2.32.0
5pip install clip
6pip install torchmetrics==1.7.4
7cd ./t2v_metrics
8conda install pip -y
9conda install ffmpeg -c conda-forge
10pip install -e .
11cd ..
12pip install transformers==4.45.2
13pip install hpsv3
14pip install tensorboard
15pip install wandb~/miniconda3/envs/test_eval/lib/python3.12/site-packages/hpsv2/src/open_clip/~/miniconda3/envs/test_eval/lib/python3.12/site-packages/hpsv2/__init__.py and ~/miniconda3/envs/test_eval/lib/python3.12/site-packages/hpsv2/img_score.py for multi-gpu evaluation, we also provide our modified version under extra/Installation and the random seed in either:
/path/to/configs_flux.yaml/path/to/configs_brushnet.yamlscripts/sample_flux.pyscripts/sample_brushnet.pygenerator_seed in configs/configs_<model>.yaml to control diversity.1# BrushNet
2accelerate launch \
3 --config_file /root/.cache/huggingface/accelerate/accelerate_default.yaml \
4 scripts/sample_brushnet.py
5# FLUX.1 Fill
6accelerate launch \
7 --config_file /root/.cache/huggingface/accelerate/accelerate_default.yaml \
8 scripts/sample_flux.pyscripts/merge_score_jsons.ipynb to produce a list-style JSON for scoring.CodeGoat24/UnifiedReward-qwen-7b1conda activate vllm
2bash scripts/vllm_server.sh1conda activate eval
2accelerate launch
3 --config_file /root/.cache/huggingface/accelerate/accelerate_default.yaml \
4 scripts/score.py \
5 --metric <ensemble> \
6 --annotation_path /path/to/annotation_list \
7 --output_dir /path/to/output \1python /root/test_env/scripts/score_unifiedreward.py
2 --annotation_path /path/to/annotation_list
3 --output_dir /path/to/output
4 --seed 0
5 --port <port_you_specify_when_launching_vllm>scripts/merge_score_jsons.ipynb to attach scores to annotations for training.configs/configs_<model>.yaml.1conda activate train
2accelerate launch \
3 --config_file /root/test_env/configs/accelerate_flux.yaml \
4 scripts/train_flux_dpo.py1conda activate train
2accelerate launch \
3 --config_file /root/.cache/huggingface/accelerate/accelerate_default.yaml \
4 /root/test_env/scripts/train_brushnet_dpo.py1conda activate train
2accelerate launch \
3 --num_processes 8 \
4 --mixed_precision bf16 \
5 script gen.py \
6 --ckpt_path /path/to/ckpt \
7 --base_model_path [black-forest-labs/FLUX.1-Fill-dev|runwayml/stable-diffusion-v1-5] \
8 --image_save_path /path/to/save/images \
9 --mapping_file /path/to/BrushBench/mapping_file_list.json \
10 --base_dir /path/to/BrushBench \
11 --use_blended \
12 --model flux \
13 --benchmark brushbench \
14 --num_steps 50 # To reproduce our results, 20 for FLUX.1 Fill and 10 for BrushNet1conda activate eval
2accelerate launch
3 --num_processes 8 \
4 --mixed_precision bf16 \
5 scripts/eval.py \
6 --image_save_path /path/to/save/images \
7 --benchmark brushbench \
8 --mapping_file /path/to/BrushBench/mapping_file_list.json \
9 --base_dir /path/to/BrushBench \
10 --use_blend1python scripts/eval_gpt4.py \
2 --save_path /path/to/save/results \
3 --mapping_file /path/to/BrushBench/mapping_file_list.json \
4 --mask_key inpainting_mask \
5 --base_dir /path/to/bench \
6 --image_dir /path/to/images/to/eval1from diffusers import StableDiffusionBrushNetPipeline, BrushNetModel, UniPCMultistepScheduler
2import torch
3import cv2
4import numpy as np
5from PIL import Image
6
7brushnet = BrushNetModel.from_pretrained(ckpt_path, torch_dtype=torch.float16)
8pipe = StableDiffusionBrushNetPipeline.from_pretrained(
9 "runwayml/stable-diffusion-v1-5", brushnet=brushnet, torch_dtype=torch.float16
10).to("cuda")
11pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
12
13init_image = cv2.imread(...)[:,:,::-1]
14mask_image = 1.*(cv2.imread(...).sum(-1)>255)[:,:,np.newaxis]
15init_image = init_image * (1-mask_image)
16init_image = Image.fromarray(init_image.astype(np.uint8)).convert("RGB")
17mask_image = Image.fromarray(mask_image.astype(np.uint8).repeat(3,-1)*255).convert("RGB")
18
19image = pipe(
20 caption,
21 init_image,
22 mask_image,
23 num_inference_steps=50,
24 generator=generator,
25 brushnet_conditioning_scale=brushnet_conditioning_scale
26).images[0]
27image.save(f"output.png")1import torch
2from diffusers import FluxFillPipeline, FluxTransformer2DModel
3from PIL import Image
4
5image = Image.open(...).convert("RGB")
6mask = Image.open(...).convert("RGB")
7ckpt_path = ...
8
9transformer = FluxTransformer2DModel.from_pretrained(
10 ckpt_path, torch_dtype=torch.bfloat16
11).to(device)
12pipe = FluxFillPipeline.from_pretrained(
13 "black-forest-labs/FLUX.1-Fill-dev",
14 torch_dtype=torch.bfloat16,
15 transformer=transformer
16).to("cuda")
17
18image = pipe(
19 prompt="...",
20 image=image,
21 mask_image=mask,
22 height=512,
23 width=512,
24 guidance_scale=30,
25 num_inference_steps=20,
26 generator=torch.Generator("cpu").manual_seed(0)
27).images[0]
28image.save(f"output.png")