Moebits / waifu2x

waifu2x image upscaling in Node.js
MIT License
70 stars 11 forks source link

Turn code promise based #2

Closed Specy closed 3 years ago

Specy commented 3 years ago

I stumbled upon this module and really liked it except the part where the upscaling runs in sync, this would cause the main thread to freeze to wait for the upscale to end which is not really good. I had to remake my own to convert the execSync to an async / promise based call.

I don't know typescript to make a pull request to apply this change but I'd grately suggest you convert the sync code to async and let the upscaleImage function return a promise that is resolved with the data from the stdout.

Thanks

Moebits commented 3 years ago

Hi, I made upscaleImage and upscaleImages async, just upgrade to the latest version (v0.1.7).

If you want to learn typescript, then this is a good place to start: https://www.typescriptlang.org/docs/handbook/intro.html I can't recommend it enough.

Specy commented 3 years ago

Thanks a lot! I can finally ditch my patched up implementation, it took me forever to understand how to convert gif and I'm still stuck on encoding them back so this is going to be of big help, if you were wondering, I'm creating a waifu2x GUI with electron and react https://github.com/Specy-wot/Scapix

Moebits commented 3 years ago

Thanks a lot! I can finally ditch my patched up implementation, it took me forever to understand how to convert gif and I'm still stuck on encoding them back so this is going to be of big help, if you were wondering, I'm creating a waifu2x GUI with electron and react https://github.com/Specy-wot/Scapix

Looks pretty cool! Let me know when you finish it. I'm fairly active so feel free to open another issue (or pull request) when you need another feature.

Specy commented 3 years ago

https://github.com/Specy-wot/Scapix/releases/tag/v1.0.0

Finsihed! (Oh well, more like working)

Moebits commented 3 years ago

https://github.com/Specy-wot/Scapix/releases/tag/v1.0.0

Finsihed! (Oh well, more like working)

I like it! Nice work. If you plan on adding support for GIFs then upgrade to the latest version (v0.2.0), since I made a couple bug fixes.

Specy commented 3 years ago

It already supports GIFs, I'll upgrade to v0.2.0 next version which will probably be soon.

Hardest part was figuring out how to package the .exe so now that I got that out of the way I should be able to test out and develop faster

Moebits commented 3 years ago

It already supports GIFs, I'll upgrade to v0.2.0 next version which will probably be soon.

Hardest part was figuring out how to package the .exe so now that I got that out of the way I should be able to test out and develop faster

Huh, I didn't try it since it wasn't mentioned in the UI. Instead of having the frames parameter would you rather have a speed parameter where I calculate the frames for you? (So 1.0x is all the frames, 2.0x is half as many frames, 0.5x doubles the delay between frames).

Specy commented 3 years ago

Yes i didn't even want to add that frames thing, but having an option to make the speed change would be nice as currently the upscaled gif won't have the same speed of the original one.

I haven't mentioned it in the UI as it wasn't fully working and was buggy but when I manage to get it decent enough I'll add an hint for it

Moebits commented 3 years ago

Yes i didn't even want to add that frames thing, but having an option to make the speed change would be nice as currently the upscaled gif won't have the same speed of the original one.

I haven't mentioned it in the UI as it wasn't fully working and was buggy but when I manage to get it decent enough I'll add an hint for it

Ok, v0.2.1 replaces constraint with speed. Hopefully now the output GIF should have the speed that you want, or close enough to it.

Specy commented 3 years ago

Thanks a lot! I'll see tomorrow or one of those days to change stuff up. I already found some issues that I have to fix first

Moebits commented 3 years ago

One more thing. I added the option reverse which will reverse the frames if set to true. Just a fun option to play with (it's on v0.2.2 now).

Specy commented 3 years ago

Oook i managed to add it now already, only issue is that GIFs still are pretty buggy, I've tried with the loading.gif that of the installation and it seems to switch some frames. You can try the new version at https://github.com/Specy-wot/Scapix/releases/tag/v1.0.0 (It was more of a bug fix so I just replaced the file). I don't remember if I forgot to clear the storage or not, before doing anything check in the settings if the output path is set to default, if it isn't the default then change it to one you want

Moebits commented 3 years ago

A folder is created to store all of the extracted and upscaled frames, it's automatically deleted when the GIF is complete but if you stop it in your UI before it completes then the folder remains there. You will need to delete that folder or else the old frames will remain there.