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

How to modify or update the model weight in swift? #307

Open
simon5u opened this issue Dec 22, 2023 · 2 comments
Open

How to modify or update the model weight in swift? #307

simon5u opened this issue Dec 22, 2023 · 2 comments

Comments

@simon5u
Copy link

simon5u commented Dec 22, 2023

Hi, we are developing a swift app in ipad where we managed to load the stable diffusion model into the app, but we want to partially change the model weight when running the app. For example, we want to change different loras with base model SD1.5 on the fly, instead of compiling everything into coreml .mlmodel from beginning and load the model using loadedModel = try MLModel(contentsOf: modelURL, configuration: configuration). The latter is very slow every time we want to change a lora, it is not user friendly and the app is not very responsive.

Is it possible to update model weight using swift and functions given in mlmodel.h? The only related class is class var weights: MLParameterKey { get }, but there is no "set" method.

If not possible, is it we have to do it from scratch using objective c++?

Please advise. Thanks.

@yyyoungman
Copy link

yyyoungman commented Dec 26, 2023

Hi, we are developing a swift app in ipad where we managed to load the stable diffusion model into the app, but we want to partially change the model weight when running the app. For example, we want to change different loras with base model SD1.5 on the fly, instead of compiling everything into coreml .mlmodel from beginning and load the model using loadedModel = try MLModel(contentsOf: modelURL, configuration: configuration). The latter is very slow every time we want to change a lora, it is not user friendly and the app is not very responsive.

Is it possible to update model weight using swift and functions given in mlmodel.h? The only related class is class var weights: MLParameterKey { get }, but there is no "set" method.

If not possible, is it we have to do it from scratch using objective c++?

Please advise. Thanks.

@simon5u Hi, we are trying to do the same thing and haven't found a way yet. Did you mean it's possible to do this in objective c++? Could you please show how? Thanks!

@Vimy
Copy link

Vimy commented Jan 12, 2024

Did one of you find a solution?

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

No branches or pull requests

3 participants