Skip to content
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

Fix Regex for macOS/Clang support #16

Merged
merged 2 commits into from
Aug 21, 2023
Merged

Conversation

drasticactions
Copy link
Contributor

When running on macOS, I was hitting an exception with std:regex

[INFO]  stable-diffusion.cpp:2687 - loading model from '../models/sd-v1-4-ggml-model-f16.bin'
[INFO]  stable-diffusion.cpp:2712 - ftype: f16
[INFO]  stable-diffusion.cpp:2941 - total params size = 1969.97MB (clip 235.01MB, unet 1640.45MB, vae 94.51MB)
[INFO]  stable-diffusion.cpp:2943 - loading model from '../models/sd-v1-4-ggml-model-f16.bin' completed, taking 0.79s
libc++abi: terminating due to uncaught exception of type std::__1::regex_error: The parser did not consume the entire regular expression.

I found the root in parse_prompt_attention. When compiled on my Mac with Clang, it would always throw. With GCC on Linux, it didn't and would work. I think this is an encoding issue. I updated the line so it should work with everything, but knowing Regex I may have still screwed something up. Such is life.

@jamswat
Copy link

jamswat commented Aug 21, 2023

Thanks. I can confirm this has fixed the same error I was experiencing on macOS.

@leejet
Copy link
Owner

leejet commented Aug 21, 2023

Thank you for your contribution. But I found that your modifications didn't achieve the expected results. For example:

[DEBUG] stable-diffusion.cpp:766  - parse 'a (((house:1.3)) [on] a (hill:0.5), sun, (((sky))).' to [['a ', 1], ['house', 1.573], [' ', 1], ['on', 0.909091], [' a ', 1], ['hill', 0.5], ['), sun, ', 1], ['sky', 1.331], ['.', 1], ]

But the expectation is

[DEBUG] stable-diffusion.cpp:766  - parse 'a (((house:1.3)) [on] a (hill:0.5), sun, (((sky))).' to [['a ', 1], ['house', 1.573], [' ', 1.1], ['on', 1], [' a ', 1.1], ['hill', 0.55], [', sun, ', 1.1], ['sky', 1.4641], ['.', 1.1], ]

So I made some adjustments.

@leejet leejet merged commit a227226 into leejet:master Aug 21, 2023
3 checks passed
@drasticactions
Copy link
Contributor Author

So I made some adjustments.

It's Regex, so I knew I had good chance of not getting it right the first time, lol. Thanks for editing and merging it!

@drasticactions drasticactions deleted the regex-fix branch August 21, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants