-
Notifications
You must be signed in to change notification settings - Fork 5.9k
pipeline.from_pretrained is broken when the pipeline is partially downloaded #3383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @haowang1013, Thanks for the issue! I see, to my eyes replacing:
with:
seems to be the right move. @Wauplin is this fine in your experience? |
Yes that's exactly how to do it!
|
Great thanks! @haowang1013 would you like to open a PR to fix it? :-) |
I'd love to take this up! |
Hey @Wauplin, curious about how you think I should add a test specific to Windows. Unable to find any entry in |
@patrickvonplaten is there some tests running on Windows in the CI? FYI @vimarshc in |
Yeah we should probably test on Windows very soon cc @sayakpaul |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Describe the bug
Hi,
There's a bug in pipeline_utils.py which causes
pipeline.from_pretrained
to fail if the pipeline was partially downloaded. Specifically the code doesn't handle missing components in thefeature_extractor
,safety_checker
,scheduler
andtokenizer
folders, at least on Windows platform.The cause of the bug is this line
This turns some folder names into a regexp pattern but on Windows the path joining is done via
{parent}\\{child}
, which gives a pattern like thisThe
\\*
pattern doesn't play nice with the regexp matching later and causes some files to be incorrectly excluded from the "consider list", after theexpected_files = [f for f in expected_files if any(p.match(f) for p in re_allow_pattern)]
call, expected_files is onlyAnd this means if some files are missing in those folders mentioned above, diffusers will not even try to download them and causes loading errors down the road.
To reproduce:
StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base")
and wait until the pipeline is loadedfeature_extractor
folder from the pipeline cache folderC:\Users\<YOU>\.cache\huggingface\hub\models--stabilityai--stable-diffusion-2-1-base\snapshots\<HASH>
StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1-base")
again and observe the errorFix:
I've tried changing the line above to below and it seems to fix the bug for me. This should be safe for non-Windows platforms as well as that's how path joining works for them in the first place.
Reproduction
See above
Logs
No response
System Info
diffusers 0.16.1
The text was updated successfully, but these errors were encountered: