diff --git a/view/src/ai.ts b/view/src/ai.ts index dd711a0..ac5f825 100644 --- a/view/src/ai.ts +++ b/view/src/ai.ts @@ -1,19 +1,18 @@ import '@tensorflow/tfjs-backend-webgl'; +import "@tensorflow/tfjs-backend-cpu" import * as tfconv from '@tensorflow/tfjs-converter'; import * as deeplab from '@tensorflow-models/deeplab'; +import { getLabels, getColormap, getURL, SemanticSegmentation, toSegmentationImage } from '@tensorflow-models/deeplab'; +const base = 'cityscapes'; // set to your preferred model, out of `pascal`, const createModel = async () => { - - console.log("Ezzzz") - const base = 'pascal'; // set to your preferred model, out of `pascal`, // `cityscapes` and `ade20k` const quantizationBytes = 2; // either 1, 2 or 4 // use the getURL utility function to get the URL to the pre-trained weights - const modelUrl = deeplab.getURL(base, quantizationBytes); + const modelUrl = getURL(base, quantizationBytes); const rawModel = await tfconv.loadGraphModel(modelUrl); - const modelName = 'pascal'; // set to your preferred model, out of `pascal`, - // `cityscapes` and `ade20k` - return new deeplab.SemanticSegmentation(rawModel); + const modelName = 'pascal'; // set to your preferred model, out of `pascal`, `cityscapes` and `ade20k` + return new SemanticSegmentation(rawModel, modelName); }; const model = createModel(); @@ -21,16 +20,15 @@ model.then(() => console.log(`Loaded the model successfully!`)); self.addEventListener('message', async (e) => { - const { pixels, width, height } = e.data; - - console.log(pixels, width, height) + const { pixels, width, height, i } = e.data; var array = new Uint8ClampedArray(pixels); var image = new ImageData(array, width, height); - console.log("model", await (await model).segment(image)) + const result = await (await model).segment(image); - console.log(e); + //@ts-ignore + self.postMessage({ i, result }) }); \ No newline at end of file diff --git a/view/src/components/Editor/CustomOrbit.ts b/view/src/components/Editor/CustomOrbit.ts index 818b8fd..43521cd 100644 --- a/view/src/components/Editor/CustomOrbit.ts +++ b/view/src/components/Editor/CustomOrbit.ts @@ -1,5 +1,5 @@ +//@ts-nocheck import { Vec2, Vec3 } from 'ogl'; - const STATE = { NONE: -1, ROTATE: 0, DOLLY: 1, PAN: 2, DOLLY_PAN: 3 }; const tempVec3 = new Vec3(); const tempVec2a = new Vec2(); diff --git a/view/src/components/Editor/OrbView.ts b/view/src/components/Editor/OrbView.ts index 41f33ff..e6bf4f0 100644 --- a/view/src/components/Editor/OrbView.ts +++ b/view/src/components/Editor/OrbView.ts @@ -113,6 +113,7 @@ export default (image: Image, canvas2D: CanvasRenderingContext2D, canvas3D: HTML } function updateOverlay() { + //@ts-ignore overlayProgram.uniforms.tMap.value.image = canvas2D.getImageData(0, 0, image.width, image.height).data; } @@ -126,6 +127,7 @@ export default (image: Image, canvas2D: CanvasRenderingContext2D, canvas3D: HTML } function setOpacity(o) { + //@ts-ignore overlayProgram.uniforms.opacity.value = o / 100; } diff --git a/view/src/components/Editor/Painter.svelte b/view/src/components/Editor/Painter.svelte index bfa566c..63acb45 100644 --- a/view/src/components/Editor/Painter.svelte +++ b/view/src/components/Editor/Painter.svelte @@ -1,8 +1,9 @@