@@ -2,17 +2,7 @@ import Spinner from '../../components/Spinner';
22import { BottomBar } from '../../components/BottomBar' ;
33import { ModelPicker , ModelOption } from '../../components/ModelPicker' ;
44import { getImage } from '../../utils' ;
5- import {
6- useOCR ,
7- OCR_ENGLISH ,
8- OCR_GERMAN ,
9- OCR_FRENCH ,
10- OCR_SPANISH ,
11- OCR_ITALIAN ,
12- OCR_JAPANESE ,
13- OCR_KOREAN ,
14- OCRProps ,
15- } from 'react-native-executorch' ;
5+ import { models , useOCR , OCRProps } from 'react-native-executorch' ;
166import { View , StyleSheet , Image , Text , ScrollView } from 'react-native' ;
177import ImageWithBboxes2 from '../../components/ImageWithOCRBboxes' ;
188import React , { useContext , useEffect , useState } from 'react' ;
@@ -22,14 +12,16 @@ import { StatsBar } from '../../components/StatsBar';
2212
2313type OCRModelSources = OCRProps [ 'model' ] ;
2414
15+ const ocr = models . ocr . craft ;
16+
2517const MODELS : ModelOption < OCRModelSources > [ ] = [
26- { label : 'English' , value : OCR_ENGLISH } ,
27- { label : 'German' , value : OCR_GERMAN } ,
28- { label : 'French' , value : OCR_FRENCH } ,
29- { label : 'Spanish' , value : OCR_SPANISH } ,
30- { label : 'Italian' , value : OCR_ITALIAN } ,
31- { label : 'Japanese' , value : OCR_JAPANESE } ,
32- { label : 'Korean' , value : OCR_KOREAN } ,
18+ { label : 'English' , value : ocr ( { language : 'en' } ) } ,
19+ { label : 'German' , value : ocr ( { language : 'de' } ) } ,
20+ { label : 'French' , value : ocr ( { language : 'fr' } ) } ,
21+ { label : 'Spanish' , value : ocr ( { language : 'es' } ) } ,
22+ { label : 'Italian' , value : ocr ( { language : 'it' } ) } ,
23+ { label : 'Japanese' , value : ocr ( { language : 'ja' } ) } ,
24+ { label : 'Korean' , value : ocr ( { language : 'ko' } ) } ,
3325] ;
3426import ErrorBanner from '../../components/ErrorBanner' ;
3527
@@ -41,8 +33,9 @@ export default function OCRScreen() {
4133 width : number ;
4234 height : number ;
4335 } > ( ) ;
44- const [ selectedModel , setSelectedModel ] =
45- useState < OCRModelSources > ( OCR_ENGLISH ) ;
36+ const [ selectedModel , setSelectedModel ] = useState < OCRModelSources > (
37+ ocr ( { language : 'en' } )
38+ ) ;
4639 const [ inferenceTime , setInferenceTime ] = useState < number | null > ( null ) ;
4740
4841 const model = useOCR ( {
0 commit comments