Repository: huggingface/diffusers

Issue:
use_safetensors Fails on Windows When There Are Alternative bin Files
### Describe the bug

When a model contains safetensors and bin weights diffusers will only download the bin weights. An error is raised when `use_safetensors=True`:
```
OSError: Could not found the necessary `safetensors` weights in {'vae/diffusion_pytorch_model.fp16.bin', 'text_encoder/pytorch_model.fp16.bin', 'unet/diffusion_pytorch_model.fp16.safetensors', 'text_encoder/model.fp16.safetensors', 'vae/diffusion_pytorch_model.fp16.safetensors', 'unet/diffusion_pytorch_model.fp16.bin', 'safety_checker/pytorch_model.fp16.bin', 'safety_checker/model.fp16.safetensors'} (variant=fp16)
```
With a warning before it like:
```vae\diffusion_pytorch_model.fp16.safetensors not found```

This is happening due to a windows separator being inserted where a unix separator is expected.
https://github.com/huggingface/diffusers/blob/a10107f92b09ecb4bdabd53d91a0ca6e2df29409/src/diffusers/pipelines/pipeline_utils.py#L177

### Reproduction

```python
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
)
```

A model like SDXL 1.0 doesn't have this issue due to not having bin weights to compare against.
```python
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
)
```

### Logs

_No response_

### System Info

platform: Windows 11
python: 3.10.7
diffusers: 0.19.3

### Who can help?

@patrickvonplaten
use_safetensors Fails on Windows When There Are Alternative bin Files
### Describe the bug

When a model contains safetensors and bin weights diffusers will only download the bin weights. An error is raised when `use_safetensors=True`:
```
OSError: Could not found the necessary `safetensors` weights in {'vae/diffusion_pytorch_model.fp16.bin', 'text_encoder/pytorch_model.fp16.bin', 'unet/diffusion_pytorch_model.fp16.safetensors', 'text_encoder/model.fp16.safetensors', 'vae/diffusion_pytorch_model.fp16.safetensors', 'unet/diffusion_pytorch_model.fp16.bin', 'safety_checker/pytorch_model.fp16.bin', 'safety_checker/model.fp16.safetensors'} (variant=fp16)
```
With a warning before it like:
```vae\diffusion_pytorch_model.fp16.safetensors not found```

This is happening due to a windows separator being inserted where a unix separator is expected.
https://github.com/huggingface/diffusers/blob/a10107f92b09ecb4bdabd53d91a0ca6e2df29409/src/diffusers/pipelines/pipeline_utils.py#L177

### Reproduction

```python
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
)
```

A model like SDXL 1.0 doesn't have this issue due to not having bin weights to compare against.
```python
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
)
```

### Logs

_No response_

### System Info

platform: Windows 11
python: 3.10.7
diffusers: 0.19.3

### Who can help?

@patrickvonplaten


Discussion:
Thanks for reporting this! 

@DN6 could you look into it?
On it 👍🏽
Gentle ping here @DN6 
Thanks for reporting this! 

@DN6 could you look into it?
On it 👍🏽
Gentle ping here @DN6 

Resolving patch:
diff --git a/src/diffusers/pipelines/pipeline_utils.py b/src/diffusers/pipelines/pipeline_utils.py
--- a/src/diffusers/pipelines/pipeline_utils.py
+++ b/src/diffusers/pipelines/pipeline_utils.py
@@ -158,9 +158,9 @@ def is_safetensors_compatible(filenames, variant=None, passed_components=None) -
             continue
 
         if extension == ".bin":
-            pt_filenames.append(filename)
+            pt_filenames.append(os.path.normpath(filename))
         elif extension == ".safetensors":
-            sf_filenames.add(filename)
+            sf_filenames.add(os.path.normpath(filename))
 
     for filename in pt_filenames:
         #  filename = 'foo/bar/baz.bam' -> path = 'foo/bar', filename = 'baz', extention = '.bam'
@@ -172,9 +172,8 @@ def is_safetensors_compatible(filenames, variant=None, passed_components=None) -
         else:
             filename = filename
 
-        expected_sf_filename = os.path.join(path, filename)
+        expected_sf_filename = os.path.normpath(os.path.join(path, filename))
         expected_sf_filename = f"{expected_sf_filename}.safetensors"
-
         if expected_sf_filename not in sf_filenames:
             logger.warning(f"{expected_sf_filename} not found")
             return False
@@ -1769,7 +1768,7 @@ def download(cls, pretrained_model_name, **kwargs) -> Union[str, os.PathLike]:
                 )
             ):
                 raise EnvironmentError(
-                    f"Could not found the necessary `safetensors` weights in {model_filenames} (variant={variant})"
+                    f"Could not find the necessary `safetensors` weights in {model_filenames} (variant={variant})"
                 )
             if from_flax:
                 ignore_patterns = ["*.bin", "*.safetensors", "*.onnx", "*.pb"]


Test patch: