Open joe-rabbit opened 2 years ago
`import { StatusBar } from 'expo-status-bar'; import { StyleSheet, Text, View,Button,TouchableOpacity,Image,SafeAreaView} from 'react-native'; import {Camera,CameraType} from 'expo-camera'; import as MediaLibrary from 'expo-media-library'; import tw from 'twrnc' import as mobilenet from '@tensorflow-models/mobilenet' import {useEffect,useRef,useState} from 'react';
export default function ImageCamera() { const[model,setModel]=useState(null); const[ismodelLoading,setModelLoading]=useState(false); const [type, setType] = useState(CameraType.back); let CameraRef = useRef(MediaLibrary); const [permission, requestPermission] = Camera.useCameraPermissions(); const [photo,setPhoto]=useState();
const loadModel = async ()=>{ setModelLoading(true); try{ const model = await mobilenet.load(); setModel(model); setModelLoading(false); } catch(e){ setModelLoading(false); console.log(e); } }
function toggleCameraType() { setType(current => (current === CameraType.back ? CameraType.front : CameraType.back)); } const [mediaLibrary,setHasMediaLibraryPermission]=useState();
useEffect(()=>{
loadModel();
(async()=>{
const {mediaLibrary} = await MediaLibrary.requestPermissionsAsync(); setHasMediaLibraryPermission({mediaLibrary}==='granted'); })(); })
let takePic = async () =>{ let options ={ quality:1, base64:true, fixOrientation:true, exif:false }; let data = await CameraRef.current.takePictureAsync(options); setPhoto(data); console.log(data.width,data.height); console.log(data.uri); let assets=null; if(photo) {
} else{ console.log('no photo'); } console.log(assets); }
return (
); }
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, buttonContainer:{ flex:1, backgroundColor:'#ffff', alignSelf:'flex-end' } }); `
hello, im trying to make an image classifier usin react native and I am getting this error after install tensoorflow mobilenet kindly help