-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Stable Diffusion Model never loads. #2
Comments
Hi @esinanturan, thanks for opening the issue! There was a bug regarding how the path was parsed in Swift. I believe it's related to this issue: #3 which should be fixed now in Could you update the package and give it another try? |
@andrei-zgirvaci I have tried on my device (iPhone 13 Pro Max) again but still no success. Its stuck at loading the model. |
@esinanturan in the simulator it looks like the model actually loaded, you can see the console output saying Regarding the CoreML warning: Give it a few more minutes and you should see Try to run the app from Xcode on your iPhone 13 Pro Max and see if you get the console: I will also add a new print in the console before generating the image, to show that image is about to be generated! Also, make sure that the const SAVE_PATH = FileSystem.documentDirectory + 'image.jpeg'; See more info in this issue: #3 |
@andrei-zgirvaci On simulator I am getting the generating response and it stucks there. I have changed the save path to "FileSystem.documentDirectory + 'image.jpeg';" also but still no success |
@andrei-zgirvaci I have finally succeed generating image on my device ( but no success on simulator ). And it took quite short time to generate the image like 10-15 seconds. But loading the model is a nightmare : ) Edit: Well actually after first load now it takes around 5 seconds to load the model. But first load was quite hard we need to improve that or it was a one time thing I am not sure. I will try to re-install it. I have tried re-installing and it takes 10 minutes in the first modal load. This is quite a lot for such action to be efficient. I hope we can improve that. Thank you for your effort @andrei-zgirvaci |
@esinanturan Nice, I am glad you managed to make it work on your physical device. The load time is to be expected tho, however, there are some things we can do to optimize the model loading time! I also have documented more about this in my blog post: If you have the latest iOS 17 installed, you have some options! First, I would try to convert a base 16-bit SD model to an 6-bit palettized model model instead which should improve the loading and image generation time! You can convert a model to 6-bit instead of 16-bit by specifying the python -m python_coreml_stable_diffusion.torch2coreml \
--model-version stabilityai/stable-diffusion-2-1-base \
--convert-unet \
--convert-text-encoder \
--convert-vae-decoder \
--convert-safety-checker \
--quantize-nbits 6 \
--chunk-unet \
--attention-implementation SPLIT_EINSUM_V2 \
--compute-unit ALL \
--bundle-resources-for-swift-cli \
-o models/stable-diffusion-2-1/split_einsum_v2/compiled Another option is to try and experiment with running the model on the Currently, there is no way to change this option from To do so, you have to change this line:
to: config.computeUnits = .cpuAndGPU Let me know on your findings. If Hope this helps! |
I will mark this issue as completed for now as the described problem was fixed. In case you encounter other issues regarding this, let me know! |
Hi and thank you for this great idea of making SD available in react-native with iOS.
I have tried to run the example you have given in the repository in my iPhone 13 Pro Max but I do not get any response from 'loadModel' method it awaits there forever no errors,warnings or whatsoever. its stuck at loading model log
What am I missing ? @andrei-zgirvaci
The text was updated successfully, but these errors were encountered: