Request ModelResourcesGraphService for all Task API web graphs.

PiperOrigin-RevId: 508681004
This commit is contained in:
MediaPipe Team 2023-02-10 09:32:32 -08:00 committed by Copybara-Service
parent 915d2c7417
commit 39a943e91e
2 changed files with 7 additions and 4 deletions

View File

@ -84,9 +84,6 @@ export abstract class TaskRunner {
// Disables the automatic render-to-screen code, which allows for pure
// CPU processing.
this.graphRunner.setAutoRenderToScreen(false);
// Enables use of our model resource caching graph service.
this.graphRunner.registerModelResourcesGraphService();
}
/** Configures the task with custom options. */
@ -149,6 +146,11 @@ export abstract class TaskRunner {
this.graphRunner.attachErrorListener((code, message) => {
this.processingErrors.push(new Error(message));
});
// Enables use of our model resource caching graph service; we apply this to
// every MediaPipe graph we run.
this.graphRunner.registerModelResourcesGraphService();
this.graphRunner.setGraph(graphData, isBinary);
this.handleErrors();
}

View File

@ -40,7 +40,6 @@ class TaskRunnerFake extends TaskRunner {
'registerModelResourcesGraphService', 'attachErrorListener'
]));
const graphRunner = this.graphRunner as jasmine.SpyObj<CachedGraphRunner>;
expect(graphRunner.registerModelResourcesGraphService).toHaveBeenCalled();
expect(graphRunner.setAutoRenderToScreen).toHaveBeenCalled();
graphRunner.attachErrorListener.and.callFake(listener => {
this.errorListener = listener;
@ -65,6 +64,8 @@ class TaskRunnerFake extends TaskRunner {
override setGraph(graphData: Uint8Array, isBinary: boolean): void {
super.setGraph(graphData, isBinary);
expect(this.graphRunner.registerModelResourcesGraphService)
.toHaveBeenCalled();
}
setOptions(options: TaskRunnerOptions): Promise<void> {