File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import * as tf from '@tensorflow/tfjs';
11
11
import callCallback from '../utils/callcallback' ;
12
12
import { array3DToImage } from '../utils/imageUtilities' ;
13
13
import Video from '../utils/Video' ;
14
+ import p5Utils from '../utils/p5Utils' ;
14
15
15
16
const URL = 'https://raw.githubusercontent.com/zaidalyafeai/HostedModels/master/unet-128/model.json' ;
16
17
const imageSize = 128 ;
@@ -40,10 +41,10 @@ class UNET extends Video {
40
41
}
41
42
42
43
// check if p5js
43
- static checkP5 ( ) {
44
- if ( typeof window !== 'undefined' && window . p5 && window . p5 . Image && typeof window . p5 . Image === 'function' ) return true ;
45
- return false ;
46
- }
44
+ // static checkP5() {
45
+ // if (typeof window !== 'undefined' && window.p5 && window.p5.Image && typeof window.p5.Image === 'function') return true;
46
+ // return false;
47
+ // }
47
48
48
49
async segment ( inputOrCallback , cb ) {
49
50
await this . ready ;
@@ -108,8 +109,10 @@ class UNET extends Video {
108
109
const raw = await tf . browser . toPixels ( tensor ) ;
109
110
let image ;
110
111
111
- if ( UNET . checkP5 ( ) ) {
112
- image = window . loadImage ( dom . src ) ;
112
+ if ( p5Utils . checkP5 ( ) ) {
113
+ const blob1 = await p5Utils . rawToBlob ( raw , imageSize , imageSize ) ;
114
+ const p5Image1 = await p5Utils . blobToP5Image ( blob1 ) ;
115
+ image = p5Image1 ;
113
116
}
114
117
115
118
return {
You can’t perform that action at this time.
0 commit comments