repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
diffusers
examples/research_projects/wuerstchen/text_to_image/train_text_to_image_lora_prior.py
.py
# Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
951
38,069
diffusers
examples/research_projects/wuerstchen/text_to_image/train_text_to_image_prior.py
.py
# Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appl...
938
38,063
diffusers
examples/research_projects/wuerstchen/text_to_image/modeling_efficient_net_encoder.py
.py
import torch.nn as nn from torchvision.models import efficientnet_v2_l, efficientnet_v2_s from diffusers.configuration_utils import ConfigMixin, register_to_config from diffusers.models.modeling_utils import ModelMixin class EfficientNetEncoder(ModelMixin, ConfigMixin): @register_to_config def __init__(self,...
24
881
diffusers
examples/research_projects/anytext/anytext_controlnet.py
.py
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
464
22,020
diffusers
examples/research_projects/anytext/anytext.py
.py
# Copyright 2026 The HuggingFace Team. All rights reserved. # Copyright (c) Alibaba, Inc. and its affiliates. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
2,367
110,235
diffusers
examples/research_projects/anytext/ocr_recog/RecModel.py
.py
from torch import nn from .RecCTCHead import CTCHead from .RecMv1_enhance import MobileNetV1Enhance from .RNN import Im2Im, Im2Seq, SequenceEncoder backbone_dict = {"MobileNetV1Enhance": MobileNetV1Enhance} neck_dict = {"SequenceEncoder": SequenceEncoder, "Im2Seq": Im2Seq, "None": Im2Im} head_dict = {"CTCHead": CTCH...
50
1,753
diffusers
examples/research_projects/anytext/ocr_recog/common.py
.py
import torch import torch.nn as nn import torch.nn.functional as F class Hswish(nn.Module): def __init__(self, inplace=True): super(Hswish, self).__init__() self.inplace = inplace def forward(self, x): return x * F.relu6(x + 3.0, inplace=self.inplace) / 6.0 # out = max(0, min(1, slo...
75
2,187
diffusers
examples/research_projects/anytext/ocr_recog/RNN.py
.py
import torch from torch import nn from .RecSVTR import Block class Swish(nn.Module): def __int__(self): super(Swish, self).__int__() def forward(self, x): return x * torch.sigmoid(x) class Im2Im(nn.Module): def __init__(self, in_channels, **kwargs): super().__init__() s...
210
6,455
diffusers
examples/research_projects/anytext/ocr_recog/RecMv1_enhance.py
.py
import torch import torch.nn as nn import torch.nn.functional as F from .common import Activation class ConvBNLayer(nn.Module): def __init__( self, num_channels, filter_size, num_filters, stride, padding, channels=None, num_groups=1, act="hard_swish" ): super(ConvBNLayer, self).__init__() ...
198
6,095
diffusers
examples/research_projects/anytext/ocr_recog/RecCTCHead.py
.py
from torch import nn class CTCHead(nn.Module): def __init__( self, in_channels, out_channels=6625, fc_decay=0.0004, mid_channels=None, return_feats=False, **kwargs ): super(CTCHead, self).__init__() if mid_channels is None: self.fc = nn.Linear( in_channels, ...
46
1,181
diffusers
examples/research_projects/anytext/ocr_recog/RecSVTR.py
.py
import numpy as np import torch import torch.nn as nn from torch.nn import functional from torch.nn.init import ones_, trunc_normal_, zeros_ def drop_path(x, drop_prob=0.0, training=False): """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). the original name is mislead...
571
18,891
diffusers
examples/research_projects/instructpix2pix_lora/train_instruct_pix2pix_lora.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,172
49,495
diffusers
examples/research_projects/diffusion_dpo/train_diffusion_dpo_sdxl.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 bram-w, The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
1,142
46,776
diffusers
examples/research_projects/diffusion_dpo/train_diffusion_dpo.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 bram-w, The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/lic...
984
39,736
diffusers
examples/research_projects/vae/vae_roundtrip.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
284
8,521
diffusers
examples/research_projects/consistency_training/train_cm_ct_unconditional.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,439
59,948
diffusers
examples/research_projects/pytorch_xla/inference/flux/flux_inference.py
.py
from argparse import ArgumentParser from pathlib import Path from time import perf_counter import structlog import torch import torch_xla.core.xla_model as xm import torch_xla.debug.metrics as met import torch_xla.debug.profiler as xp import torch_xla.distributed.xla_multiprocessing as xmp import torch_xla.runtime as ...
135
5,435
diffusers
examples/research_projects/pytorch_xla/inference/flux/flux_inference_spmd.py
.py
"""FLUX inference on TPU using PyTorch/XLA SPMD. Uses SPMD to shard the transformer across multiple TPU chips, enabling inference on devices where the model doesn't fit on a single chip (e.g., v5e). The VAE is loaded on CPU at startup, moved to XLA for decode, then moved back. """ from argparse import ArgumentParser ...
194
7,354
diffusers
examples/research_projects/pytorch_xla/training/text_to_image/train_text_to_image_xla.py
.py
import argparse import os import random import time from pathlib import Path import datasets import numpy as np import torch import torch.nn.functional as F import torch.utils.checkpoint import torch_xla.core.xla_model as xm import torch_xla.debug.profiler as xp import torch_xla.distributed.parallel_loader as pl impor...
671
23,704
diffusers
examples/research_projects/sana/train_sana_sprint_diffusers.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 Sana-Sprint team. All rights reserved. # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of ...
1,783
71,982
diffusers
examples/research_projects/flux_lora_quantization/train_dreambooth_lora_flux_miniature.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,202
47,146
diffusers
examples/research_projects/flux_lora_quantization/compute_embeddings.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
108
3,808
diffusers
examples/research_projects/multi_token_textual_inversion/textual_inversion_flax.py
.py
import argparse import logging import math import os import random from pathlib import Path import jax import jax.numpy as jnp import numpy as np import optax import PIL import torch import torch.utils.checkpoint import transformers from flax import jax_utils from flax.training import train_state from flax.training.co...
655
24,712
diffusers
examples/research_projects/multi_token_textual_inversion/multi_token_clip.py
.py
""" The main idea for this code is to provide a way for users to not need to bother with the hassle of multiple tokens for a concept by typing a photo of <concept>_0 <concept>_1 ... and so on and instead just do a photo of <concept> which gets translated to the above. This needs to work for both inference and training....
105
4,344
diffusers
examples/research_projects/multi_token_textual_inversion/textual_inversion.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
939
38,600
diffusers
examples/research_projects/scheduled_huber_loss_training/text_to_image/train_text_to_image_lora_sdxl.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,385
58,488
diffusers
examples/research_projects/scheduled_huber_loss_training/text_to_image/train_text_to_image.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,163
48,430
diffusers
examples/research_projects/scheduled_huber_loss_training/text_to_image/train_text_to_image_sdxl.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,395
59,612
diffusers
examples/research_projects/scheduled_huber_loss_training/text_to_image/train_text_to_image_lora.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,052
44,229
diffusers
examples/research_projects/scheduled_huber_loss_training/dreambooth/train_dreambooth_lora.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,506
60,743
diffusers
examples/research_projects/scheduled_huber_loss_training/dreambooth/train_dreambooth.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,520
61,751
diffusers
examples/research_projects/scheduled_huber_loss_training/dreambooth/train_dreambooth_lora_sdxl.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
2,079
87,908
diffusers
examples/research_projects/promptdiffusion/promptdiffusioncontrolnet.py
.py
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
387
19,228
diffusers
examples/research_projects/promptdiffusion/convert_original_promptdiffusion_to_diffusers.py
.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
2,120
90,530
diffusers
examples/research_projects/promptdiffusion/pipeline_prompt_diffusion.py
.py
# Copyright 2023 The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
1,340
67,973
diffusers
examples/research_projects/lpl/train_sdxl_lpl.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,623
69,328
diffusers
examples/research_projects/lpl/lpl_loss.py
.py
# Copyright 2025 Berrada et al. import numpy as np import torch import torch.nn as nn import torch.nn.functional as F def normalize_tensor(in_feat, eps=1e-10): norm_factor = torch.sqrt(torch.sum(in_feat**2, dim=1, keepdim=True)) return in_feat / (norm_factor + eps) def cross_normalize(input, target, eps=1e...
216
8,200
diffusers
examples/research_projects/multi_subject_dreambooth/train_multi_subject_dreambooth.py
.py
import argparse import itertools import json import logging import math import uuid import warnings from os import environ, listdir, makedirs from os.path import basename, join from pathlib import Path from typing import List import datasets import numpy as np import torch import torch.nn.functional as F import torch....
1,196
50,141
diffusers
examples/research_projects/pixart/pipeline_pixart_alpha_controlnet.py
.py
# Copyright 2025 PixArt-Alpha Authors and The HuggingFace Team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unl...
1,099
49,805
diffusers
examples/research_projects/pixart/controlnet_pixart_alpha.py
.py
from typing import Any, Dict, Optional import torch from torch import nn from diffusers.configuration_utils import ConfigMixin, register_to_config from diffusers.models import PixArtTransformer2DModel from diffusers.models.attention import BasicTransformerBlock from diffusers.models.modeling_outputs import Transforme...
292
11,986
diffusers
examples/research_projects/pixart/run_pixart_alpha_controlnet_pipeline.py
.py
import torch import torchvision.transforms as T from controlnet_aux import HEDdetector from diffusers.utils import load_image from examples.research_projects.pixart.controlnet_pixart_alpha import PixArtControlNetAdapterModel from examples.research_projects.pixart.pipeline_pixart_alpha_controlnet import PixArtAlphaCont...
76
2,466
diffusers
examples/research_projects/pixart/train_pixart_controlnet_hf.py
.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
1,175
49,099
diffusers
examples/research_projects/autoencoder_rae/train_autoencoder_rae.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
406
17,370
diffusers
examples/research_projects/sdxl_flax/sdxl_single_aot.py
.py
import time import jax import jax.numpy as jnp import numpy as np from flax.jax_utils import replicate from jax import pmap # Let's cache the model compilation, so that it doesn't take as long the next time around. from jax.experimental.compilation_cache import compilation_cache as cc from diffusers import FlaxStabl...
144
5,758
diffusers
examples/research_projects/sdxl_flax/sdxl_single.py
.py
# Show best practices for SDXL JAX import time import jax import jax.numpy as jnp import numpy as np from flax.jax_utils import replicate # Let's cache the model compilation, so that it doesn't take as long the next time around. from jax.experimental.compilation_cache import compilation_cache as cc from diffusers im...
107
4,031
diffusers
examples/research_projects/control_lora/control_lora.py
.py
import cv2 import numpy as np import torch from PIL import Image from diffusers import ( AutoencoderKL, ControlNetModel, StableDiffusionXLControlNetPipeline, UNet2DConditionModel, ) from diffusers.utils import load_image, make_image_grid pipe_id = "stabilityai/stable-diffusion-xl-base-1.0" lora_id = ...
59
1,848
diffusers
examples/research_projects/gligen/train_gligen_text.py
.py
# from accelerate.utils import write_basic_config # # write_basic_config() import argparse import logging import math import os import shutil from pathlib import Path import accelerate import torch import torch.nn.functional as F import torch.utils.checkpoint import transformers from accelerate import Accelerator from...
716
29,367
diffusers
examples/research_projects/gligen/make_datasets.py
.py
import argparse import os import random import torch import torchvision import torchvision.transforms as TS from PIL import Image from ram import inference_ram from ram.models import ram from tqdm import tqdm from transformers import ( AutoModelForZeroShotObjectDetection, AutoProcessor, Blip2ForConditional...
120
4,701
diffusers
examples/research_projects/gligen/dataset.py
.py
import os import random import torch import torchvision.transforms as transforms from PIL import Image def recalculate_box_and_verify_if_valid(x, y, w, h, image_size, original_image_size, min_box_size): scale = image_size / min(original_image_size) crop_y = (original_image_size[1] * scale - image_size) // 2 ...
111
3,858
diffusers
examples/research_projects/rdm/retriever.py
.py
import os from typing import List import faiss import numpy as np import torch from datasets import Dataset, load_dataset from PIL import Image from transformers import CLIPImageProcessor, CLIPModel, PretrainedConfig from diffusers import logging logger = logging.get_logger(__name__) # pylint: disable=invalid-name...
249
8,971
diffusers
examples/research_projects/rdm/pipeline_rdm.py
.py
import inspect from typing import Callable, List, Optional, Union import torch from PIL import Image from retriever import Retriever, normalize_images, preprocess_images from transformers import CLIPImageProcessor, CLIPModel, CLIPTokenizer from diffusers import ( AutoencoderKL, DDIMScheduler, DiffusionPip...
345
16,975
diffusers
examples/research_projects/lora/train_text_to_image_lora.py
.py
# coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
1,027
43,344
diffusers
examples/research_projects/realfill/infer.py
.py
import argparse import os import torch from PIL import Image, ImageFilter from transformers import CLIPTextModel from diffusers import DPMSolverMultistepScheduler, StableDiffusionInpaintPipeline, UNet2DConditionModel parser = argparse.ArgumentParser(description="Inference") parser.add_argument( "--model_path", ...
92
2,491
diffusers
examples/research_projects/realfill/train_realfill.py
.py
import argparse import copy import itertools import logging import math import os import random import shutil from pathlib import Path import numpy as np import torch import torch.nn.functional as F import torch.utils.checkpoint import torchvision.transforms.v2 as transforms_v2 import transformers from accelerate impo...
985
37,362
diffusers
examples/research_projects/diffusion_orpo/train_diffusion_orpo_sdxl_lora_wds.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,097
44,381
diffusers
examples/research_projects/diffusion_orpo/train_diffusion_orpo_sdxl_lora.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,094
44,742
diffusers
examples/research_projects/dreambooth_inpaint/train_dreambooth_inpaint.py
.py
import argparse import itertools import math import os import random from pathlib import Path import numpy as np import torch import torch.nn.functional as F import torch.utils.checkpoint from accelerate import Accelerator from accelerate.logging import get_logger from accelerate.utils import ProjectConfiguration, set...
813
33,292
diffusers
examples/research_projects/dreambooth_inpaint/train_dreambooth_inpaint_lora.py
.py
import argparse import math import os import random from pathlib import Path import numpy as np import torch import torch.nn.functional as F import torch.utils.checkpoint from accelerate import Accelerator from accelerate.logging import get_logger from accelerate.utils import ProjectConfiguration, set_seed from huggin...
832
34,795
diffusers
examples/cogview4-control/train_control_cogview4.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,244
52,617
diffusers
examples/instruct_pix2pix/train_instruct_pix2pix_sdxl.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 Harutatsu Akiyama and The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www....
1,262
53,990
diffusers
examples/instruct_pix2pix/train_instruct_pix2pix.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,044
44,753
diffusers
examples/instruct_pix2pix/test_instruct_pix2pix.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
93
3,614
diffusers
examples/flux-control/train_control_lora_flux.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,408
59,771
diffusers
examples/flux-control/train_control_flux.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,251
52,461
diffusers
examples/unconditional_image_generation/test_unconditional.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
125
4,998
diffusers
examples/unconditional_image_generation/train_unconditional.py
.py
import argparse import inspect import logging import math import os import shutil from datetime import timedelta from pathlib import Path import accelerate import datasets import torch import torch.nn.functional as F from accelerate import Accelerator, InitProcessGroupKwargs from accelerate.logging import get_logger f...
750
31,274
diffusers
examples/vqgan/test_vqgan.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
379
16,220
diffusers
examples/vqgan/train_vqgan.py
.py
# coding=utf-8 # Copyright 2023 The HuggingFace Inc. team. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable...
1,068
43,480
diffusers
examples/vqgan/discriminator.py
.py
""" Ported from Paella """ import torch from torch import nn from diffusers.configuration_utils import ConfigMixin, register_to_config from diffusers.models.modeling_utils import ModelMixin # Discriminator model ported from Paella https://github.com/dome272/Paella/blob/main/src_distributed/vqgan.py class Discrimina...
49
1,722
diffusers
examples/dreambooth/train_dreambooth_lora_ideogram4.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
2,208
95,023
diffusers
examples/dreambooth/test_dreambooth_lora_qwenimage.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
299
12,940
diffusers
examples/dreambooth/test_dreambooth_lora_edm.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
100
4,059
diffusers
examples/dreambooth/train_dreambooth_lora_flux2_klein_img2img.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,950
80,828
diffusers
examples/dreambooth/train_dreambooth_lora_lumina2.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,582
63,050
diffusers
examples/dreambooth/train_dreambooth_lora_sana.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,603
63,064
diffusers
examples/dreambooth/train_dreambooth_lora_qwen_image.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,963
82,240
diffusers
examples/dreambooth/convert_to_imagefolder.py
.py
import argparse import json import pathlib parser = argparse.ArgumentParser() parser.add_argument( "--path", type=str, required=True, help="Path to folder with image-text pairs.", ) parser.add_argument("--caption_column", type=str, default="prompt", help="Name of caption column.") args = parser.parse_...
33
1,016
diffusers
examples/dreambooth/test_dreambooth_sd3.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
198
7,944
diffusers
examples/dreambooth/train_dreambooth_lora_sd3.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
2,009
82,773
diffusers
examples/dreambooth/train_dreambooth_lora.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,471
59,491
diffusers
examples/dreambooth/test_dreambooth_lora_sd3.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
267
11,419
diffusers
examples/dreambooth/train_dreambooth_flax.py
.py
import argparse import logging import math import os from pathlib import Path import jax import jax.numpy as jnp import numpy as np import optax import torch import torch.utils.checkpoint import transformers from flax import jax_utils from flax.training import train_state from flax.training.common_utils import shard f...
702
27,302
diffusers
examples/dreambooth/test_dreambooth_lora_lumina2.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
204
8,650
diffusers
examples/dreambooth/train_dreambooth_lora_flux.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
2,009
80,963
diffusers
examples/dreambooth/test_dreambooth_lora_flux.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
279
11,802
diffusers
examples/dreambooth/train_dreambooth.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,457
59,238
diffusers
examples/dreambooth/train_dreambooth_lora_sdxl.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
2,039
86,933
diffusers
examples/dreambooth/train_dreambooth_lora_hidream.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,799
73,119
diffusers
examples/dreambooth/train_dreambooth_flux.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,871
75,862
diffusers
examples/dreambooth/test_dreambooth_lora_flux_kontext.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
279
11,857
diffusers
examples/dreambooth/test_dreambooth_lora_sana.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
246
10,230
diffusers
examples/dreambooth/test_dreambooth_flux.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
198
7,949
diffusers
examples/dreambooth/test_dreambooth_lora_flux2.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
260
10,884
diffusers
examples/dreambooth/train_dreambooth_lora_krea2.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
2,080
90,162
diffusers
examples/dreambooth/train_dreambooth_lora_flux2_klein.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
2,083
87,393
diffusers
examples/dreambooth/test_dreambooth_lora.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
373
15,922
diffusers
examples/dreambooth/test_dreambooth_lora_flux2_klein.py
.py
# coding=utf-8 # Copyright 2026 HuggingFace Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ag...
314
13,577
diffusers
examples/dreambooth/train_dreambooth_lora_z_image.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,969
80,052
diffusers
examples/dreambooth/train_dreambooth_sd3.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
1,819
74,074
diffusers
examples/dreambooth/train_dreambooth_lora_flux2.py
.py
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
2,113
88,310