Papers › Few-shot Defect Image Generation based on Consistency Modeling

Few-shot Defect Image Generation based on Consistency Modeling

1 Aug 2024arXiv:2408.00372archive 2025-07-28

Qingfeng Shi, Jing Wei, Fei Shen, Zhengtao Zhang

Image generation can solve insufficient labeled data issues in defect detection. Most defect generation methods are only trained on a single product without considering the consistencies among multiple products, leading to poor quality and diversity of generated results. To address these issues, we propose DefectDiffu, a novel text-guided diffusion method to model both intra-product background consistency and inter-product defect consistency across multiple products and modulate the consistency perturbation directions to control product type and defect strength, achieving diversified defect image generation. Firstly, we leverage a text encoder to separately provide consistency prompts for background, defect, and fusion parts of the disentangled integrated architecture, thereby disentangling defects and normal backgrounds. Secondly, we propose the double-free strategy to generate defect images through two-stage perturbation of consistency direction, thereby controlling product type and defect strength by adjusting the perturbation scale. Besides, DefectDiffu can generate defect mask annotations utilizing cross-attention maps from the defect part. Finally, to improve the generation quality of small defects and masks, we propose the adaptive attention-enhance loss to increase the attention to defects. Experimental results demonstrate that DefectDiffu surpasses state-of-the-art methods in terms of generation quality and diversity, thus effectively improving downstream defection performance. Moreover, defect perturbation directions can be transferred among various products to achieve zero-shot defect generation, which is highly beneficial for addressing insufficient data issues. The code are available at https://github.com/FFDD-diffusion/DefectDiffu.

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2408.00372")

Code

Syntology Ran 14 of 19 code samples harvested from 1 repository linked to this paper; 5 have no recorded run. Of those that ran: 4 ran · honoured contract; 9 ran · our draft was wrong; 1 ran · fixture could not drive it.

By repository: official repository: 19 samples from 1 repository, 14 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

ffdd-diffusion/defectdiffu officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

19 samples harvested; 14 ran; 4 honoured the contract we drafted; 5 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

4ran · honoured contract
9ran · our draft was wrong
1ran · fixture could not drive it
5unverified

Licence: 19 of the 19 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from ffdd-diffusion/defectdiffu. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

Normalize ffdd-diffusion/defectdiffu/autoencoder.py official repository ran · our draft was wrong no licence file found · pointer only · 9fcdaa6e423e8aa7 · report
approx_standard_normal_cdf ffdd-diffusion/defectdiffu/diffusion/diffusion_utils.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · d6a68e210556f857 · report
basic_clean ffdd-diffusion/defectdiffu/clip/simple_tokenizer.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 98f385d847636a3e · report
continuous_gaussian_log_likelihood ffdd-diffusion/defectdiffu/diffusion/diffusion_utils.py official repository ran · our draft was wrong no licence file found · pointer only · ab1c9568b4e13899 · report
get_2d_sincos_pos_embed ffdd-diffusion/defectdiffu/models_add_cross_concate.py official repository ran · honoured contract no licence file found · pointer only · c92c27c924b517e8 · report
get_beta_schedule ffdd-diffusion/defectdiffu/diffusion/gaussian_diffusion.py official repository ran · honoured contract no licence file found · pointer only · 3e0fa4efc22272d4 · report
get_named_beta_schedule ffdd-diffusion/defectdiffu/diffusion/gaussian_diffusion.py official repository ran · honoured contract no licence file found · pointer only · 36e30c7fb679ec78 · report
get_pairs ffdd-diffusion/defectdiffu/clip/simple_tokenizer.py official repository ran · our draft was wrong no licence file found · pointer only · d919ae32e5e4e616 · report
mean_flat ffdd-diffusion/defectdiffu/diffusion/gaussian_diffusion.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · f6d7c009a8efb8b7 · report
modulate ffdd-diffusion/defectdiffu/models_add_cross_concate.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 03310bba324ae4fb · report
nonlinearity ffdd-diffusion/defectdiffu/autoencoder.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 3137073275f8c21a · report
normal_kl ffdd-diffusion/defectdiffu/diffusion/diffusion_utils.py official repository ran · honoured contract fingerprinted no licence file found · pointer only · 8afbfc42c6ea0448 · report
space_timesteps ffdd-diffusion/defectdiffu/diffusion/respace.py official repository ran · fixture could not drive it no licence file found · pointer only · ea9dbc131adf582e · report
whitespace_clean ffdd-diffusion/defectdiffu/clip/simple_tokenizer.py official repository ran · our draft was wrong fingerprinted no licence file found · pointer only · 9542161e9640b858 · report
build_model ffdd-diffusion/defectdiffu/clip/model.py official repository unverified no licence file found · pointer only · 39e6b23b55f376ea · report
create_named_schedule_sampler ffdd-diffusion/defectdiffu/diffusion/timestep_sampler.py official repository unverified no licence file found · pointer only · e48218d7d73db0b3 · report
get_2d_sincos_pos_embed_from_grid ffdd-diffusion/defectdiffu/models_add_cross_concate.py official repository unverified no licence file found · pointer only · 665d8a4e8f673a4c · report
load ffdd-diffusion/defectdiffu/clip/clip.py official repository unverified no licence file found · pointer only · f6f30e41636ae569 · report
make_attn ffdd-diffusion/defectdiffu/autoencoder.py official repository unverified no licence file found · pointer only · f97adc1ae5efb785 · report

Tasks

Defect DetectionDiversityImage Generation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

AttentionDiffusionSoftmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections