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

iOS models should be in app's document directory #16

Open
hypen-flutter opened this issue Sep 6, 2024 · 2 comments
Open

iOS models should be in app's document directory #16

hypen-flutter opened this issue Sep 6, 2024 · 2 comments

Comments

@hypen-flutter
Copy link

The readme says that the model should be under the file's root directory, but the flutter_gemma plugin code refers to the app's document directory.
I could run this plugin after manually moving the model file to the app's document.
Here's the code I use to move the model file.

final docDir = await getApplicationDocumentsDirectory();
final model = await rootBundle.load('assets/model.bin');
final modelBytes = model.buffer.asUint8List(model.offsetInBytes, model.lengthInBytes);
await File(p.join(docDir.path, 'model.bin')).writeAsBytes(modelBytes);

And also, line 17 of ios/classes/InferenceModel.swift should be

self.inference = try! LlmInference(options: llmOptions)

or

Use do / catch 

in case the model file does not exist.

@obutora
Copy link

obutora commented Sep 20, 2024

@hypen-flutter
Thank you for providing detailed information!
In my case, I tried your method on iOS simlator and it worked!

@DenisovAV
Copy link
Owner

Please check with new methods for loading model

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