Skip to content

Commit f1af7e2

Browse files
authored
Merge branch 'main' into flux_lora_advanced
2 parents 22046d1 + f10775b commit f1af7e2

File tree

14 files changed

+38
-52
lines changed

14 files changed

+38
-52
lines changed

.github/workflows/pr_style_bot.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,5 @@ jobs:
1313
uses: huggingface/huggingface_hub/.github/workflows/style-bot-action.yml@main
1414
with:
1515
python_quality_dependencies: "[quality]"
16-
pre_commit_script_name: "Download and Compare files from the main branch"
17-
pre_commit_script: |
18-
echo "Downloading the files from the main branch"
19-
20-
curl -o main_Makefile https://raw.githubusercontent.com/huggingface/diffusers/main/Makefile
21-
curl -o main_setup.py https://raw.githubusercontent.com/huggingface/diffusers/refs/heads/main/setup.py
22-
curl -o main_check_doc_toc.py https://raw.githubusercontent.com/huggingface/diffusers/refs/heads/main/utils/check_doc_toc.py
23-
24-
echo "Compare the files and raise error if needed"
25-
26-
diff_failed=0
27-
if ! diff -q main_Makefile Makefile; then
28-
echo "Error: The Makefile has changed. Please ensure it matches the main branch."
29-
diff_failed=1
30-
fi
31-
32-
if ! diff -q main_setup.py setup.py; then
33-
echo "Error: The setup.py has changed. Please ensure it matches the main branch."
34-
diff_failed=1
35-
fi
36-
37-
if ! diff -q main_check_doc_toc.py utils/check_doc_toc.py; then
38-
echo "Error: The utils/check_doc_toc.py has changed. Please ensure it matches the main branch."
39-
diff_failed=1
40-
fi
41-
42-
if [ $diff_failed -eq 1 ]; then
43-
echo "❌ Error happened as we detected changes in the files that should not be changed ❌"
44-
exit 1
45-
fi
46-
47-
echo "No changes in the files. Proceeding..."
48-
rm -rf main_Makefile main_setup.py main_check_doc_toc.py
49-
style_command: "make style && make quality"
5016
secrets:
5117
bot_token: ${{ secrets.GITHUB_TOKEN }}

examples/instruct_pix2pix/train_instruct_pix2pix.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
from diffusers.optimization import get_scheduler
5050
from diffusers.training_utils import EMAModel
5151
from diffusers.utils import check_min_version, deprecate, is_wandb_available
52+
from diffusers.utils.constants import DIFFUSERS_REQUEST_TIMEOUT
5253
from diffusers.utils.import_utils import is_xformers_available
5354
from diffusers.utils.torch_utils import is_compiled_module
5455

@@ -418,7 +419,7 @@ def convert_to_np(image, resolution):
418419

419420

420421
def download_image(url):
421-
image = PIL.Image.open(requests.get(url, stream=True).raw)
422+
image = PIL.Image.open(requests.get(url, stream=True, timeout=DIFFUSERS_REQUEST_TIMEOUT).raw)
422423
image = PIL.ImageOps.exif_transpose(image)
423424
image = image.convert("RGB")
424425
return image

examples/research_projects/instructpix2pix_lora/train_instruct_pix2pix_lora.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
from diffusers.optimization import get_scheduler
5555
from diffusers.training_utils import EMAModel, cast_training_params
5656
from diffusers.utils import check_min_version, convert_state_dict_to_diffusers, deprecate, is_wandb_available
57+
from diffusers.utils.constants import DIFFUSERS_REQUEST_TIMEOUT
5758
from diffusers.utils.hub_utils import load_or_create_model_card, populate_model_card
5859
from diffusers.utils.import_utils import is_xformers_available
5960
from diffusers.utils.torch_utils import is_compiled_module
@@ -475,7 +476,7 @@ def convert_to_np(image, resolution):
475476

476477

477478
def download_image(url):
478-
image = PIL.Image.open(requests.get(url, stream=True).raw)
479+
image = PIL.Image.open(requests.get(url, stream=True, timeout=DIFFUSERS_REQUEST_TIMEOUT).raw)
479480
image = PIL.ImageOps.exif_transpose(image)
480481
image = image.convert("RGB")
481482
return image

examples/research_projects/promptdiffusion/convert_original_promptdiffusion_to_diffusers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
UnCLIPScheduler,
6060
)
6161
from diffusers.utils import is_accelerate_available, logging
62+
from diffusers.utils.constants import DIFFUSERS_REQUEST_TIMEOUT
6263

6364

6465
if is_accelerate_available():
@@ -1435,7 +1436,7 @@ def download_from_original_stable_diffusion_ckpt(
14351436
config_url = "https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/x4-upscaling.yaml"
14361437

14371438
if config_url is not None:
1438-
original_config_file = BytesIO(requests.get(config_url).content)
1439+
original_config_file = BytesIO(requests.get(config_url, timeout=DIFFUSERS_REQUEST_TIMEOUT).content)
14391440
else:
14401441
with open(original_config_file, "r") as f:
14411442
original_config_file = f.read()

scripts/convert_dance_diffusion_to_diffusers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from torch import nn
1212

1313
from diffusers import DanceDiffusionPipeline, IPNDMScheduler, UNet1DModel
14+
from diffusers.utils.constants import DIFFUSERS_REQUEST_TIMEOUT
1415

1516

1617
MODELS_MAP = {
@@ -74,7 +75,7 @@ def __init__(self, global_args):
7475

7576
def download(model_name):
7677
url = MODELS_MAP[model_name]["url"]
77-
r = requests.get(url, stream=True)
78+
r = requests.get(url, stream=True, timeout=DIFFUSERS_REQUEST_TIMEOUT)
7879

7980
local_filename = f"./{model_name}.ckpt"
8081
with open(local_filename, "wb") as fp:

scripts/convert_vae_pt_to_diffusers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
renew_vae_attention_paths,
1414
renew_vae_resnet_paths,
1515
)
16+
from diffusers.utils.constants import DIFFUSERS_REQUEST_TIMEOUT
1617

1718

1819
def custom_convert_ldm_vae_checkpoint(checkpoint, config):
@@ -122,7 +123,8 @@ def vae_pt_to_vae_diffuser(
122123
):
123124
# Only support V1
124125
r = requests.get(
125-
" https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml"
126+
" https://raw.githubusercontent.com/CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml",
127+
timeout=DIFFUSERS_REQUEST_TIMEOUT,
126128
)
127129
io_obj = io.BytesIO(r.content)
128130

src/diffusers/loaders/single_file_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
is_transformers_available,
4545
logging,
4646
)
47+
from ..utils.constants import DIFFUSERS_REQUEST_TIMEOUT
4748
from ..utils.hub_utils import _get_model_file
4849

4950

@@ -443,7 +444,7 @@ def fetch_original_config(original_config_file, local_files_only=False):
443444
"Please provide a valid local file path."
444445
)
445446

446-
original_config_file = BytesIO(requests.get(original_config_file).content)
447+
original_config_file = BytesIO(requests.get(original_config_file, timeout=DIFFUSERS_REQUEST_TIMEOUT).content)
447448

448449
else:
449450
raise ValueError("Invalid `original_config_file` provided. Please set it to a valid file path or URL.")

src/diffusers/pipelines/kolors/pipeline_kolors.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from ...callbacks import MultiPipelineCallbacks, PipelineCallback
2121
from ...image_processor import PipelineImageInput, VaeImageProcessor
22-
from ...loaders import IPAdapterMixin, StableDiffusionXLLoraLoaderMixin
22+
from ...loaders import IPAdapterMixin, StableDiffusionLoraLoaderMixin
2323
from ...models import AutoencoderKL, ImageProjection, UNet2DConditionModel
2424
from ...models.attention_processor import AttnProcessor2_0, FusedAttnProcessor2_0, XFormersAttnProcessor
2525
from ...schedulers import KarrasDiffusionSchedulers
@@ -121,16 +121,16 @@ def retrieve_timesteps(
121121
return timesteps, num_inference_steps
122122

123123

124-
class KolorsPipeline(DiffusionPipeline, StableDiffusionMixin, StableDiffusionXLLoraLoaderMixin, IPAdapterMixin):
124+
class KolorsPipeline(DiffusionPipeline, StableDiffusionMixin, StableDiffusionLoraLoaderMixin, IPAdapterMixin):
125125
r"""
126126
Pipeline for text-to-image generation using Kolors.
127127
128128
This model inherits from [`DiffusionPipeline`]. Check the superclass documentation for the generic methods the
129129
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)
130130
131131
The pipeline also inherits the following loading methods:
132-
- [`~loaders.StableDiffusionXLLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
133-
- [`~loaders.StableDiffusionXLLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
132+
- [`~loaders.StableDiffusionLoraLoaderMixin.load_lora_weights`] for loading LoRA weights
133+
- [`~loaders.StableDiffusionLoraLoaderMixin.save_lora_weights`] for saving LoRA weights
134134
- [`~loaders.IPAdapterMixin.load_ip_adapter`] for loading IP Adapters
135135
136136
Args:

src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
UnCLIPScheduler,
5353
)
5454
from ...utils import is_accelerate_available, logging
55+
from ...utils.constants import DIFFUSERS_REQUEST_TIMEOUT
5556
from ..latent_diffusion.pipeline_latent_diffusion import LDMBertConfig, LDMBertModel
5657
from ..paint_by_example import PaintByExampleImageEncoder
5758
from ..pipeline_utils import DiffusionPipeline
@@ -1324,7 +1325,7 @@ def download_from_original_stable_diffusion_ckpt(
13241325
config_url = "https://raw.githubusercontent.com/Stability-AI/stablediffusion/main/configs/stable-diffusion/x4-upscaling.yaml"
13251326

13261327
if config_url is not None:
1327-
original_config_file = BytesIO(requests.get(config_url).content)
1328+
original_config_file = BytesIO(requests.get(config_url, timeout=DIFFUSERS_REQUEST_TIMEOUT).content)
13281329
else:
13291330
with open(original_config_file, "r") as f:
13301331
original_config_file = f.read()

src/diffusers/utils/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
DIFFUSERS_DYNAMIC_MODULE_NAME = "diffusers_modules"
4141
HF_MODULES_CACHE = os.getenv("HF_MODULES_CACHE", os.path.join(HF_HOME, "modules"))
4242
DEPRECATED_REVISION_ARGS = ["fp16", "non-ema"]
43+
DIFFUSERS_REQUEST_TIMEOUT = 60
4344

4445
# Below should be `True` if the current version of `peft` and `transformers` are compatible with
4546
# PEFT backend. Will automatically fall back to PEFT backend if the correct versions of the libraries are

0 commit comments

Comments
 (0)