Skip to content

Commit

Permalink
refactor(modelService): rename it to ONNXService
Browse files Browse the repository at this point in the history
Signed-off-by: Bill ZHANG <[email protected]>
  • Loading branch information
Lutra-Fs committed Sep 8, 2023
1 parent 887841c commit 22b09d6
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/services/modelService.ts → src/services/ONNXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as ort from 'onnxruntime-web';
import { type Vector2 } from 'three';
import type Model from './model';

export default class ModelService implements Model {
export default class ONNXService implements Model {
session: ort.InferenceSession | null;
gridSize: [number, number];
batchSize: number;
Expand All @@ -20,12 +20,11 @@ export default class ModelService implements Model {
// 1, 2: partial velocity
// 3, 4: Force (currently not used)

private isPaused: boolean;
private curFrameCountbyLastSecond: number;
// hold constructor private to prevent direct instantiation
// ort.InferenceSession.create() is async,
// so we need to use a static async method to create an instance
private isPaused: boolean;
private curFrameCountbyLastSecond: number;

private constructor() {
this.session = null;
this.matrixArray = new Float32Array();
Expand All @@ -51,9 +50,9 @@ export default class ModelService implements Model {
channelSize = 5,
outputChannelSize = 3,
fpsLimit = 15,
): Promise<ModelService> {
): Promise<ONNXService> {
console.log('createModelService called');
const modelServices = new ModelService();
const modelServices = new ONNXService();
await modelServices.init(
modelPath,
gridSize,
Expand All @@ -66,7 +65,7 @@ export default class ModelService implements Model {
return modelServices;
}

async initMatrixFromPath(path: string | URL): Promise<void> {
async initMatrxFromPath(path: string | URL): Promise<void> {
// check if the path is a relative path
if (typeof path === 'string' && !path.startsWith('http')) {
path = new URL(path, import.meta.url);
Expand Down

0 comments on commit 22b09d6

Please sign in to comment.