Tohrusky/Final2x

[Bug] Conversion fails on Grayscale (PseudoClass Gray) JPEGs

Closed this issue · 4 comments

MarcG2 commented

Please carefully review each item in the checklist below | 请认真检查以下清单中的每一项 | 以下のチェックリストの各項目を注意深く確認してください

  • Searched and didn't find a similar issue | 已经搜索过,没有发现类似issue | 類似の問題が見つかりませんでした
  • Searched documentation and didn't find relevant content | 已经搜索过文档,没有发现相关内容 | ドキュメントを検索して関連する内容が見つかりませんでした
  • Tried with the latest version and the issue still exists | 已经尝试使用过最新版,问题依旧存在 | 最新バージョンを試しましたが問題は解消されませんでした

Software Version | 软件版本 | ソフトウェアバージョン

1.1.5

Operating System | 操作系统 | オペレーティングシステム

Windows x64

System Version | 系统版本 | システムバージョン

Windows 10

Describe the bug | 描述错误 | BUGの説明

Final2x conversions seems to always fail if inputting a grayscale JPEGs. ImageMagick identifies them as being "PseudoClass Gray".

To reproduce | 复现步骤 | 再現方法

I've uploaded an example of a grayscale image that won't convert.

Claymore v1-001

Error log | 报错日志 | ログ

Log
[{"label":"CPU: Core™ i7-8750H","value":-1},{"label":"GPU 0: NVIDIA GeForce GTX 1070","value":0},{"label":"GPU: Auto","value":114514}]
{"gpuid":0,"inputpath":["D:\_Junk\_Cache\test\Claymore v1-001.jpg"],"model":"Waifu2x-cunet","modelscale":2,"modelnoise":0,"outputpath":"D:\_Junk\_Cache\test","targetscale":2,"tta":false}
2023-09-25 20:33:22.697 | INFO | main:main:58 - projectPATH: C:\Users\mpgri\Downloads\Final2x-windows-x64-unpacked\resources\app\resources\Final2x-core
2023-09-25 20:33:22.698 | INFO | main:main:71 - config loaded
2023-09-25 20:33:22.698 | INFO | src.SRFactory.SRBaseClass:_set_sr_n:53 - sr_n set to 1
2023-09-25 20:33:22.698 | INFO | src.SRFactory.SRBaseClass:init:35 - SRBaseClass init
[0 NVIDIA GeForce GTX 1070] queueC=2[8] queueG=0[16] queueT=1[2]
[0 NVIDIA GeForce GTX 1070] bugsbn1=0 bugbilz=0 bugcopc=0 bugihfa=0
[0 NVIDIA GeForce GTX 1070] fp16-p/s/a=1/1/0 int8-p/s/a=1/1/1
[0 NVIDIA GeForce GTX 1070] subgroup=32 basic=1 vote=1 ballot=1 shuffle=1
2023-09-25 20:33:23.450 | INFO | src.SRFactory.WAIFU2X:_init_SR_class:74 - Waifu2x model initialized
2023-09-25 20:33:23.451 | INFO | src.SRqueue:SR_queue:25 - Processing------[ 0.0% ]
2023-09-25 20:33:23.473 | ERROR | src.SRqueue:SR_queue:67 - tuple index out of range
2023-09-25 20:33:23.473 | WARNING | src.SRqueue:SR_queue:68 - CV2 load image failed: D:_Junk_Cache\test\Claymore v1-001.jpg, skip.
2023-09-25 20:33:23.473 | WARNING | src.SRqueue:SR_queue:69 - Skip_Image: D:_Junk_Cache\test\Claymore v1-001.jpg
2023-09-25 20:33:23.474 | INFO | src.utils.progressLog:printProgress:34 - Processing------[ 100.0% ]
2023-09-25 20:33:23.479 | SUCCESS | main:main:81 - SR_COMPLETED
CLOSE CODE:3221226505

Additional context | 附加内容 | 追加コンテキスト

No response

At present, we can only convert it to rgb/rgba and then process it.

in https://github.com/Tohrusky/Final2x-core/blob/main/src/SRqueue.py#L59 I use this to compatible with special characters
img = cv2.imdecode(np.fromfile(img_path, dtype=np.uint8), cv2.IMREAD_UNCHANGED)

but cv.imread can load a grayscale image directly into 3 channels, when img is None, try to use it may work…
And the output of the neural network is in rgb. Wanna convert it back to grayscale?

MarcG2 commented

I'm not sure I understand your comment. For reference, I use Final2x-core with the compiled Windows EXE.

I understand that the upscalers are intended for sRGB. So it's fine with me if the 1-channel grayscale images have to first be converted to RGB.

Having a built-in option for converting the final output back to 1-channel grayscale would be nice. Though I don't require it because I convert the upscaled images to JPEG afterwards.

having the same problem. is there any solutions?

having the same problem. is there any solutions?

I'll fix it in a few days