Giter Club home page Giter Club logo

Comments (5)

thewtex avatar thewtex commented on May 18, 2024 1

Re: Question 1: that looks OK to me.

Re: Question 2: the executable will run synchronously and it should not return until your .cxx calls return from main.

I recently added a synchronous API for running in Node. Once it has been released, I will ping you so we can see if that fixed your problem.

from itk-wasm.

thewtex avatar thewtex commented on May 18, 2024

Hi @yh3ds ,

I think we are running into Node behavior where the process is exiting before the promises have resolved.

from itk-wasm.

yh3ds avatar yh3ds commented on May 18, 2024

Hi @thewtex ,
maybe but I m not sure. At least, it looks strange when I write logs to follow the process.
Indeed I get :

DEBUG - Script runned - Before read image
DEBUG - Script runned - Image read, before run pipeline
Inside js coming from cxx - START
Inside js coming from cxx - END
DEBUG - Script runned - Pipeline runned, before write output on disk

Which looks like expected.
Nonetheless, there is one last log missing (I put on when writing output on disk is over. I tested when I just read and write directly and it is printed correctly)

I can imagine two possibilities for the problem :


Question 1

Would it be possible that image coming from run node is corrupted or different than expected ?

Indeed if I log what I m going to write in case of working case (just read / write), I got :

DEBUG - Write output on disk - image : Image {
imageType:
ImageType {
dimension: 2,
componentType: 'uint8_t',
pixelType: 2,
components: 3 },
name: 'Image',
origin: [ 0, 0 ],
spacing: [ 1, 1 ],
direction: Matrix { rows: 2, columns: 2, data: [ 1, 0, 0, 1 ] },
size: [ 256, 256 ],
data:
Uint8Array [
0,
0,
0,
0,
...

But with the 'failing' pipeline, I got :

DEBUG - Write output on disk - outputs[0].data : { imageType:
{ dimension: 2,
componentType: 'uint8_t',
pixelType: 1,
components: 1 },
origin: [ 1.5, 1.5 ],
spacing: [ 4, 4 ],
direction: [ 1, 0, 0, 1 ],
size: [ 64, 64 ],
data: ArrayBuffer { byteLength: 4096 } }

But this second image looks strange isn t it ?
So maybe it is a problem with the cxx ?


Question 2

In the .cxx converted in js, we finish the script with writer->Update(); I guess we don't wait for this Update method to be finished and then we return.
So maybe the problem is just coming from this ?
We need (in a way or another) to force or cxx (converted in js) to wait the end of this Update before exiting ?

Thanks a lot,
Yves

from itk-wasm.

thewtex avatar thewtex commented on May 18, 2024

@yh3ds itk.js 9.2.0 has been released. Could you please try the synchronous API? i.e.

const image = readImageLocalFileSync(testInputFilePath)
const result = runPipelineNodeSync(pipelinePath, args, outputs, inputs) 
[....]

from itk-wasm.

thewtex avatar thewtex commented on May 18, 2024

@yh3ds I assume the *Sync functions solved your issue. If there are still problems, please re-open.

from itk-wasm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.