publiclab / image-sequencer

A pure JavaScript sequential image processing system, inspired by storyboards
https://sequencer.publiclab.org
GNU General Public License v3.0
110 stars 210 forks source link

Running Sequencer on gCloud #755

Open tech4GT opened 5 years ago

tech4GT commented 5 years ago

Current Service

exports.helloWorld = (req, res) => {

const img = req.query.url,
    sequence = req.query.sequence;

sequencer.loadImages(img, () => {
    sequencer.importString(sequence);
    sequencer.run(out => {
        res.status(200).send({ data: out });
    });
});

}



### Process:
<img width="267" alt="screen shot 2019-02-10 at 2 43 23 am" src="https://user-images.githubusercontent.com/25617855/52526381-bce48c00-2cdd-11e9-92d0-fba2a53c697c.png">
<img width="267" alt="screen shot 2019-02-10 at 2 43 32 am" src="https://user-images.githubusercontent.com/25617855/52526382-bfdf7c80-2cdd-11e9-872c-b02b91a34ba0.png">
<img width="500" alt="screen shot 2019-02-10 at 2 43 46 am" src="https://user-images.githubusercontent.com/25617855/52526384-c2da6d00-2cdd-11e9-90bc-01bedcdbd56e.png">

## Ideas
- Parallelize the processing of images using more cloud functions or maybe deploying on cloud engine
- Optimize the core APIs to make the processing faster and more memory efficient
- Try to run Image sequencer on a stream based input
tech4GT commented 5 years ago

cc @jywarren @icarito

jywarren commented 5 years ago

This is great; can you share the script for how you set it up, and maybe some screenshots?

On Sat, Feb 9, 2019, 4:01 PM Varun Gupta <notifications@github.com wrote:

Current Service

  • We are running a google cloud function which processes the image and returns the output

Ideas

  • Parallelize the processing of images using more cloud functions or maybe deploying on cloud engine
  • Optimize the core APIs to make the processing faster and more memory efficient
  • Try to run Image sequencer on a stream based input

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ6t7YtEDoHI76f3P5UWEBkyy7yYSks5vLzcAgaJpZM4ayvPE .

tech4GT commented 5 years ago

Sure!

jywarren commented 5 years ago

Also let's set it up to fwd to the dataurl if output=forward?

On Sat, Feb 9, 2019, 5:33 PM Varun Gupta <notifications@github.com wrote:

cc @jywarren https://github.com/jywarren @icarito https://github.com/icarito

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462079063, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ13Po57Z0WTa-D53xYglx8tM3HBaks5vLzcMgaJpZM4ayvPE .

jywarren commented 5 years ago

To try out!

https://us-central1-public-lab.cloudfunctions.net/is-function/?url=https://publiclab.org/system/images/photos/000/024/686/original/valverde.jpg&upload=true&sequence=ndvi,colormap

harshkhandeparkar commented 5 years ago

@jywarren I checked it out, It took around 2mins to load the page itself. I haven't checked the dataURI it returned is there any way to ckeck it out? Also will it work for any steps?

jywarren commented 5 years ago

Anyone should be able to set up a free trial Google cloud account... Try it out! I think what I wrote about redirecting could work to view the dataurl.

jywarren commented 5 years ago

Is there a way to git track the script?

jywarren commented 5 years ago

https://us-central1-public-lab.cloudfunctions.net/is-function/?url=https://publiclab.org/system/images/photos/000/024/686/original/valverde.jpg&upload=true&sequence=ndvi,colormap&redirect=true

tech4GT commented 5 years ago

I think this is working!

tech4GT commented 5 years ago

For some reason it is loading a landing page though?

screen shot 2019-02-10 at 9 45 48 pm
jywarren commented 5 years ago

I just changed it to return "out" instead of {data:out} to see.

On Sun, Feb 10, 2019, 11:57 AM Varun Gupta <notifications@github.com wrote:

I think this is working!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462150965, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ6DRYgiXgEopf6zTxjto3gpNq-zAks5vME9xgaJpZM4ayvPE .

tech4GT commented 5 years ago

Oh, I already fixed it to redirect, we can do a res.redirect(out) to redirect to the image

jywarren commented 5 years ago

Yeah there might be a limitation on redirecting... Maybe we can somehow override it by returning an HTML page with a built in redirect or something... Anyways it's just for convenience. Many programs will want the Json response.

On Sun, Feb 10, 2019, 11:59 AM Jeffrey Warren <jeff@unterbahn.com wrote:

I just changed it to return "out" instead of {data:out} to see.

On Sun, Feb 10, 2019, 11:57 AM Varun Gupta <notifications@github.com wrote:

I think this is working!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462150965, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ6DRYgiXgEopf6zTxjto3gpNq-zAks5vME9xgaJpZM4ayvPE .

tech4GT commented 5 years ago

Yeah, I'll figure out the redirect right now! But this looks promising!! So what are our next steps? I mean should I jump to core optimizations now?

tech4GT commented 5 years ago

@jywarren I updated it!

jywarren commented 5 years ago

Yes perhaps so! Let's start benchmarking too. Can we actually build in a "execution time" attribute to the Json response so we can benchmark more easily? You can make a copy of the gc function pointed at a branch of IS on your GitHub repo, and keep running it as you push commits. And annotate runtimes in a PR so we can track progress empirically, how does that sound?

On Sun, Feb 10, 2019, 12:02 PM Varun Gupta <notifications@github.com wrote:

Yeah, I'll figure out the redirect right now! But this looks promising!! So what are our next steps? I mean should I jump to core optimizations now?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462151378, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJxkkQb40f-lzpFWJyBNTP1r7aHUqks5vMFCjgaJpZM4ayvPE .

tech4GT commented 5 years ago

@jywarren redirect is now working, you can try it out at the previous url! :tada: Also, can you explain this process to me in a little more detail? I think we can send the execution time as a part of json response from the cloud function but how do I make the copy of gc function run on the github repo?

jywarren commented 5 years ago

It looks like we can point the script at a cloud repository instead of entering a string:

https://cloud.google.com/source-repositories/

On Sun, Feb 10, 2019, 12:11 PM Varun Gupta <notifications@github.com wrote:

@jywarren https://github.com/jywarren redirect is now working, you can try it out at the previous url! 🎉 Also, can you explain this process to me in a little more detail? I think we can send the execution time as a part of json response from the cloud function but how do I make the copy of gc function run on the github repo?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462152038, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ-u052lwVWsi2S_ydpEjmmN7BN9Wks5vMFKRgaJpZM4ayvPE .

tech4GT commented 5 years ago

Okay so do we make a new repository for this, or should I add this script to is-app?

tech4GT commented 5 years ago

And as new code is pushed into image-sequencer we need to invoke the cloud function, correct? And where do we store the performance results?

jywarren commented 5 years ago

Not sure, maybe -app for now?

On Sun, Feb 10, 2019, 12:29 PM Varun Gupta <notifications@github.com wrote:

Okay so do we make a new repository for this, or should I add this script to is-app?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462153665, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ4I6DeeH6JlXyPhzAxhSITji3-Bwks5vMFbigaJpZM4ayvPE .

tech4GT commented 5 years ago

Okay, will do that right now!

tech4GT commented 5 years ago

I'll also add the performance to response! But maybe you can help with annotating runtimes?

jywarren commented 5 years ago

We can just track speeds in PR comments as improvements are made. Actually I guess maybe you want to link it to your remote is branch directly? So you can test the optimizations as directly as possible?

On Sun, Feb 10, 2019, 12:34 PM Varun Gupta <notifications@github.com wrote:

I'll also add the performance to response! But maybe you can help with annotating runtimes?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462154044, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ34O_k5OyiAEWdy8rg_Em6WC9Dz5ks5vMFf9gaJpZM4ayvPE .

tech4GT commented 5 years ago

@jywarren I don't have permission to create repository for the project :sweat_smile:

tech4GT commented 5 years ago

We can just track speeds in PR comments as improvements are made. Actually I guess maybe you want to link it to your remote is branch directly? So you can test the optimizations as directly as possible? On Sun, Feb 10, 2019, 12:34 PM Varun Gupta @.*** wrote: I'll also add the performance to response! But maybe you can help with annotating runtimes? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#755 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ34O_k5OyiAEWdy8rg_Em6WC9Dz5ks5vMFf9gaJpZM4ayvPE .

SO is this done using some sort of bot which runs the function and comments the runtime in the pr? Sorry if I am asking stupid questions, I don't really have a lot of experience in this area :sweat_smile:

harshkhandeparkar commented 5 years ago

@tech4GT I think he meant we could give progress reports in the comments. 😅. Not sure though. Edit: Sorry for commenting without any real reason. I was actually following the discussion. I'm quite pumped up here

tech4GT commented 5 years ago

@tech4GT I think he meant we could give progress reports in the comments.

Do you mean do it manually?

jywarren commented 5 years ago

Well, honestly we can just do optimization testing locally. Let's do that for now.

Eventually we will also have to look at webgl emulation for image distortion too... if thats interesting too, go ahead!

On Sun, Feb 10, 2019, 12:47 PM Varun Gupta <notifications@github.com wrote:

@jywarren https://github.com/jywarren I don't have permission to create repository for the project 😅

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462155108, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ4FPnpgIaj7XIgKuAma2n_9FRopfks5vMFshgaJpZM4ayvPE .

jywarren commented 5 years ago

https://github.com/publiclab/image-sequencer/issues/216

jywarren commented 5 years ago

I just mean we should keep an empirical log of runtime so we can track progress quantitatively... However you want to do it!

tech4GT commented 5 years ago

Oh, Got it!!

tech4GT commented 5 years ago

Also can you please grant me the permission to create cloud repositories on public-lab project, I'll link the is-app to it then, so that we can get the cloud function from there. Also what track should we follow now? As in should I now dive into optimizations? Or we are thinking of deploying to app-engine??

jywarren commented 5 years ago

Let's do optimization and webgl now. I think we should demonstrate the whole intended workflow and then look at the serverless options later. This already works!

tech4GT commented 5 years ago

Okay awesome! I'll dive into that from tomorrow! (it's pretty late here lol)

jywarren commented 5 years ago

Go rest! Great work!

On Sun, Feb 10, 2019, 1:00 PM Varun Gupta <notifications@github.com wrote:

Okay awesome! I'll dive into that from tomorrow! (it's pretty late here lol)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/image-sequencer/issues/755#issuecomment-462156232, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJxHNr3tx4mMr3sbSIPOo6HKME96tks5vMF4LgaJpZM4ayvPE .

icarito commented 5 years ago

I had missed this, very cool indeed!