From 28821d6a0a4fbd52776c4c21ae0858e5c91acb6b Mon Sep 17 00:00:00 2001 From: Yannick Assogba Date: Thu, 15 Aug 2019 11:44:46 -0700 Subject: [PATCH 1/3] Add rn app --- .../integration_rn59/.buckconfig | 6 + .../integration_rn59/.gitattributes | 1 + tfjs-react-native/integration_rn59/.gitignore | 63 + tfjs-react-native/integration_rn59/App.tsx | 163 + tfjs-react-native/integration_rn59/README.md | 3 + .../integration_rn59/android/app/BUCK | 55 + .../integration_rn59/android/app/build.gradle | 171 + .../android/app/build_defs.bzl | 32 + .../android/app/proguard-rules.pro | 17 + .../android/app/src/debug/AndroidManifest.xml | 8 + .../android/app/src/main/AndroidManifest.xml | 53 + .../com/integration_rn59/MainActivity.java | 31 + .../com/integration_rn59/MainApplication.java | 67 + .../generated/BasePackageList.java | 16 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3056 bytes .../res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 5024 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2096 bytes .../res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2858 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4569 bytes .../res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 7098 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 6464 bytes .../res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10676 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 9250 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 15523 bytes .../app/src/main/res/values/strings.xml | 20 + .../app/src/main/res/values/styles.xml | 25 + .../integration_rn59/android/build.gradle | 50 + .../android/gradle.properties | 18 + .../android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 55616 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 + .../integration_rn59/android/gradlew | 188 + .../integration_rn59/android/gradlew.bat | 100 + .../integration_rn59/android/keystores/BUCK | 8 + .../keystores/debug.keystore.properties | 4 + .../integration_rn59/android/settings.gradle | 25 + tfjs-react-native/integration_rn59/app.json | 4 + .../assets/images/catsmall.jpg | Bin 0 -> 4704 bytes .../assets/model/bundle_model_test.json | 1 + .../model/bundle_model_test_weights.bin | Bin 0 -> 44 bytes .../integration_rn59/babel.config.js | 3 + .../components/diagnostic.tsx | 105 + .../integration_rn59/components/ml.ts | 118 + .../components/mobilenet_demo.tsx | 213 + .../integration_rn59/components/run.tsx | 148 + tfjs-react-native/integration_rn59/index.js | 22 + .../integration_rn59/ios/Podfile | 48 + .../integration_rn59/ios/Podfile.lock | 225 + .../project.pbxproj | 1318 ++++ .../xcschemes/integration_rn59-tvOS.xcscheme | 129 + .../xcschemes/integration_rn59.xcscheme | 129 + .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/WorkspaceSettings.xcsettings | 8 + .../ios/integration_rn59/AppDelegate.h | 17 + .../ios/integration_rn59/AppDelegate.m | 56 + .../Base.lproj/LaunchScreen.xib | 42 + .../AppIcon.appiconset/Contents.json | 53 + .../Images.xcassets/Contents.json | 6 + .../ios/integration_rn59/Info.plist | 82 + .../ios/integration_rn59/main.m | 16 + .../ios/integration_rn59Tests/Info.plist | 24 + .../integration_rn59Tests.m | 68 + .../integration_rn59/jest.config.js | 21 + .../integration_rn59/metro.config.js | 40 + .../integration_rn59/package.json | 41 + .../integration_rn59/tsconfig.json | 17 + .../integration_rn59/tslint.json | 7 + tfjs-react-native/integration_rn59/yarn.lock | 6668 +++++++++++++++++ 68 files changed, 10776 insertions(+) create mode 100644 tfjs-react-native/integration_rn59/.buckconfig create mode 100644 tfjs-react-native/integration_rn59/.gitattributes create mode 100644 tfjs-react-native/integration_rn59/.gitignore create mode 100644 tfjs-react-native/integration_rn59/App.tsx create mode 100644 tfjs-react-native/integration_rn59/README.md create mode 100644 tfjs-react-native/integration_rn59/android/app/BUCK create mode 100644 tfjs-react-native/integration_rn59/android/app/build.gradle create mode 100644 tfjs-react-native/integration_rn59/android/app/build_defs.bzl create mode 100644 tfjs-react-native/integration_rn59/android/app/proguard-rules.pro create mode 100644 tfjs-react-native/integration_rn59/android/app/src/debug/AndroidManifest.xml create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/AndroidManifest.xml create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/java/com/integration_rn59/MainActivity.java create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/java/com/integration_rn59/MainApplication.java create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/java/com/integration_rn59/generated/BasePackageList.java create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/values/strings.xml create mode 100644 tfjs-react-native/integration_rn59/android/app/src/main/res/values/styles.xml create mode 100644 tfjs-react-native/integration_rn59/android/build.gradle create mode 100644 tfjs-react-native/integration_rn59/android/gradle.properties create mode 100644 tfjs-react-native/integration_rn59/android/gradle/wrapper/gradle-wrapper.jar create mode 100644 tfjs-react-native/integration_rn59/android/gradle/wrapper/gradle-wrapper.properties create mode 100755 tfjs-react-native/integration_rn59/android/gradlew create mode 100644 tfjs-react-native/integration_rn59/android/gradlew.bat create mode 100644 tfjs-react-native/integration_rn59/android/keystores/BUCK create mode 100644 tfjs-react-native/integration_rn59/android/keystores/debug.keystore.properties create mode 100644 tfjs-react-native/integration_rn59/android/settings.gradle create mode 100644 tfjs-react-native/integration_rn59/app.json create mode 100644 tfjs-react-native/integration_rn59/assets/images/catsmall.jpg create mode 100644 tfjs-react-native/integration_rn59/assets/model/bundle_model_test.json create mode 100644 tfjs-react-native/integration_rn59/assets/model/bundle_model_test_weights.bin create mode 100644 tfjs-react-native/integration_rn59/babel.config.js create mode 100644 tfjs-react-native/integration_rn59/components/diagnostic.tsx create mode 100644 tfjs-react-native/integration_rn59/components/ml.ts create mode 100644 tfjs-react-native/integration_rn59/components/mobilenet_demo.tsx create mode 100644 tfjs-react-native/integration_rn59/components/run.tsx create mode 100644 tfjs-react-native/integration_rn59/index.js create mode 100644 tfjs-react-native/integration_rn59/ios/Podfile create mode 100644 tfjs-react-native/integration_rn59/ios/Podfile.lock create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcodeproj/project.pbxproj create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcodeproj/xcshareddata/xcschemes/integration_rn59-tvOS.xcscheme create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcodeproj/xcshareddata/xcschemes/integration_rn59.xcscheme create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcworkspace/contents.xcworkspacedata create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/AppDelegate.h create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/AppDelegate.m create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/Base.lproj/LaunchScreen.xib create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/Images.xcassets/Contents.json create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/Info.plist create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59/main.m create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59Tests/Info.plist create mode 100644 tfjs-react-native/integration_rn59/ios/integration_rn59Tests/integration_rn59Tests.m create mode 100644 tfjs-react-native/integration_rn59/jest.config.js create mode 100644 tfjs-react-native/integration_rn59/metro.config.js create mode 100644 tfjs-react-native/integration_rn59/package.json create mode 100644 tfjs-react-native/integration_rn59/tsconfig.json create mode 100644 tfjs-react-native/integration_rn59/tslint.json create mode 100644 tfjs-react-native/integration_rn59/yarn.lock diff --git a/tfjs-react-native/integration_rn59/.buckconfig b/tfjs-react-native/integration_rn59/.buckconfig new file mode 100644 index 00000000000..934256cb29d --- /dev/null +++ b/tfjs-react-native/integration_rn59/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/tfjs-react-native/integration_rn59/.gitattributes b/tfjs-react-native/integration_rn59/.gitattributes new file mode 100644 index 00000000000..d42ff18354d --- /dev/null +++ b/tfjs-react-native/integration_rn59/.gitattributes @@ -0,0 +1 @@ +*.pbxproj -text diff --git a/tfjs-react-native/integration_rn59/.gitignore b/tfjs-react-native/integration_rn59/.gitignore new file mode 100644 index 00000000000..448aabe7da1 --- /dev/null +++ b/tfjs-react-native/integration_rn59/.gitignore @@ -0,0 +1,63 @@ +# OSX +# +.DS_Store + +# Xcode +# +build/ +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +*.xccheckout +*.moved-aside +DerivedData +*.hmap +*.ipa +*.xcuserstate +project.xcworkspace + +# Android/IntelliJ +# +build/ +.idea +.gradle +local.properties +*.iml + +# Visual Studio Code +# +.vscode/ + +# node.js +# +node_modules/ +npm-debug.log +yarn-error.log + +# BUCK +buck-out/ +\.buckd/ +*.keystore + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/ + +*/fastlane/report.xml +*/fastlane/Preview.html +*/fastlane/screenshots + +# Bundle artifact +*.jsbundle + +# CocoaPods +/ios/Pods/ \ No newline at end of file diff --git a/tfjs-react-native/integration_rn59/App.tsx b/tfjs-react-native/integration_rn59/App.tsx new file mode 100644 index 00000000000..1e948695d8c --- /dev/null +++ b/tfjs-react-native/integration_rn59/App.tsx @@ -0,0 +1,163 @@ +/** + * @license + * Copyright 2019 Google LLC. All Rights Reserved. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================================= + */ + +import React, { Fragment } from 'react'; +import { Button, SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar } from 'react-native'; + +import * as tf from '@tensorflow/tfjs'; +import '@tensorflow/tfjs-react-native'; + +import { Diagnostic } from './components/diagnostic'; +import { MobilenetDemo } from './components/mobilenet_demo'; + +export type Screen = 'main' | 'diag' | 'demo'; + +interface AppState { + isTfReady: boolean; + currentScreen: Screen; +} + +export class App extends React.Component<{}, AppState> { + constructor(props: {}) { + super(props); + this.state = { + isTfReady: false, + currentScreen: 'main' + }; + + this.showDiagnosticScreen = this.showDiagnosticScreen.bind(this); + this.showDemoScreen = this.showDemoScreen.bind(this); + this.showMainScreen = this.showMainScreen.bind(this); + } + + async componentDidMount() { + await tf.setBackend('rn-webgl'); + await tf.ready(); + this.setState({ + isTfReady: true, + }); + } + + showDiagnosticScreen() { + this.setState({ currentScreen: 'diag' }); + } + + showDemoScreen() { + this.setState({ currentScreen: 'demo' }); + } + + showMainScreen() { + this.setState({ currentScreen: 'main' }); + } + + renderMainScreen() { + return + + Diagnostic +