Skip to content

Commit

Permalink
4.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
abdelaziz-mahdy committed Apr 2, 2024
1 parent a6f52d8 commit e6a343b
Show file tree
Hide file tree
Showing 9 changed files with 235 additions and 256 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

## 4.2.5
* added ability to load model from path and assets, instead of only assets
* updated pigeon from 11.0.0 to 17.0.0

## 4.2.4
* fixed ios possible memory leak (by [cyrillkuettel](https://github.com/cyrillkuettel))
Expand Down
51 changes: 44 additions & 7 deletions android/src/main/java/com/abdelaziz_mahdy/pytorch_lite/Pigeon.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// Autogenerated from Pigeon (v11.0.1), do not edit directly.
// Autogenerated from Pigeon (v17.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

package com.abdelaziz_mahdy.pytorch_lite;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.CLASS;

import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -11,6 +14,8 @@
import io.flutter.plugin.common.MessageCodec;
import io.flutter.plugin.common.StandardMessageCodec;
import java.io.ByteArrayOutputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -57,6 +62,10 @@ protected static ArrayList<Object> wrapError(@NonNull Throwable exception) {
return errorList;
}

@Target(METHOD)
@Retention(CLASS)
@interface CanIgnoreReturnValue {}

/** Generated class from Pigeon that represents data sent in messages. */
public static final class PyTorchRect {
private @NonNull Double left;
Expand Down Expand Up @@ -144,41 +153,47 @@ public static final class Builder {

private @Nullable Double left;

@CanIgnoreReturnValue
public @NonNull Builder setLeft(@NonNull Double setterArg) {
this.left = setterArg;
return this;
}

private @Nullable Double top;

@CanIgnoreReturnValue
public @NonNull Builder setTop(@NonNull Double setterArg) {
this.top = setterArg;
return this;
}

private @Nullable Double right;

@CanIgnoreReturnValue
public @NonNull Builder setRight(@NonNull Double setterArg) {
this.right = setterArg;
return this;
}

private @Nullable Double bottom;

@CanIgnoreReturnValue
public @NonNull Builder setBottom(@NonNull Double setterArg) {
this.bottom = setterArg;
return this;
}

private @Nullable Double width;

@CanIgnoreReturnValue
public @NonNull Builder setWidth(@NonNull Double setterArg) {
this.width = setterArg;
return this;
}

private @Nullable Double height;

@CanIgnoreReturnValue
public @NonNull Builder setHeight(@NonNull Double setterArg) {
this.height = setterArg;
return this;
Expand Down Expand Up @@ -284,27 +299,31 @@ public static final class Builder {

private @Nullable Long classIndex;

@CanIgnoreReturnValue
public @NonNull Builder setClassIndex(@NonNull Long setterArg) {
this.classIndex = setterArg;
return this;
}

private @Nullable String className;

@CanIgnoreReturnValue
public @NonNull Builder setClassName(@Nullable String setterArg) {
this.className = setterArg;
return this;
}

private @Nullable Double score;

@CanIgnoreReturnValue
public @NonNull Builder setScore(@NonNull Double setterArg) {
this.score = setterArg;
return this;
}

private @Nullable PyTorchRect rect;

@CanIgnoreReturnValue
public @NonNull Builder setRect(@NonNull PyTorchRect setterArg) {
this.rect = setterArg;
return this;
Expand Down Expand Up @@ -344,10 +363,28 @@ ArrayList<Object> toList() {
}
}

/** Asynchronous error handling return type for non-nullable API method returns. */
public interface Result<T> {
@SuppressWarnings("UnknownNullness")
void success(T result);
/** Success case callback method for handling returns. */
void success(@NonNull T result);

/** Failure case callback method for handling errors. */
void error(@NonNull Throwable error);
}
/** Asynchronous error handling return type for nullable API method returns. */
public interface NullableResult<T> {
/** Success case callback method for handling returns. */
void success(@Nullable T result);

/** Failure case callback method for handling errors. */
void error(@NonNull Throwable error);
}
/** Asynchronous error handling return type for void API method returns. */
public interface VoidResult {
/** Success case callback method for handling returns. */
void success();

/** Failure case callback method for handling errors. */
void error(@NonNull Throwable error);
}

Expand Down Expand Up @@ -387,7 +424,7 @@ public interface ModelApi {

void loadModel(@NonNull String modelPath, @Nullable Long numberOfClasses, @Nullable Long imageWidth, @Nullable Long imageHeight, @Nullable Long objectDetectionModelType, @NonNull Result<Long> result);
/**predicts abstract number input */
void getPredictionCustom(@NonNull Long index, @NonNull List<Double> input, @NonNull List<Long> shape, @NonNull String dtype, @NonNull Result<List<Object>> result);
void getPredictionCustom(@NonNull Long index, @NonNull List<Double> input, @NonNull List<Long> shape, @NonNull String dtype, @NonNull NullableResult<List<Object>> result);
/**predicts raw image but returns the raw net output */
void getRawImagePredictionList(@NonNull Long index, @NonNull byte[] imageData, @NonNull Result<List<Double>> result);
/**predicts raw image but returns the raw net output */
Expand All @@ -402,7 +439,7 @@ public interface ModelApi {
return ModelApiCodec.INSTANCE;
}
/**Sets up an instance of `ModelApi` to handle messages through the `binaryMessenger`. */
static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ModelApi api) {
static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable ModelApi api) {
{
BinaryMessenger.TaskQueue taskQueue = binaryMessenger.makeBackgroundTaskQueue();
BasicMessageChannel<Object> channel =
Expand Down Expand Up @@ -451,8 +488,8 @@ public void error(Throwable error) {
List<Double> inputArg = (List<Double>) args.get(1);
List<Long> shapeArg = (List<Long>) args.get(2);
String dtypeArg = (String) args.get(3);
Result<List<Object>> resultCallback =
new Result<List<Object>>() {
NullableResult<List<Object>> resultCallback =
new NullableResult<List<Object>>() {
public void success(List<Object> result) {
wrapped.add(0, result);
reply.reply(wrapped);
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
8 changes: 4 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down Expand Up @@ -491,7 +491,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -620,7 +620,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -669,7 +669,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
46 changes: 23 additions & 23 deletions ios/Classes/pigeon.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v11.0.1), do not edit directly.
// Autogenerated from Pigeon (v17.3.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

#import <Foundation/Foundation.h>
Expand All @@ -16,30 +16,30 @@ NS_ASSUME_NONNULL_BEGIN
@interface PyTorchRect : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithLeft:(NSNumber *)left
top:(NSNumber *)top
right:(NSNumber *)right
bottom:(NSNumber *)bottom
width:(NSNumber *)width
height:(NSNumber *)height;
@property(nonatomic, strong) NSNumber * left;
@property(nonatomic, strong) NSNumber * top;
@property(nonatomic, strong) NSNumber * right;
@property(nonatomic, strong) NSNumber * bottom;
@property(nonatomic, strong) NSNumber * width;
@property(nonatomic, strong) NSNumber * height;
+ (instancetype)makeWithLeft:(double )left
top:(double )top
right:(double )right
bottom:(double )bottom
width:(double )width
height:(double )height;
@property(nonatomic, assign) double left;
@property(nonatomic, assign) double top;
@property(nonatomic, assign) double right;
@property(nonatomic, assign) double bottom;
@property(nonatomic, assign) double width;
@property(nonatomic, assign) double height;
@end

@interface ResultObjectDetection : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithClassIndex:(NSNumber *)classIndex
+ (instancetype)makeWithClassIndex:(NSInteger )classIndex
className:(nullable NSString *)className
score:(NSNumber *)score
score:(double )score
rect:(PyTorchRect *)rect;
@property(nonatomic, strong) NSNumber * classIndex;
@property(nonatomic, assign) NSInteger classIndex;
@property(nonatomic, copy, nullable) NSString * className;
@property(nonatomic, strong) NSNumber * score;
@property(nonatomic, assign) double score;
@property(nonatomic, strong) PyTorchRect * rect;
@end

Expand All @@ -49,17 +49,17 @@ NSObject<FlutterMessageCodec> *ModelApiGetCodec(void);
@protocol ModelApi
- (void)loadModelModelPath:(NSString *)modelPath numberOfClasses:(nullable NSNumber *)numberOfClasses imageWidth:(nullable NSNumber *)imageWidth imageHeight:(nullable NSNumber *)imageHeight objectDetectionModelType:(nullable NSNumber *)objectDetectionModelType completion:(void (^)(NSNumber *_Nullable, FlutterError *_Nullable))completion;
///predicts abstract number input
- (void)getPredictionCustomIndex:(NSNumber *)index input:(NSArray<NSNumber *> *)input shape:(NSArray<NSNumber *> *)shape dtype:(NSString *)dtype completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion;
- (void)getPredictionCustomIndex:(NSInteger)index input:(NSArray<double> *)input shape:(NSArray<NSInteger> *)shape dtype:(NSString *)dtype completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion;
///predicts raw image but returns the raw net output
- (void)getRawImagePredictionListIndex:(NSNumber *)index imageData:(FlutterStandardTypedData *)imageData completion:(void (^)(NSArray<NSNumber *> *_Nullable, FlutterError *_Nullable))completion;
- (void)getRawImagePredictionListIndex:(NSInteger)index imageData:(FlutterStandardTypedData *)imageData completion:(void (^)(NSArray<double> *_Nullable, FlutterError *_Nullable))completion;
///predicts raw image but returns the raw net output
- (void)getRawImagePredictionListObjectDetectionIndex:(NSNumber *)index imageData:(FlutterStandardTypedData *)imageData minimumScore:(NSNumber *)minimumScore IOUThreshold:(NSNumber *)IOUThreshold boxesLimit:(NSNumber *)boxesLimit completion:(void (^)(NSArray<ResultObjectDetection *> *_Nullable, FlutterError *_Nullable))completion;
- (void)getRawImagePredictionListObjectDetectionIndex:(NSInteger)index imageData:(FlutterStandardTypedData *)imageData minimumScore:(double)minimumScore IOUThreshold:(double)IOUThreshold boxesLimit:(NSInteger)boxesLimit completion:(void (^)(NSArray<ResultObjectDetection *> *_Nullable, FlutterError *_Nullable))completion;
///predicts image but returns the raw net output
- (void)getImagePredictionListIndex:(NSNumber *)index imageData:(nullable FlutterStandardTypedData *)imageData imageBytesList:(nullable NSArray<FlutterStandardTypedData *> *)imageBytesList imageWidthForBytesList:(nullable NSNumber *)imageWidthForBytesList imageHeightForBytesList:(nullable NSNumber *)imageHeightForBytesList mean:(NSArray<NSNumber *> *)mean std:(NSArray<NSNumber *> *)std completion:(void (^)(NSArray<NSNumber *> *_Nullable, FlutterError *_Nullable))completion;
- (void)getImagePredictionListIndex:(NSInteger)index imageData:(nullable FlutterStandardTypedData *)imageData imageBytesList:(nullable NSArray<FlutterStandardTypedData *> *)imageBytesList imageWidthForBytesList:(nullable NSNumber *)imageWidthForBytesList imageHeightForBytesList:(nullable NSNumber *)imageHeightForBytesList mean:(NSArray<double> *)mean std:(NSArray<double> *)std completion:(void (^)(NSArray<double> *_Nullable, FlutterError *_Nullable))completion;
///predicts image but returns the output detections
- (void)getImagePredictionListObjectDetectionIndex:(NSNumber *)index imageData:(nullable FlutterStandardTypedData *)imageData imageBytesList:(nullable NSArray<FlutterStandardTypedData *> *)imageBytesList imageWidthForBytesList:(nullable NSNumber *)imageWidthForBytesList imageHeightForBytesList:(nullable NSNumber *)imageHeightForBytesList minimumScore:(NSNumber *)minimumScore IOUThreshold:(NSNumber *)IOUThreshold boxesLimit:(NSNumber *)boxesLimit completion:(void (^)(NSArray<ResultObjectDetection *> *_Nullable, FlutterError *_Nullable))completion;
- (void)getImagePredictionListObjectDetectionIndex:(NSInteger)index imageData:(nullable FlutterStandardTypedData *)imageData imageBytesList:(nullable NSArray<FlutterStandardTypedData *> *)imageBytesList imageWidthForBytesList:(nullable NSNumber *)imageWidthForBytesList imageHeightForBytesList:(nullable NSNumber *)imageHeightForBytesList minimumScore:(double)minimumScore IOUThreshold:(double)IOUThreshold boxesLimit:(NSInteger)boxesLimit completion:(void (^)(NSArray<ResultObjectDetection *> *_Nullable, FlutterError *_Nullable))completion;
@end

extern void ModelApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<ModelApi> *_Nullable api);
extern void SetUpModelApi(id<FlutterBinaryMessenger> binaryMessenger, NSObject<ModelApi> *_Nullable api);

NS_ASSUME_NONNULL_END
Loading

0 comments on commit e6a343b

Please sign in to comment.