Repository: huggingface/diffusers

Issue:
Bug in `convert_original_stable_diffusion_to_diffusers.py`
### Describe the bug

See the steps to reproduce below.

This is caused by [this code change](https://github.com/huggingface/diffusers/commit/cb4b3f0b784db83309b3954bd2118c5dc9f30e8f#diff-10656ff1d173475012d0818b48f05a092001418ac70745e803b97fbb493dfb6aL10).  `yaml.safe_load()` takes a stream object not a file path name, so currently it just returns the file path, causing the error shown below.

### Reproduction

Run this command to convert a checkpoint into diffusers format:

```
python3 /path/to/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py   --pipeline_class_name StableDiffusionXLPipeline  --checkpoint_path  /path/to/file.ckpt --original_config_file /path/to/config.yaml --dump_path /path/to/output
```

It fails like this:

```
Traceback (most recent call last):
  File "/path/to/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py", line 160, in <module>
    pipe = download_from_original_stable_diffusion_ckpt(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/diffusers/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1329, in download_from_original_stable_diffusion_ckpt
    and "cond_stage_config" in original_config["model"]["params"]
                               ~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: string indices must be integers, not 'str'
```

### Logs

_No response_

### System Info

python 3.11, diffusers main branch.

### Who can help?

cc @sayakpaul FYI
Bug in `convert_original_stable_diffusion_to_diffusers.py`
### Describe the bug

See the steps to reproduce below.

This is caused by [this code change](https://github.com/huggingface/diffusers/commit/cb4b3f0b784db83309b3954bd2118c5dc9f30e8f#diff-10656ff1d173475012d0818b48f05a092001418ac70745e803b97fbb493dfb6aL10).  `yaml.safe_load()` takes a stream object not a file path name, so currently it just returns the file path, causing the error shown below.

### Reproduction

Run this command to convert a checkpoint into diffusers format:

```
python3 /path/to/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py   --pipeline_class_name StableDiffusionXLPipeline  --checkpoint_path  /path/to/file.ckpt --original_config_file /path/to/config.yaml --dump_path /path/to/output
```

It fails like this:

```
Traceback (most recent call last):
  File "/path/to/diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py", line 160, in <module>
    pipe = download_from_original_stable_diffusion_ckpt(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/diffusers/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1329, in download_from_original_stable_diffusion_ckpt
    and "cond_stage_config" in original_config["model"]["params"]
                               ~~~~~~~~~~~~~~~^^^^^^^^^
TypeError: string indices must be integers, not 'str'
```

### Logs

_No response_

### System Info

python 3.11, diffusers main branch.

### Who can help?

cc @sayakpaul FYI


Discussion:
cc @sayakpaul here
cc @sayakpaul here

Resolving patch:
diff --git a/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py b/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
--- a/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
+++ b/src/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py
@@ -1320,6 +1320,9 @@ def download_from_original_stable_diffusion_ckpt(
         else:
             with open(original_config_file, "r") as f:
                 original_config_file = f.read()
+    else:
+        with open(original_config_file, "r") as f:
+            original_config_file = f.read()
 
     original_config = yaml.safe_load(original_config_file)
 


Test patch: