fbelderink / flutter_pytorch_mobile Goto Github PK
View Code? Open in Web Editor NEWA flutter plugin for pytorch model inference. Supports image models as well as custom models.
Home Page: https://pub.dev/packages/pytorch_mobile
License: Other
A flutter plugin for pytorch model inference. Supports image models as well as custom models.
Home Page: https://pub.dev/packages/pytorch_mobile
License: Other
I created a custom model which detects different sneakers. On running with a particular image on a python notebook and on flutter gives two different values as outputs...
I have verified the model has been saved properly and labels are in the same order but the app returns different values...
Hello!
I am a Flutter application developer building a clinical-grade application that uses computer vision. I am curious about any progress toward official support from Pytorch Foundation.
Recently, Tensorflow has committed to expanding its support for Flutter by retaining ownership of an open-source package developed by an independent developer, similar to this package.
As a business with a Pytorch engineer, we hope to use stable, supported libraries. However, I appreciate OS Devs that lead the way!
I know you're working on it, just filing this issue as a placeholder so that anyone interested can track the resolution. π Thanks for the library.
Currently this package on Android goes from Dart to Java via message channels, then from Java to C++ glue code via JNI, then from that C++ to the actual core pytorch library (and then all the way back). It would be more efficient if the Dart code used FFI to directly drive the C++ code.
Hi, I am using pytorch v0.2.2 with iOS, after profiling the app I discovered memory leak related to the PyTorchMobilePlugin
Malloc 3.98 MiB 61 < multiple > 243.05 MiB -[PyTorchMobilePlugin handleMethodCall:result:]
Malloc 1.33 MiB 43 < multiple > 57.11 MiB -[PyTorchMobilePlugin handleMethodCall:result:]
Please help me to solve this issue.
Is the package updated to use the latest pytorch mobile ?
E/PyTorchMobile(26080): assets/yolov5s.torchscript.pt is not a proper model
E/PyTorchMobile(26080): com.facebook.jni.CppException: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at ../caffe2/serialize/inline_container.cc:132, please report a bug to PyTorch. Attempted to read a PyTorch file with version 3, but the maximum supported version for reading is 2. Your PyTorch installation may be too old. (init at ../caffe2/serialize/inline_container.cc:132)
i read the example codes but it seems only support object detection right now, so i am wondering can this package supports a GAN model ?
Kindly update the plugin to flutter 3.0 and also add the support for IOS
As far as I know, yolov5 is developed on pytorch framework (https://github.com/ultralytics/yolov5), so is the model created by yolov5 flutter_pytorch_monile readable?
add support for windows to run Demucs Music Source Separation https://github.com/facebookresearch/demucs
I'm trying to use your flutter package for a custom model but I get that my model is not initialised. Is this a regular occurrence?
Let me show you some of my code:
import 'package:pytorch_mobile/pytorch_mobile.dart';
import 'package:pytorch_mobile/model.dart';
I've put pytorch_mobile in my dependencies and added my assets:
assets:
- assets/models/[fine-tuning_0.pt](http://fine-tuning_0.pt/)
- assets/models/
I put both the actual asset and the directory because it wasn't working, so i just put both, I've tried the combinations and it doesn't work.
@override
void initState() {
loadPytorchModel().whenComplete(() => log("THIS IS DONE"));
Future<void> loadPytorchModel() async {
mobileNetModel =
await PyTorchMobile.loadModel('assets/models/[fine-tuning_0.pt](http://fine-tuning_0.pt/)');
}
Future<void> takePicture() async {
image = ....
// Ensure that model has been initialised
log("this works...");
if (mobileNetModel == null) {
await loadPytorchModel();
}
List? prediction = await mobileNetModel!
.getImagePredictionList(image, decodedImage.width, decodedImage.height);
If I put the if statement checking if the model is null, then nothing happens, if I remove it, I get "mobileNetModel" is uninitialised.
The memory leak happens very slowly, but could be worth fixing for some use cases.
Just 2 minor changes
Issue: The normalize: method in the UIImageExtension class has a potential memory leak caused by not freeing allocated memory.
Leak Source: The rawBytes pointer is allocated memory using calloc but is never released.
Solution:
Free rawBytes: After processing the image data, free the memory allocated to rawBytes using free(rawBytes) before returning "normalizedBuffer"
Issue: The memory leak occurs in the image prediction functionality (case 2 block) of the handleMethodCall:result: method in the PyTorchMobilePlugin class. The leak is caused by dynamically allocated memory that is not freed properly.
Leak Source: The leak is traced back to the UIImageExtension's normalize: method, which allocates memory for the input float array. This memory allocation is necessary for image processing but becomes a liability if not handled correctly.
Solution:
Here's the corrected section of the code:
case 2:
...
...
try {
NSArray<NSNumber*>* output = [imageModule predictImage:input withWidth:width andHeight: height];
result(output);
} catch (const std::exception& e) {
NSLog(@"PyTorchMobile: %s", e.what());
}
free(input); // // Add this line to fix memory leak
break;
... Rest of the code ...
I replaced this line in the main.dart of the example program
String pathCustomModel = "assets/models/yolov5s.pt";
After compiling and running on the IOS emulator, an error is reportedοΌ
[enforce fail at inline_container.cc:222] . file not found: archive/constants.pkl
It seems that yolov5s.pt is not loaded correctly
yolov5s.pt has been verified to be OK.
I would like to know how to solve this problem
OS: Windows 11
Package: Anaconda
pytorch_mobile: ^0.2.1
PyTorch : 1.8.1
I'm getting this error when trying to load the model:
E/PyTorchMobile( 7949): assets/MobileNetV3_2.pt is not a proper model
E/PyTorchMobile( 7949): com.facebook.jni.CppException: [enforce fail at inline_container.cc:222] . file >not found: archive/constants.pkl
All my save types:
quantized_model = torch.quantization.convert(mobilenet)
scripted_model = torch.jit.script(quantized_model)
torch.save(scripted_model.state_dict(), "model_output/MobileNetV3_1.pt")
torch.jit.save(scripted_model, "model_output/MobileNetV3_2.pt")
scripted_model.save("model_output/MobileNetV3_3.pt")
opt_model = optimize_for_mobile(scripted_model)
opt_model._save_for_lite_interpreter("model_output/MobileNetV3_4.ptl")
I tried all the files and got the same error. Is there a version issue? How can I save my model properly?
When using release build the app is crashing on startup. Tested on Flutter versions 2.5.0 2.8.1 3.3.8
WARN: Unable to load JNA library (OS: Mac OS X 13.0)
java.lang.UnsatisfiedLinkError: /Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp: dlopen(/Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp, 0x0001): tried: '/Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp' (no such file), '/Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64'))
WARN: Unable to load JNA library (OS: Mac OS X 13.0)
java.lang.UnsatisfiedLinkError: /Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp: dlopen(/Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp, 0x0001): tried: '/Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp' (no such file), '/Users/dvagala/Library/Caches/JNA/temp/jna3185256063644712833.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64'))
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
at java.base/java.lang.Runtime.load0(Runtime.java:768)
at java.base/java.lang.System.load(System.java:1837)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
at com.sun.jna.Native.<clinit>(Native.java:195)
at com.intellij.jna.JnaLoader.load(JnaLoader.java:16)
at com.intellij.jna.JnaLoader.isLoaded(JnaLoader.java:29)
at com.intellij.openapi.util.io.FileSystemUtil.getMediator(FileSystemUtil.java:54)
at com.intellij.openapi.util.io.FileSystemUtil.<clinit>(FileSystemUtil.java:46)
at com.intellij.openapi.vfs.impl.ZipHandler.setFileAttributes(ZipHandler.java:62)
at com.intellij.openapi.vfs.impl.ZipHandler$1.createAccessor(ZipHandler.java:44)
at com.intellij.openapi.vfs.impl.ZipHandler$1.createAccessor(ZipHandler.java:39)
at com.intellij.util.io.FileAccessorCache.createHandle(FileAccessorCache.java:61)
at com.intellij.util.io.FileAccessorCache.get(FileAccessorCache.java:54)
at com.intellij.openapi.vfs.impl.ZipHandler.getCachedZipFileHandle(ZipHandler.java:84)
at com.intellij.openapi.vfs.impl.ZipHandler.acquireZipHandle(ZipHandler.java:131)
at com.intellij.openapi.vfs.impl.ZipHandlerBase.createEntriesMap(ZipHandlerBase.java:44)
at com.intellij.openapi.vfs.impl.ArchiveHandler.getEntriesMap(ArchiveHandler.java:183)
at com.intellij.openapi.vfs.impl.jar.CoreJarHandler.<init>(CoreJarHandler.java:42)
at com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem.lambda$new$0(CoreJarFileSystem.java:33)
at com.intellij.util.containers.ConcurrentFactoryMap$2.create(ConcurrentFactoryMap.java:181)
at com.intellij.util.containers.ConcurrentFactoryMap.get(ConcurrentFactoryMap.java:46)
at com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem.findFileByPath(CoreJarFileSystem.java:44)
at com.intellij.core.JavaCoreProjectEnvironment.addJarToClassPath(JavaCoreProjectEnvironment.java:79)
at com.android.tools.lint.LintCoreProjectEnvironment.registerPaths(LintCoreProjectEnvironment.java:129)
at com.android.tools.lint.LintCliClient.initializeProjects(LintCliClient.java:1317)
at com.android.tools.lint.client.api.LintClient.performInitializeProjects$lint_api(LintClient.kt:868)
at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.kt:377)
at com.android.tools.lint.LintCliClient.run(LintCliClient.java:238)
at com.android.tools.lint.gradle.LintGradleClient.run(LintGradleClient.java:261)
at com.android.tools.lint.gradle.LintGradleExecution.runLint(LintGradleExecution.java:305)
at com.android.tools.lint.gradle.LintGradleExecution.lintSingleVariant(LintGradleExecution.java:392)
at com.android.tools.lint.gradle.LintGradleExecution.analyze(LintGradleExecution.java:94)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.android.tools.lint.gradle.api.ReflectiveLintRunner.runLint(ReflectiveLintRunner.kt:38)
at com.android.build.gradle.tasks.LintBaseTask.runLint(LintBaseTask.java:114)
at com.android.build.gradle.tasks.LintPerVariantTask.lint(LintPerVariantTask.java:63)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:49)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:717)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:684)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:476)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:461)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:444)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:93)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:237)
at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$1(ExecuteStep.java:33)
at java.base/java.util.Optional.orElseGet(Optional.java:369)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:33)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:208)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:70)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
at java.base/java.util.Optional.map(Optional.java:265)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:76)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:69)
at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:47)
at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:140)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:829)
Hello, I was playing around a bit and was trying to recreate the pytorch code for the custom_model in the example with:
import torch
import torch.nn as nn
import torch.utils.mobile_optimizer as mobile
from torchsummary import summary
class FullyNet(nn.Module):
def __init__(self):
super(FullyNet, self).__init__()
self.fc = nn.Linear(4, 1)
def forward(self, x):
x = x.view(-1)
return self.fc(x)
if __name__ == '__main__':
net = FullyNet()
net.eval()
quantized_model = torch.quantization.convert(net)
scripted_model = torch.jit.script(quantized_model)
opt_model = mobile.optimize_for_mobile(scripted_model)
opt_model.save('fully_net.pt')
out = net(torch.randn(1, 2, 2))
print(out)
However I get Your input type float32 (Float) does not match with model input type
I can also print the full stacktrace below...
Is there some way to fix that?
Full stack trace: https://hastebin.com/share/ibuvorukuq.css
PS: If I use the custom_model for from your examples, it works like a charm :)
Greetings!
I installed your package pytorch_mobile, tried to compile the example from the package and got the error message:
Package install error: Failure [INSTALL_FAILED_OLDER_SDK]
Error launching application on GT I9500.
What will I do?
Thank you for your work.
I'm encountering an issue with the object_detection
library in my Flutter application where, after initially detecting an object, the detection feature no longer updates. I expect the UI to refresh and display newly detected objects every time a new object is detected in the camera view.
Device: Model: Samsung A70
dependencies:
image_picker: ^0.8.5+3
path_provider: ^2.0.2
camera: ^0.9.8+1
image: ^3.0.2
flutter_pytorch: ^1.0.1
I've taken steps to ensure that my development setup aligns with the requirements of the object_detection
library and have confirmed that all related dependencies are current. Despite these precautions, the issue with the object detection not updating remains unresolved.
Your insights or assistance in addressing this problem would be highly valued. Thank you in advance for your time and support.
Android is quite notorious for deprecating things. When I try to run the example app, I get this:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. Follow the
steps at
https://flutter.dev/go/android-project-migration
to migrate your project. You may also pass the --ignore-deprecation flag to
ignore this check and continue with the deprecated v1 embedding. However,
the v1 Android embedding will be removed in future versions of Flutter.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The detected reason was:
/Users/cyrill/fynnmaarten_pull_request/flutter_pytorch_mobile/example/android/app/sr
c/main/AndroidManifest.xml uses `android:name="io.flutter.app.FlutterApplication"`
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Build failed due to use of deprecated Android v1 embedding.
Does this package support real-time inference? Because i see the parameter for the prediction function takes in a file.
I found three articles in the pytorch docs that talk about using GPU on edge devices:
Which of them are supported in this plugin?
I was just wondering what type of image models predictImage
actually supports. I'm assuming here image classification models are supported, but what about other types of models, like for example object detection?
Is the implementation different for these or does this work as well.
Thank you for this plugin by the way, very nice work.
@fynnmaarten I am trying to load a model that i compiled using PyTorch 2.0.0 and it is giving me an error.
How to update the torch version for this plugin ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.