Skip to content

Commit 210dd1b

Browse files
author
yangyang
committed
adding test_js for UNET.
I'm testing this model by predicting an image. However, UNET got frozen when doing this because there is no nextFrame. Therefore, I added a check to see if the content to be predicted is a video. If not, skip asking for next frame.
1 parent c7e77cc commit 210dd1b

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/UNET/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ class UNET extends Video {
8282
async segmentInternal(imgToPredict) {
8383
// Wait for the model to be ready
8484
await this.ready;
85-
await tf.nextFrame();
85+
// skip asking for next frame if it's not video
86+
if (imgToPredict instanceof HTMLVideoElement){
87+
await tf.nextFrame();
88+
}
8689
this.isPredicting = true;
8790

8891
const tensor = tf.tidy(() => {

src/UNET/index_test.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)