Comments (9)
@raedle thanks for the info. for the expo reproduction, here are the steps:
- Initialize a project using
expo init <project_name>
- Install react-native-pytorch-core
expo install react-native-pytorch-core
- Use any module from pytorch core in App.js. e.g, the ` module
- Running this app on emulator or even the physical device throws this error, but without pytorch-core components the app runs fine
Ohh and btw, I was able to get it working with react-native manual installation, so expo support is not a blocker for me right now. I'm able to experiment without it. I'd be happy to write the steps for setting it up on m1 mac if needed along with the common troubles users might face
from playtorch.
Thanks, @AyushExel! I could confirm the "Invariant Violation" error on my end with the blank
Expo template.
FWIW, ejecting the Expo app (expo eject
) and running the React Native app with yarn android
works.
@byCedric, do you have an idea? :)
from playtorch.
@raedle thanks!
I was probably doing yarn add
. Your suggestion fixed the problem!
from playtorch.
Hi @AyushExel,
Thanks for leaving the encouraging comment! It is one of our goals to make PyTorch Live the best-in-class ML tool for rapid prototyping, which is why it is important to get feedback from the community (like your feedback) to help us achieve this goal!
There are some issues with M1 chipsets with Android, React Native, Python, and PyTorch. We have solved a few already and will be solving issues as they are reported.
-
Thanks for the callout on Expo. Expo is on our radar, so it's great to hear that there is interest there. Please let us know how to reproduce the issue that you are facing, so we can have a closer look at it or submit a PR if you find fix ;)
-
PyTorch Live uses PyTorch Mobile to run on-device inference. Unfortunately, PyTorch (Mobile) doesn't have a JavaScript runtime (or WASM runtime) to load TorchScript models in the browser and run inference on them. There are a few paths to make this probably work (e.g., expose libTorch via WASM or run via local Flask/Python server), but that's currently out of the scope for PyTorch Live project.
I'll keep this issue open until we either fixed the Expo issue or identified it as a #wontfix!
Thanks again, and don't hesitate to reach out!
from playtorch.
Hi @AyushExel - I wanted to circle back. There have been many updates and major API changes in our 0.2.0 series. One specific change with the just-released 0.2.1 version is a working Expo config plugin to help with configuring a new Expo project. See my comment here, I hope it helps: #73 (comment)
from playtorch.
@chrisklaiber hey thanks for the update. I kinda stopped playing with pytorch after this attempt. But the new release looks promising! I'll start exploring it again! btw I see you guys have added support for YOLOv5. I'm one of the maintainers of the repo, feel free to tag me if there are any issues related to yolov5. Thanks!
from playtorch.
Thanks for the followup, and thanks for your work on YOLOv5! I'll close this issue out for now, since it appears there is nothing specific left to address. Also, happily, there is now a YOLOv5 tutorial available: https://playtorch.dev/docs/tutorials/snacks/yolov5/
from playtorch.
@chrisklaiber hey! I decided to give it another shot with expo. I upgraded to the latest version of react-native-pytorch-core
. Here is my package.json
"dependencies": {
"expo": "~47.0.6",
"expo-status-bar": "~1.4.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-native": "0.70.5",
"react-native-web": "~0.18.9",
"react-native-pytorch-core": "0.2.2",
"react-native-safe-area-context": "3.3.2"
},
And App.ts
import { View } from 'react-native';
import {Camera} from 'react-native-pytorch-core';
export default function App() {
return (
<View>
<Camera />
</View>
);
On doing yarn android via expo, I get this error:
ERROR Error: PlayTorchJSIModule not found. Maybe try rebuilding the app.
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 11): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient, RCTEventEmitter.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.
from playtorch.
Hey @AyushExel, there are a few notable changes since the launch from last year. There are three options now. I listed them below in the order of increased involvement (or my subjective rating of difficulty).
1. Use PlayTorch app
no CLI commands required
Use the PlayTorch app available in Play Store and App Store and build ML demos on the Expo Snack platform (this is what the YOLOv5 tutorial describes step by step: https://playtorch.dev/docs/next/tutorials/snacks/yolov5/).
2. Create Standalone App with Expo
requires CLI commands
- Create Expo app with
npx create-expo-app my-app
- Navigate to app directory
cd my-app
- Install PlayTorch SDK with
npx expo install react-native-pytorch-core
(it needs to usenpx expo install
because it makes sure to run the PlayTorch config plugin in the next step; i.e.,yarn add react-native-pytorch-core
ornpm install react-native-pytorch-core
will result in an error similar to what you reported) - Change
App.js
(see code below)
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import { Camera } from 'react-native-pytorch-core';
export default function App() {
return (
<View style={styles.container}>
<Camera style={StyleSheet.absoluteFill} />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Note: style={StyleSheet.absoluteFill}
makes sure the camera is full width/height (otherwise it might end up 0,0
width/height.
- If
.watchmanconfig
is missing in the app directory, runecho "{}" > .watchmanconfig
(otherwise the next command will err withError: watchman::CommandValidationError:
) - For iOS, we just realized that it is now necessary to add
NSCameraUsageDescription
to theInfo.plist
. Add the following to theios/myapp/Info.plist
:
<key>NSCameraUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use the camera as input for machine learning models.</string>
- Run app on Android with
npx expo run:android
or on iOS withnpx expo run:ios
(note: use the commands provided here to build the native app from scratch, otherwise Expo will use the Expo Go app, which does not ship with the PlayTorch SDK native code)
3. Add PlayTorch SDK to Existing RN App
Instructions for this are on the website in the Add Package to Existing App tutorial
from playtorch.
Related Issues (20)
- PlayTorchJSIModule not found - ios & android m2 macbook pro HOT 2
- It is not possible to convert audio float32 tensor to playable uint8 audio expected by .audioFromBytes() HOT 1
- How to specify interpolation in transforms.resize?
- AudioUtil is not working on Android
- How to convert my yolov5s.pt to yolov5s.ptl HOT 1
- resize function gives error: 'Factory function resize expects 1 argument but 4 are given.'
- Cannot scan QR code from the PlayTorch app HOT 2
- playtorchjsimodule not found
- Mac M1 tutorial failure HOT 2
- unable to load local .ptl model HOT 2
- How to export a Huggingface transfromer model? HOT 3
- react_native_pytorch_core error during gradle build HOT 15
- image data fetch
- Is there a processing step im missing when using a custom trained yolo model?
- Is this project still maintained?
- Unable to work
- CMake Error
- Android build fails | Expo app using prebuild HOT 4
- 'react_native_pytorch_core-Swift.h' file not found during ios build HOT 1
- Add how to use EAS (Expo Application Service) build within this tutorial
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from playtorch.