Skip to content

Commit

Permalink
revert pigeon update
Browse files Browse the repository at this point in the history
  • Loading branch information
abdelaziz-mahdy committed Apr 2, 2024
1 parent e6a343b commit c150a84
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 231 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

## 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: 7 additions & 44 deletions android/src/main/java/com/abdelaziz_mahdy/pytorch_lite/Pigeon.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// Autogenerated from Pigeon (v17.3.0), do not edit directly.
// Autogenerated from Pigeon (v11.0.1), 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 @@ -14,8 +11,6 @@
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 @@ -62,10 +57,6 @@ 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 @@ -153,47 +144,41 @@ 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 @@ -299,31 +284,27 @@ 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 @@ -363,28 +344,10 @@ ArrayList<Object> toList() {
}
}

/** Asynchronous error handling return type for non-nullable API method returns. */
public interface Result<T> {
/** 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();
@SuppressWarnings("UnknownNullness")
void success(T result);

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

Expand Down Expand Up @@ -424,7 +387,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 NullableResult<List<Object>> result);
void getPredictionCustom(@NonNull Long index, @NonNull List<Double> input, @NonNull List<Long> shape, @NonNull String dtype, @NonNull Result<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 @@ -439,7 +402,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 @@ -488,8 +451,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);
NullableResult<List<Object>> resultCallback =
new NullableResult<List<Object>>() {
Result<List<Object>> resultCallback =
new Result<List<Object>>() {
public void success(List<Object> result) {
wrapped.add(0, result);
reply.reply(wrapped);
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
camera_avfoundation: 3125e8cd1a4387f6f31c6c63abb8a55892a9eeeb
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
integration_test: 13825b8a9334a850581300559b8839134b124670
LibTorch: 8abfa5fc9d146230b31065a29b0502e1104956ea
Expand All @@ -55,4 +55,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 7be2f5f74864d463a8ad433546ed1de7e0f29aef

COCOAPODS: 1.12.1
COCOAPODS: 1.15.2
4 changes: 3 additions & 1 deletion example/macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
FLUTTER_ROOT=/Users/AbdelazizMahdy/Developer/flutter
FLUTTER_APPLICATION_PATH=/Users/AbdelazizMahdy/flutter_projects/pytorch_lite/example
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=/Users/AbdelazizMahdy/flutter_projects/pytorch_lite/example/lib/main.dart
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9lNzZjOTU2NDk4ODQxZTFhYjQ1ODU3N2QzODkyMDAzZTU1M2U0ZjNjLw==
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json
PACKAGE_CONFIG=/Users/AbdelazizMahdy/flutter_projects/pytorch_lite/example/.dart_tool/package_config.json
18 changes: 18 additions & 0 deletions example/macos/Flutter/ephemeral/FlutterMacOS.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# This podspec is NOT to be published. It is only used as a local source!
# This is a generated file; do not edit or check into version control.
#

Pod::Spec.new do |s|
s.name = 'FlutterMacOS'
s.version = '1.0.0'
s.summary = 'A UI toolkit for beautiful and fast apps.'
s.homepage = 'https://flutter.dev'
s.license = { :type => 'BSD' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.osx.deployment_target = '10.14'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'FlutterMacOS'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
export "FLUTTER_ROOT=/Users/AbdelazizMahdy/Developer/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/AbdelazizMahdy/flutter_projects/pytorch_lite/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=/Users/AbdelazizMahdy/flutter_projects/pytorch_lite/example/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==,RkxVVFRFUl9XRUJfQ0FOVkFTS0lUX1VSTD1odHRwczovL3d3dy5nc3RhdGljLmNvbS9mbHV0dGVyLWNhbnZhc2tpdC9lNzZjOTU2NDk4ODQxZTFhYjQ1ODU3N2QzODkyMDAzZTU1M2U0ZjNjLw=="
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
export "PACKAGE_CONFIG=/Users/AbdelazizMahdy/flutter_projects/pytorch_lite/example/.dart_tool/package_config.json"
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 (v17.3.0), do not edit directly.
// Autogenerated from Pigeon (v11.0.1), 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:(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;
+ (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;
@end

@interface ResultObjectDetection : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithClassIndex:(NSInteger )classIndex
+ (instancetype)makeWithClassIndex:(NSNumber *)classIndex
className:(nullable NSString *)className
score:(double )score
score:(NSNumber *)score
rect:(PyTorchRect *)rect;
@property(nonatomic, assign) NSInteger classIndex;
@property(nonatomic, strong) NSNumber * classIndex;
@property(nonatomic, copy, nullable) NSString * className;
@property(nonatomic, assign) double score;
@property(nonatomic, strong) NSNumber * 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:(NSInteger)index input:(NSArray<double> *)input shape:(NSArray<NSInteger> *)shape dtype:(NSString *)dtype completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion;
- (void)getPredictionCustomIndex:(NSNumber *)index input:(NSArray<NSNumber *> *)input shape:(NSArray<NSNumber *> *)shape dtype:(NSString *)dtype completion:(void (^)(NSArray *_Nullable, FlutterError *_Nullable))completion;
///predicts raw image but returns the raw net output
- (void)getRawImagePredictionListIndex:(NSInteger)index imageData:(FlutterStandardTypedData *)imageData completion:(void (^)(NSArray<double> *_Nullable, FlutterError *_Nullable))completion;
- (void)getRawImagePredictionListIndex:(NSNumber *)index imageData:(FlutterStandardTypedData *)imageData completion:(void (^)(NSArray<NSNumber *> *_Nullable, FlutterError *_Nullable))completion;
///predicts raw image but returns the raw net output
- (void)getRawImagePredictionListObjectDetectionIndex:(NSInteger)index imageData:(FlutterStandardTypedData *)imageData minimumScore:(double)minimumScore IOUThreshold:(double)IOUThreshold boxesLimit:(NSInteger)boxesLimit completion:(void (^)(NSArray<ResultObjectDetection *> *_Nullable, FlutterError *_Nullable))completion;
- (void)getRawImagePredictionListObjectDetectionIndex:(NSNumber *)index imageData:(FlutterStandardTypedData *)imageData minimumScore:(NSNumber *)minimumScore IOUThreshold:(NSNumber *)IOUThreshold boxesLimit:(NSNumber *)boxesLimit completion:(void (^)(NSArray<ResultObjectDetection *> *_Nullable, FlutterError *_Nullable))completion;
///predicts image but returns the raw net output
- (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;
- (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;
///predicts image but returns the output detections
- (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;
- (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;
@end

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

NS_ASSUME_NONNULL_END
Loading

0 comments on commit c150a84

Please sign in to comment.