Author Topic: Need help combining some ESRGAN PY Scripts for dedithering and alpha  (Read 7690 times)

Fraggoso

  • *
  • Posts: 278
    • View Profile
As I wanted to improve on my FFIX and X/X-2 HD Remake Texture Mods, I searched for a way to preserve alpha channels within an image using ESRGAN and asked Xinntao (from the original ESRGAN Team) in one of the bug reports if there's a way to do so.
He tweaked the test.py script so that now we can also upscale and preserves alpha channels: https://pastebin.com/xUdTHff9 Sadly he never came back to the community on other questions, that's why I'm shouting help to you all. :)

Here goes my first two questions:

1. Would it be possible to tweak the alpha test.py so it can detect alpha in an image and preserve the alpha?
2. If no alpha is in the image then it should just skip the alpha scaling?
Right now if there's no alpha, the script will stop working and ask you to use the normal test.py that comes with ESRGAN which is a bit tedious to use.

On the other hand, I found a model that works wonder on dithered images which can be found quite a lot in PSX Games.
https://github.com/alsa64/AI-wiki/wiki/Model-Database

I made a quick comparison.
http://www.framecompare.com/image-compare/screenshotcomparison/21J1NNNU

The problem with this script is, that it sadly also eliminates alpha completely...
So here's my last question:
3. With a hopefully tweaked alpha py, I also would need to have this working with the dedither model

Every help is very much appreciated! :)

Manakaiser

  • *
  • Posts: 110
    • View Profile
https://mega.nz/#!W591SaCI!XPT7QjQFPG6oy6I3-DOTFaGrq38xyzaBUfh_3mtwp_8

this test file preserves alpha; use with old esrgan version (new one is useless for the end user anyway it has no effect on quality so i advise against using it in general). Gonna warn you though doing alpha wiht esrgan is always relatively bad;

Also using https://github.com/ptrsuder/crop-upscale-merge tool handles alpha better than the test i posted you and the tool is pretty much perfect regarding esrgan (and regarding what it does) anyway so I suggest just using it in general; Just configure settings and it will automatically split alpha and merge after upscaling, and as a bonus it has a really nice GUI and makes using many different models in quick succession easy and quick (for ex dedither followed by whatever model you want).
« Last Edit: 2019-07-10 14:55:28 by Manakaiser »

satsuki

  • *
  • Posts: 807
    • View Profile
    • My softs (french only)
Seems a great gui, do you have any binary file of it ?

Manakaiser

  • *
  • Posts: 110
    • View Profile
https://github.com/ptrsuder/crop-upscale-merge/releases just dl the release, exe is inside inside.

satsuki

  • *
  • Posts: 807
    • View Profile
    • My softs (french only)
My bad, haven't seens it ^^'

Fraggoso

  • *
  • Posts: 278
    • View Profile
https://mega.nz/#!W591SaCI!XPT7QjQFPG6oy6I3-DOTFaGrq38xyzaBUfh_3mtwp_8

this test file preserves alpha; use with old esrgan version (new one is useless for the end user anyway it has no effect on quality so i advise against using it in general). Gonna warn you though doing alpha wiht esrgan is always relatively bad;

Also using https://github.com/ptrsuder/crop-upscale-merge tool handles alpha better than the test i posted you and the tool is pretty much perfect regarding esrgan (and regarding what it does) anyway so I suggest just using it in general; Just configure settings and it will automatically split alpha and merge after upscaling, and as a bonus it has a really nice GUI and makes using many different models in quick succession easy and quick (for ex dedither followed by whatever model you want).

I already tried Auto crop but it doesn't work with the dedither Modell.
The error log reads:

Code: [Select]
[10.07.2019 22:17:59] Traceback (most recent call last):
[10.07.2019 22:17:59]   File "hackallimages.py", line 7, in <module>
[10.07.2019 22:17:59]     import architecture as arch
[10.07.2019 22:17:59] ModuleNotFoundError: No module named 'architecture'
[10.07.2019 22:18:00] Error ocured during ESRGAN work!

If I run it normally or with Satsukis GUI, it works, but not with Auto crop, sadly. :/

Manakaiser

  • *
  • Posts: 110
    • View Profile
because you are using new esrgan and as i mentioned already its not advised and has no benefit for the end user.

use this https://github.com/xinntao/ESRGAN/releases/tag/old-arch then auto should work.

cheers.

Fraggoso

  • *
  • Posts: 278
    • View Profile
because you are using new esrgan and as i mentioned already its not advised and has no benefit for the end user.

use this https://github.com/xinntao/ESRGAN/releases/tag/old-arch then auto should work.

cheers.

Thanks, now at least it works with the models but still, alpha isn't preserved. :(

Afterwards all images within my LR folder are erased.
« Last Edit: 2019-07-11 09:09:17 by Fraggoso »

Manakaiser

  • *
  • Posts: 110
    • View Profile
Settings like this (dont be scared youre not gonna get a quality loss despite the warning on preserve format):




then click run all steps (Output: default; Overwrite: Disable; make sure the "merged" folder exists so create it beforehand)
« Last Edit: 2019-07-11 09:43:08 by Manakaiser »

Fraggoso

  • *
  • Posts: 278
    • View Profile
I really can't solve the problem...
It also doesn't seem to copy the tiles from one folder to another, if I copy the tiles afterwards to merged folder and hit merge they merge at last but still, without alpha it's useless...

Everytime I receive this error:
Code: [Select]
'D:\ESRGAN\LR' is cleared

All images within that folder than vanishes.

I'm too stupid I think! >_<
« Last Edit: 2019-07-11 12:29:12 by Fraggoso »

Manakaiser

  • *
  • Posts: 110
    • View Profile
Youre killing me XD

Are you absolutely sure you have all settings exactly like I posted them (including using the run all steps button, and having overwrite disabled and output default on the first tab? Because I can guaranteee that it works, i just double checked and tried it again. Worked flawlessly X_X

*edit* im almost sure that you didint have the image in the LR folder and a copy of it in the "img" folder(create it in the esrgan root (doesnt have to be called img just thats what its called by defualt just check the paths section in the first image i posted in my previous reply for reference what im talking about) if you dont have it like you created "merged" in results if you didint have it). =)



Fingers crossed :P
« Last Edit: 2019-07-11 15:49:25 by Manakaiser »

Fraggoso

  • *
  • Posts: 278
    • View Profile
I'm so baffled as it works now without any problems! >_<
Thank you so much, Manakaiser! You made my day. :)

Manakaiser

  • *
  • Posts: 110
    • View Profile