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

Add is_asset argument to load models/labels from storage #48

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 31
namespace "com.vladih.computer_vision.flutter_vision"
compileSdkVersion 35

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,20 @@ private void close_ocr_model(Result result) {
}

private void load_yolo_model(Map<String, Object> args) throws Exception {
final String model = this.assets.getAssetFilePathByName(args.get("model_path").toString());
final Object is_asset_obj = args.get("is_asset");
String model = "";
final Object is_asset_obj = args.get("is_asset");
final boolean is_asset = is_asset_obj == null ? false : (boolean) is_asset_obj;
String label_path = "";
if(is_asset){
model = this.assets.getAssetFilePathByName(args.get("model_path").toString());
label_path = this.assets.getAssetFilePathByName(args.get("label_path").toString());
}else{
model = args.get("model_path").toString();
label_path = args.get("label_path").toString();
}
final int num_threads = (int) args.get("num_threads");
final boolean quantization = (boolean) args.get("quantization");
final boolean use_gpu = (boolean) args.get("use_gpu");
final String label_path = this.assets.getAssetFilePathByName(args.get("label_path").toString());
final int rotation = (int) args.get("rotation");
final String version = args.get("model_version").toString();
switch (version) {
Expand Down
1 change: 1 addition & 0 deletions lib/flutter_vision.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ abstract class FlutterVision {
required String modelVersion,
bool? quantization,
int? numThreads,
bool? is_asset,
bool? useGpu});

///yoloOnFrame accept a byte List as input and
Expand Down
3 changes: 2 additions & 1 deletion lib/src/plugin/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ class AndroidFlutterVision extends BaseFlutterVision implements FlutterVision {
required String modelVersion,
bool? quantization,
int? numThreads,
bool? is_asset,
bool? useGpu}) async {
try {
await channel.invokeMethod<String?>('loadYoloModel', {
'model_path': modelPath,
'is_asset': true,
'is_asset': is_asset ?? false,
'quantization': quantization ?? false,
'num_threads': numThreads ?? 1,
'use_gpu': useGpu ?? false,
Expand Down
1 change: 1 addition & 0 deletions lib/src/plugin/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ abstract class BaseFlutterVision {
bool? quantization,
int? numThreads,
bool? useGpu,
bool? is_asset,
});

Future<List<Map<String, dynamic>>> yoloOnFrame({
Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_vision
description: Plugin for managing Yolov5, Yolov8 and Tesseract v5 accessing with TensorFlow Lite 2.x. Support object detection, segmentation and OCR on Android. iOS, Working in progress.

version: 1.1.4
version: 1.1.6

homepage: https://github.com/vladiH/flutter_vision

Expand All @@ -12,11 +12,11 @@ environment:
dependencies:
flutter:
sdk: flutter
path: ^1.8.1
path_provider: ^2.0.11
path: ^1.9.0
path_provider: ^2.1.4

dev_dependencies:
flutter_lints: ^2.0.1
flutter_lints: ^5.0.0
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
Expand Down