Repository: huggingface/diffusers

Issue:
[Tracker] change to posix for better Windows support
In https://github.com/huggingface/diffusers/pull/6564, @fabiorigano introduced the use of Posix to better support Windows compatibility. 

It'd be nice to change the instances of `os.path.join()` to `Path(...).as_posix()`. 

Feel free to open PRs for this and tag me. 

While opening PRs, please target only ONE script at a time. 

Let's go 🚀 



Discussion:
Hi @sayakpaul, I checked the mentioned PR and also understood the issue. This is a documentation change right? We need to change every instance of `os.path.join()` to `Path(...).as_posix()`?
> Hi @sayakpaul, I checked the mentioned PR and also understood the issue. This is a documentation change right? We need to change every instance of `os.path.join()` to `Path(...).as_posix()`?

Hey @Bhavay-2001 this is not a documentation change. Try going through this issue #6561 you'll understand why we are doing this.  
Hi @charchit7, yes I understood that this is to provide windows support for the adapter.py. I previously thought that it was a documentation change issue, however I have changed the file and opened the corresponding PR.
Thanks 
Hi, @sayakpaul! Does this issue request to change all os.path.join() instances in the whole Diffusers repo? Can I just take any script containing os.path.join() and change it?
I think so. 
@sayakpaul there are quite a few such instances in training examples. I will tackle a few. ok?
I think those are fine to leave as is because most of the training doesn't take place on Windows. 
@sayakpaul I searched across the entire diffusers repo and 111 files contain instance(s) of `os.path.join` however as you previously mentioned a lot of that is related to training. I then did a targeted search within `diffusers/src/diffusers` and this revealed a much smaller [subset](https://github.com/search?q=repo%3Ahuggingface%2Fdiffusers+os.path.join+path%3A%2F%5Esrc%5C%2Fdiffusers%5C%2F%2F&type=code) that contains 11 files and ~55 instances of `os.path.join`. One of these 11 files was addressed by Bhavay in this [PR](https://github.com/huggingface/diffusers/pull/6672). Would it be worth me going after the other 10 files, most of which are within `diffusers/src/diffusers/utils` and `diffusers/src/diffusers/pipelines`?
Yeah that works for me.
Hi @sayakpaul, could you please review my PR.
Thanks
Where is it?
Please find the [PR](https://github.com/huggingface/diffusers/pull/6672) here
Also, @Stepheni12 if you don't mind can we distribute the following tasks? 
Yes, @Bhavay-2001 that sounds good! There were 11 files in total and your PR already did one of them so we can just split the other 10 from this [subset](https://github.com/search?q=repo%3Ahuggingface%2Fdiffusers+os.path.join+path%3A%2F%5Esrc%5C%2Fdiffusers%5C%2F%2F&type=code). You can take the top 5 files which are:
>src/diffusers/utils/hub_utils.py
>src/diffusers/utils/constants.py
>src/diffusers/models/modeling_flax_utils.py
>src/diffusers/configuration_utils.py
>src/diffusers/utils/dynamic_modules_utils.py

and then I'll take the bottom half of the list which are:

>src/diffusers/pipelines/onnx_utils.py
>src/diffusers/pipelines/pipeline_flax_utils.py
>src/diffusers/models/modeling_utils.py
>src/diffusers/utils/testing_utils.py
>src/diffusers/pipelines/pipeline_utils.py

Resolving patch:
diff --git a/src/diffusers/pipelines/onnx_utils.py b/src/diffusers/pipelines/onnx_utils.py
--- a/src/diffusers/pipelines/onnx_utils.py
+++ b/src/diffusers/pipelines/onnx_utils.py
@@ -172,7 +172,7 @@ def _from_pretrained(
         # load model from local directory
         if os.path.isdir(model_id):
             model = OnnxRuntimeModel.load_model(
-                os.path.join(model_id, model_file_name), provider=provider, sess_options=sess_options
+                Path(model_id, model_file_name).as_posix(), provider=provider, sess_options=sess_options
             )
             kwargs["model_save_dir"] = Path(model_id)
         # load model from hub


Test patch: