0% 0/28 [00:07<?, ?it/s] Traceback (most recent call last): File…
- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
0%| | 0/28 [00:07<?, ?it/s] Traceback (most recent call last): File "/path/lib/python3.11/site-packages/gradio/queueing.py", line 407, in call_prediction output = await route_utils.call_process_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/gradio/route_utils.py", line 226, in call_process_api output = await app.get_blocks().process_api( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/gradio/blocks.py", line 1550, in process_api result = await self.call_function( ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/gradio/blocks.py", line 1185, in call_function prediction = await anyio.to_thread.run_sync( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2470, in run_sync_in_worker_thread return await future ^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 967, in run result = context.run(func, *args) ^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/gradio/utils.py", line 661, in wrapper response = f(*args, **kwargs) ^^^^^^^^^^^^^^^^^^ File "/home/uwuntu/code/projects/rm_obj_video/Omnieraser/ControlNet_version/gradio_controlnet_lora_flux.py", line 158, in infer return predict(input_image, ^^^^^^^^^^^^^^^^^^^^ File "/home/uwuntu/code/projects/rm_obj_video/Omnieraser/ControlNet_version/gradio_controlnet_lora_flux.py", line 112, in predict result = pipe( ^^^^^ File "/path/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/uwuntu/code/projects/rm_obj_video/Omnieraser/ControlNet_version/pipeline_flux_controlnet_removal.py", line 958, in call ) = self.controlnet( ^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/accelerate/hooks.py", line 170, in new_forward output = module._old_forward(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/uwuntu/code/projects/rm_obj_video/Omnieraser/ControlNet_version/controlnet_flux.py", line 332, in forward encoder_hidden_states, hidden_states = block( ^^^^^^ File "/path/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/uwuntu/code/projects/rm_obj_video/Omnieraser/ControlNet_version/transformer_flux.py", line 213, in forward attn_output, context_attn_output = self.attn( ^^^^^^^^^^ File "/path/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1739, in _wrapped_call_impl return self._call_impl(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1750, in _call_impl return forward_call(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/src/diffusers/src/diffusers/models/attention_processor.py", line 605, in forward return self.processor( ^^^^^^^^^^^^^^^ File "/path/src/diffusers/src/diffusers/models/attention_processor.py", line 2339, in call query = apply_rotary_emb(query, image_rotary_emb) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/path/src/diffusers/src/diffusers/models/embeddings.py", line 1197, in apply_rotary_emb cos, sin = freqs_cis # [S, D] ^^^^^^^^ ValueError: not enough values to unpack (expected 2, got 1)
controlnet = FluxControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch_dtype)
gr.Info(str(f"Model loading: {int((20 / 100) * 100)}%"))
transformer = FluxTransformer2DModel.from_pretrained(base_model_path, subfolder='transformer', torch_dtype=torch_dtype)
gr.Info(str(f"Model loading: {int((40 / 100) * 100)}%"))
pipe = FluxControlNetInpaintingPipeline.from_pretrained(
pretrained_model_name_or_path=base_model_path,
controlnet=controlnet,
transformer=transformer,
torch_dtype=torch_dtype
)
pipe.transformer.to(torch_dtype)
pipe.controlnet.to(torch_dtype)
gr.Info(str(f"Model loading: {int((80 / 100) * 100)}%"))
gr.Info(str(f"Inject LoRA: {lora_path}"))
pipe.load_lora_weights(lora_path, weight_name="controlnet_flux_pytorch_lora_weights.safetensors")
gr.Info(str(f"Model loading: {int((100 / 100) * 100)}%"))
i tried installing diffusers 0.25.1 got the error: ImportError: cannot import name 'cached_download' from 'huggingface_hub' (/path/lib/python3.11/site-packages/huggingface_hub/init.py) had 0.34.dev0 before (pip install -e git+https://github.com/huggingface/diffusers.git in their requirements) and did had this error but had previous
The traceback indicates a ValueError: not enough values to unpack (expected 2, got 1) occurring in the apply_rotary_emb function within diffusers/models/embeddings.py. This function expects freqs_cis to be an iterable with two elements (cosine and sine components for Rotary Embeddings) but receives only one.
This error is likely caused by an incompatibility between the version of the diffusers library you are using and the specific Flux ControlNet model or LoRA weights you are loading. Flux models, especially development versions, are rapidly evolving, and changes in the model architecture or the implementation of features like Rotary Embeddings can lead to such errors if not matched with a compatible diffusers version.
Several search results support this:
alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta model requires installing diffusers==0.30.2. This highlights the importance of using a specific diffusers version with certain Flux models.ValueError: not enough values to unpack (expected 2, got 1) in a ComfyUI context also involving diffusers and a Flux transformer model, pointing to an issue within the apply_rotary_emb function as well. This reinforces that the error is related to the interaction between Flux models and diffusers' RoPE implementation.apply_rotary_emb function in the diffusers GitHub repository, showing that it explicitly unpacks freqs_cis into cos, sin[1]. This confirms the source of the ValueError.Regarding the ImportError: cannot import name 'cached_download' from 'huggingface_hub', this is a known issue with older versions of diffusers trying to use newer versions of huggingface_hub. The cached_download function was removed in recent versions of huggingface_hub [9][2].
cached_download() was removed and recommends using hf_hub_download() instead. It also mentions huggingface-hub==0.25.2 as a version that still has the old function.ImportError, further confirming it's a common compatibility problem.You were using diffusers==0.34.dev0 which didn't have the ImportError but resulted in the ValueError. When you tried , you got the because this version is older and incompatible with a newer you likely have installed.
I tried: from diffusers.models.embeddings import apply_rotary_emb import torch
query = torch.randn(1, 2304, 128) # Example tensor, adjust shape based on your model
freqs_cis = torch.randn(2304, 128, 2) # Simulated freqs_cis (cos, sin)
try: result = apply_rotary_emb(query, freqs_cis) print("Success: apply_rotary_emb works!") except Exception as e: print(f"Error: {e}")
And it still does not work
torch: 2.6.0+cu124 diffusers: 0.30.2 transformers: 4.42.0
You've done a good step by trying to isolate the apply_rotary_emb function. However, if your test with query = torch.randn(1, 2304, 128) and freqs_cis = torch.randn(2304, 128, 2) still gives the ValueError: not enough values to unpack (expected 2, got 1), that is very strange and suggests a potential issue with your specific installation of diffusers==0.30.2 or how PyTorch is interacting with it. The function apply_rotary_emb in diffusers is designed to unpack freqs_cis into two tensors, cos and sin, and your provided freqs_cis shape (2304, 128, 2) has the necessary dimension of size 2 for this unpacking.
Let's clarify the result of your test: Did it produce the exact same ValueError? Or a different error? If it was the same ValueError, please double-check the shape of freqs_cis immediately before the apply_rotary_emb call within your test code to be absolutely sure it is (2304, 128, 2) at that point.
One significant observation is your PyTorch version: torch: 2.6.0+cu124. According to the search results, PyTorch 2.6.0 was released on January 29, 2025, and is a recent release [1, 2][1]. While it is a release version, using a very new version of PyTorch with a slightly older version of diffusers (0.30.2 was released in August 2024 [4]) could lead to compatibility issues, especially with features that interact closely with PyTorch internals like Rotary Embeddings (apply_rotary_emb uses PyTorch tensor operations) or CUDA versions. diffusers typically specifies compatibility with a range of PyTorch versions [5, 7]. While 0.30.2 likely works with stable PyTorch 2.x releases up to a certain point, 2.6.0 might be too new.
The ValueError you are seeing (not enough values to unpack (expected 2, got 1)) strongly indicates that the tensor being passed as image_rotary_emb (which becomes freqs_cis inside apply_rotary_emb) within the pipeline does not have the expected last dimension of size 2. It's likely a tensor with a last dimension of 1 or something else that cannot be unpacked into two values. This points to an issue upstream in the pipeline where image_rotary_emb is generated or processed before being passed to apply_rotary_emb.
Considering your setup:
diffusers: 0.30.2diffusers==0.25.1ImportErrorhuggingface_hubTo resolve both issues, you need to find a compatible combination of diffusers, huggingface_hub, and the specific Flux ControlNet and LoRA models you are using.
Troubleshooting Steps:
diffusers version: Check the documentation or the model card on Hugging Face for the specific Flux ControlNet base model and LoRA weights you are using. They should specify the required or recommended diffusers version. Based on the search results, diffusers==0.30.2 is recommended for at least one Flux ControlNet inpainting model [2].diffusers version: Once you identify the correct version, uninstall your current diffusers and install the recommended one:
pip uninstall diffusers transformers accelerate huggingface_hub
pip install diffusers==[recommended_version]
huggingface_hub version: You might need to experiment with huggingface_hub versions that are compatible with the chosen diffusers version. Start with a recent version that is known to work with the recommended diffusers version. If you still get the ImportError, you might need to try slightly older versions of huggingface_hub until the error is resolved. You can find huggingface_hub releases on PyPI.
pip install huggingface_hub==[compatible_version]
Note: huggingface_hub==0.25.2 is mentioned as having cached_download [9], but it might be quite old. Newer diffusers versions expect hf_hub_download. It's better to find a diffusers version that uses the newer huggingface_hub API.transformers, accelerate, and torch are also compatible with the chosen diffusers version. The model card or diffusers documentation might provide guidance on this.diffusers version. Sometimes, models or LoRAs are trained with specific configurations or versions that need to be matched[1].The ValueError strongly suggests a mismatch in how Rotary Embeddings are handled between your diffusers version and the model. Updating/downgrading diffusers and ensuring huggingface_hub compatibility based on the model's requirements is the most likely solution.
transformers: 4.42.0torch: 2.6.0+cu124Recommendations:
ValueError is the bleeding-edge PyTorch version. diffusers 0.30.2 was released before PyTorch 2.6.0. It's highly recommended to use a stable PyTorch version that is known to be compatible with diffusers==0.30.2. Based on the search results [8], diffusers versions around 0.32.0 require PyTorch 2.3.0+. A stable version like PyTorch 2.3.0 or 2.3.1 with a compatible CUDA version (e.g., cu121) would be a safer bet for diffusers==0.30.2.
pip uninstall torch torchvision torchaudio (adjust based on what you have installed).pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121diffusers==0.30.2. Sometimes, specific models require a particular diffusers version or have specific setup instructions. Check the model cards or documentation on Hugging Face Hub for any version requirements.diffusers GitHub issues page for ValueError: not enough values to unpack or issues related to apply_rotary_emb and Flux models specifically with diffusers==0.30.2 or similar versions. [6] shows a similar error but in a different context (deepcompressor), and [10] shows a RuntimeError with diffusers==0.31.0 and a Flux model, again involving apply_rotary_emb, suggesting Flux models can be sensitive to diffusers versions.Your isolated test is useful for confirming the function's basic behavior with correctly shaped inputs, but the persistence of the error in the full pipeline strongly suggests the issue lies in the data being fed into apply_rotary_emb by the pipeline's preceding layers, likely due to the version mismatch with PyTorch. Focus on getting a stable and compatible PyTorch version installed first.