SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2404.07987 · ECCV · 2024

ControlNet++: Improving Conditional Controls with Efficient Consistency Feedback

Taojiannan Yang, Chen Chen, Ming Li, Jie Wu, Zhaoning Wang, Xuefeng Xiao, Huafeng Kuang

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 2 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2404.07987.json · badge: /api/ran/2404.07987.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
liming-ai/ControlNet_Plus_Plus canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
eval_canny Ran
ran; our contract draft was wrong, not the code
liming-ai/ControlNet_Plus_Plus/eval/eval_edge.py
code served (permissive licence) · get_code("48ef6b1820273e3f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import torch
import numpy as np
from PIL import Image
from io import BytesIO

torch.manual_seed(0)

# Create mock metric callables
class MockSSIM:
    def __call__(self, pred, gt):
        return torch.tensor(0.95)

class MockPSNR:
    def __call__(self, pred, gt):
        return torch.tensor(25.5)

class MockF1:
    def __call__(self, pred, gt):
        return torch.tensor(0.88)

# Create temporary directories and files
anno_dir = "/tmp/anno_dir"
img_dir = "/tmp/img_dir"
os.makedirs(anno_dir, exist_ok=True)
for i in range(4):
    os.makedirs(os.path.join(img_dir, f"group_{i}"), exist_ok=True)

# Create a sample ground truth canny edge image
gt_img_array = np.random.randint(0, 256, (32, 48), dtype=np.uint8)
gt_img = Image.fromarray(gt_img_array, mode='L')
anno_name = "sample_anno.png"
gt_img.save(os.path.join(anno_dir, anno_name))

# Create predicted edge images for each group
for i in range(4):
    pred_img_array = np.random.randint(0, 256, (32, 48), dtype=np.uint8)
    pred_img = Image.fromarray(pred_img_array, mode='L')
    pred_img.save(os.path.join(img_dir, f"group_{i}", anno_name.replace('.png', '_edge.png')))

device = 'cpu'
ssim = MockSSIM()
psnr = MockPSNR()
fid = None  # Not used in the function
f1 = MockF1()
task = "canny_edge_detection"

pool_args = (anno_name, anno_dir, img_dir, device, ssim, psnr, fid, f1, task)

ARGS = {
    'pool_args': pool_args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, einops, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
eval_hed_lineart Ran
ran; our contract draft was wrong, not the code
liming-ai/ControlNet_Plus_Plus/eval/eval_edge.py
code served (permissive licence) · get_code("e4131995cb8c98dc")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import torch
import numpy as np
from PIL import Image
from einops import rearrange
from torchmetrics.image import StructuralSimilarityIndexMeasure, PeakSignalNoiseRatio
import tempfile
import shutil

torch.manual_seed(0)

# Create temporary directories for testing
temp_dir = tempfile.mkdtemp()
anno_dir = os.path.join(temp_dir, 'anno')
img_dir = os.path.join(temp_dir, 'img')

os.makedirs(anno_dir, exist_ok=True)
for i in range(4):
    os.makedirs(os.path.join(img_dir, f'group_{i}'), exist_ok=True)

# Create sample image files
anno_name = 'test_anno.png'
gt_img = Image.fromarray(np.random.randint(0, 256, (8, 6), dtype=np.uint8), mode='L')
gt_img.save(os.path.join(anno_dir, anno_name))

for i in range(4):
    pred_img = Image.fromarray(np.random.randint(0, 256, (8, 6), dtype=np.uint8), mode='L')
    pred_img.save(os.path.join(img_dir, f'group_{i}', anno_name.replace('.png', '_lineart.png')))

# Create metric objects
ssim_metric = StructuralSimilarityIndexMeasure(data_range=1.0)
psnr_metric = PeakSignalNoiseRatio(data_range=1.0)

# Create a simple wrapper for fid and f1 (not used in this function but included)
class DummyMetric:
    def __call__(self, x, y):
        return torch.tensor(0.5)

device = 'cpu'
ssim = ssim_metric
psnr = psnr_metric
fid = DummyMetric()
f1 = DummyMetric()
task = 'lineart'

ARGS = {
    'pool_args': (anno_name, anno_dir, img_dir, device, ssim, psnr, fid, f1, task)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, einops, numpy, torch, torchmetrics — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_reward_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
liming-ai/ControlNet_Plus_Plus/eval/utils.py
code served (permissive licence) · get_code("18d2e9a97bf73a24")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# For segmentation task
predictions_seg = torch.randn(2, 4, 3, 3)  # batch=2, classes=4, spatial dims
labels_seg = torch.randint(0, 4, (2, 3, 3))  # batch=2, spatial dims with class indices

# For canny task
predictions_canny = torch.randn(2, 1, 5, 6)  # batch=2, channels=1, height=5, width=6
labels_canny = torch.randn(2, 1, 5, 6)  # same shape as predictions

# For depth/lineart/hed task
predictions_depth = torch.randn(2, 1, 4, 5)  # batch=2, channels=1
labels_depth = torch.randn(2, 1, 4, 5)  # same shape as predictions

ARGS = {
    'predictions': predictions_seg,
    'labels': labels_seg,
    'task': 'segmentation'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_reward_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
liming-ai/ControlNet_Plus_Plus/train/utils.py
code served (permissive licence) · get_code("22da1ede48c4a8b0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Test segmentation task
predictions_seg = torch.randn(2, 4, 3, 3)  # batch=2, num_classes=4, spatial 3x3
labels_seg = torch.randint(0, 4, (2, 3, 3))  # batch=2, spatial 3x3

# Test canny task
predictions_canny = torch.randn(2, 1, 3, 3)  # batch=2, channels=1, spatial 3x3
labels_canny = torch.randn(2, 1, 3, 3)

# Test depth task
predictions_depth = torch.randn(2, 1, 3, 3)  # batch=2, channels=1, spatial 3x3
labels_depth = torch.randn(2, 1, 3, 3)

# Test lineart task
predictions_lineart = torch.randn(2, 1, 3, 3)
labels_lineart = torch.randn(2, 1, 3, 3)

# Test hed task
predictions_hed = torch.randn(2, 1, 3, 3)
labels_hed = torch.randn(2, 1, 3, 3)

ARGS = {
    'predictions': predictions_seg,
    'labels': labels_seg,
    'task': 'segmentation'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
image_grid Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
liming-ai/ControlNet_Plus_Plus/train/train_controlnet.py
code served (permissive licence) · get_code("bd5a05ce886da4ce")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Image. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from PIL import Image

# Create small test images with distinct dimensions
img1 = Image.new('RGB', size=(64, 48), color=(255, 0, 0))
img2 = Image.new('RGB', size=(64, 48), color=(0, 255, 0))
img3 = Image.new('RGB', size=(64, 48), color=(0, 0, 255))
img4 = Image.new('RGB', size=(64, 48), color=(255, 255, 0))

ARGS = {
    'imgs': [img1, img2, img3, img4],
    'rows': 2,
    'cols': 2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
PIL — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
image_grid Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
liming-ai/ControlNet_Plus_Plus/eval/utils.py
code served (permissive licence) · get_code("3be400a6bab25655")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Image. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from PIL import Image

# Create small test images
img1 = Image.new('RGB', size=(100, 80), color='red')
img2 = Image.new('RGB', size=(100, 80), color='blue')
img3 = Image.new('RGB', size=(100, 80), color='green')
img4 = Image.new('RGB', size=(100, 80), color='yellow')

ARGS = {
    'imgs': [img1, img2, img3, img4],
    'rows': 2,
    'cols': 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
import_model_class_from_model_name_or_path Not yet run
unverified (harvested, no recorded run)
liming-ai/ControlNet_Plus_Plus/train/train_controlnet.py
code served (permissive licence) · get_code("2f00b39db5a81466")
How it ran

no invocation recorded.

parse_args Not yet run
unverified (harvested, no recorded run)
liming-ai/ControlNet_Plus_Plus/train/reward_control.py
code served (permissive licence) · get_code("617029d711d81c8e")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 2 the same month, 2 later) and 5 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
import_model_class_from_model_name_or_path 24 other papers
11 dated earlier, 1 the same month, 11 later, 1 same year, order not determinable
2212.04489 (2022-12)
SINE: SINgle Image Editing with Text-to-Image Diffusion Models
2306.06874 (2023-06)
VillanDiffusion: A Unified Backdoor Attack Framework for Diffusion Models
2306.07280 (2023-06)
Controlling Text-to-Image Diffusion by Orthogonal Finetuning
and 21 more not named here
image_grid 17 other papers
8 dated earlier, 1 the same month, 7 later, 1 same year, order not determinable
2201.08896 (2022-01)
Environment Generation for Zero-Shot Compositional Reinforcement Learning
2303.09522 (2023-03)
P+: Extended Textual Conditioning in Text-to-Image Generation
2311.16518 (2023-11)
SeeSR: Towards Semantics-Aware Real-World Image Super-Resolution
and 14 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

To enhance the controllability of text-to-image diffusion models, existing efforts like ControlNet incorporated image-based conditional controls. In this paper, we reveal that existing methods still face significant challenges in generating images that align with the image conditional controls. To this end, we propose ControlNet++, a novel approach that improves controllable generation by explicitly optimizing pixel-level cycle consistency between generated images and conditional controls. Specifically, for an input conditional control, we use a pre-trained discriminative reward model to extract the corresponding condition of the generated images, and then optimize the consistency loss between the input conditional control and extracted condition. A straightforward implementation would be generating images from random noises and then calculating the consistency loss, but such an approach requires storing gradients for multiple sampling timesteps, leading to considerable time and memory costs. To address this, we introduce an efficient reward strategy that deliberately disturbs the input images by adding noise, and then uses the single-step denoised images for reward fine-tuning. This avoids the extensive costs associated with image sampling, allowing for more efficient reward fine-tuning. Extensive experiments show that ControlNet++ significantly improves controllability under various conditional controls. For example, it achieves improvements over ControlNet by 11.1% mIoU, 13.4% SSIM, and 7.6% RMSE, respectively, for segmentation mask, line-art edge, and depth conditions. All the code, models, demo and organized data have been open sourced on our Github Repo.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2404.07987")
get_code_for_paper("2404.07987")
have("2404.07987")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2404.07987.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2404.07987.svg)](https://syntology.ai/paper/2404.07987)

Connect an agent — have() is free.