Skip to content

Commit 951ab91

Browse files
fix: small adjustments to style transfer
1 parent 8940e9d commit 951ab91

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = {
3232
customWordListFile: path.resolve(__dirname, '.cspell-wordlist.txt'),
3333
},
3434
],
35-
'camelcase': 'error',
35+
'camelcase': ['error', { properties: 'never' }],
3636
},
3737
plugins: ['prettier', 'markdown'],
3838
overrides: [

apps/computer-vision/app/vision_camera/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
View,
1616
} from 'react-native';
1717
import { useSafeAreaInsets } from 'react-native-safe-area-context';
18+
import { useIsFocused } from '@react-navigation/native';
1819
import {
1920
Camera,
2021
Frame,
@@ -235,6 +236,7 @@ export default function VisionCameraScreen() {
235236
const [fps, setFps] = useState(0);
236237
const [frameMs, setFrameMs] = useState(0);
237238
const lastFrameTimeRef = useRef(Date.now());
239+
const isFocused = useIsFocused();
238240
const cameraPermission = useCameraPermission();
239241
const devices = useCameraDevices();
240242
const device =
@@ -461,7 +463,7 @@ export default function VisionCameraScreen() {
461463
style={StyleSheet.absoluteFill}
462464
device={device}
463465
outputs={[frameOutput]}
464-
isActive={true}
466+
isActive={isFocused}
465467
format={format}
466468
orientationSource="interface"
467469
/>

packages/react-native-executorch/src/modules/computer_vision/StyleTransferModule.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { VisionModule } from './VisionModule';
1010
*
1111
* @category Typescript API
1212
*/
13-
export class StyleTransferModule extends VisionModule<PixelData> {
13+
export class StyleTransferModule extends VisionModule<PixelData | string> {
1414
/**
1515
* Loads the model, where `modelSource` is a string that specifies the location of the model binary.
1616
* To track the download progress, supply a callback function `onDownloadProgressCallback`.
@@ -41,4 +41,13 @@ export class StyleTransferModule extends VisionModule<PixelData> {
4141
throw parseUnknownError(error);
4242
}
4343
}
44+
45+
async forward<O extends 'pixelData' | 'url' = 'pixelData'>(
46+
input: string | PixelData,
47+
output?: O
48+
): Promise<O extends 'url' ? string : PixelData> {
49+
return super.forward(input, output === 'url') as Promise<
50+
O extends 'url' ? string : PixelData
51+
>;
52+
}
4453
}

packages/react-native-executorch/src/modules/computer_vision/VisionModule.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export abstract class VisionModule<TOutput> extends BaseModule {
127127
RnExecutorchErrorCode.ModuleNotLoaded,
128128
'The model is currently not loaded. Please load the model before calling forward().'
129129
);
130-
131130
// Type detection and routing
132131
if (typeof input === 'string') {
133132
return await this.nativeModule.generateFromString(input, ...args);

0 commit comments

Comments
 (0)