-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
55 lines (41 loc) · 1.13 KB
/
App.js
File metadata and controls
55 lines (41 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React, {useState} from 'react';
import {StyleSheet, Text, View, StatusBar} from 'react-native';
import {Camera} from 'react-native-pytorch-core';
import classifyImage from './ImageClassifier';
const App = () => {
async function handleImage(image){
const result = await classifyImage(image);
setLabel(result);
// release the image from memory
image.release();
}
const [label, setLabel] = useState("");
return (
<View style={StyleSheet.absoluteFill}>
<StatusBar translucent backgroundColor="transparent" />
<Camera style={[StyleSheet.absoluteFill]}
onCapture={handleImage}/>
<View style={styles.labelContainer}>
<Text style={{color:"#444", fontSize:20}}>Predicted Image:</Text>
<Text style={{color:"#444", fontSize:17}}>{label}</Text>
</View>
</View>
);
};
const styles = StyleSheet.create({
labelContainer: {
padding: 20,
margin: 20,
marginTop: 40,
borderRadius: 10,
backgroundColor: 'white',
},
});
export default App;