Skip to content

Commit

Permalink
should work on webgpu -- however it doesn't
Browse files Browse the repository at this point in the history
  • Loading branch information
reinhrst committed Sep 22, 2024
1 parent 3f9a80d commit d3b8613
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 337 deletions.
7 changes: 4 additions & 3 deletions src/worker/infer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { env, InferenceSession, TypedTensor, Tensor } from 'onnxruntime-web';
import { env, InferenceSession, TypedTensor, Tensor } from 'onnxruntime-web/all';
import {nonEmptyFileExists, type FileTreeLeaf} from "../lib/FileTree"
import {Video} from "./video"
import { xxh64sum } from '../lib/fileutil'
Expand Down Expand Up @@ -150,9 +150,9 @@ export async function getModel(
await modelDir.getFileHandle(modelFilename)
).getFile()).arrayBuffer()
const metadata = await readModelMetadata(buffer)
const model = await InferenceSession.create(buffer)
const model = await InferenceSession.create(buffer, {executionProviders: ['webgpu'], preferredOutputLocation: 'gpu-buffer' });
const nmsModelData = await (await fetch(NMS_MODEL_PATH)).arrayBuffer()
const nms = await InferenceSession.create(nmsModelData)
const nms = await InferenceSession.create(nmsModelData, {executionProviders: ['webgpu'] });
return {
model,
nms,
Expand Down Expand Up @@ -352,6 +352,7 @@ export async function inferSingleFrame(
const d2 = Date.now()
const { selected } = await model.nms.run({ detection: output0, config: config });
const d3 = Date.now()
output0.dispose()
console.log(`Model run took ${d2 - d}ms, NMS took ${d3-d2}ms`)
assert(selected.dims.length === 3)
assert(selected.dims[0] === 1)
Expand Down
334 changes: 0 additions & 334 deletions src/worker/tfjs.ts

This file was deleted.

0 comments on commit d3b8613

Please sign in to comment.