cannot convert float infinity to integer

#1 · open · 6 comments

View on GitHub ↗

alucryd

Hi there, I'm trying the max character progression boost preset with the bare minimum changes (character backend to NCNN_VK) to make it work, and am running into an error. Scene detection and metric passes are fine, but it fails early while calculating boost with the following error: ``` [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] queueC=1[1] queueG=0[1] queueT=2[1] [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] bugsbn1=0 bugbilz=0 bugcopc=0 bugihfa=0 [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] fp16-p/s/u/a=1/1/1/1 int8-p/s/u/a=1/1/1/1 [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] subgroup=32(16~32) ops=1/1/1/1/1/1/1/1/1/1 [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] fp16-8x8x16/16x8x8/16x8x16/16x16x16=0/0/0/0 Scene 016 Frame [ 1497: 1690] / Calculating boost / 342 scenes per second/home/public/Videos/Encodes/Progression-Boost.py:4227: RuntimeWarning: invalid value encountered in divide character_roi_diff = np.divide(character_map_filled_diff, character_map_filled_sum, out=np.zeros_like(character_map_filled_diff), where=character_map_filled_sum != 0) Traceback (most recent call last): File "/home/public/Videos/Encodes/Progression-Boost.py", line 4288, in <module> np.savetxt(roi_map_f, line[1].reshape((1, -1)), fmt="%d") ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.13/site-packages/numpy/lib/_npyio_impl.py", line 1631, in savetxt v = format % tuple(row) + newline ~~~~~~~^~~~~~~~~~~~ OverflowError: cannot convert float infinity to integer ``` Any idea? Happens on 2 machines, one with this Intel Arc Pro B50, and another one with an AMD 9070XT (which I have to use for at least part of the process because vship does not support Intel Arc yet).

Comments

Akatmks

Ohhhhh this is peculiar............ I actually couldn't see how it becomes infinite. The invalid division seems to be unrelated, but it looks as thought the error happens right after? I wonder if it's possible that you could send me the related character map file to me? Specifically since it looks to me that this happens in scene 16, so can you go into the Progression Boost temporary folder (specified in `--temp`, or otherwise a folder with similar name to your output scenes file). Go into the `character-boost` folder, and send me the `character-016.npy` file? Thank you!

alucryd

Thank you for the quick reply. I tried switching to SSIMU2 using vszip in the meantime because I suspected my AMD graphics card being the issue (I experience many graphical glitches on my desktop when it is being used by the script), so unfortunately I don't have the files at this point in time, but I'll reproduce if they can be of interest. Meanwhile, I was hit by another error with the SSIMU2 workflow. Starting with the Max Character preset, I replaced vship/Butteraugli with vszip/SSIMU2 and swapped the max metrics summarize function with the min one, as I understand higher SSIMU2 is better, contrary to Butteraugli. Is that a good idea or should I prefer the balanced preset when using SSIMU2? Here is the error: ``` python Progression-Boost.py \ --input S01E01.mkv \ --encode-input S01E01.vpy \ --scene-detection-input S01E01.vpy \ --output-scenes S01E01.json \ --output-roi-maps S01E01.roi_maps/ --resume Time 21:59:44 / Progression Boost started [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] queueC=1[1] queueG=0[1] queueT=2[1] [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] bugsbn1=0 bugbilz=0 bugcopc=0 bugihfa=0 [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] fp16-p/s/u/a=1/1/1/1 int8-p/s/u/a=1/1/1/1 [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] subgroup=32(16~32) ops=1/1/1/1/1/1/1/1/1/1 [0 Intel(R) Arc(tm) Pro B50 Graphics (BMG G21)] fp16-8x8x16/16x8x8/16x8x16/16x16x16=0/0/0/0 Scene 003 Frame [ 218: 347] / Calculating boost / 177 scenes per secondTraceback (most recent call last): File "/home/public/Videos/Encodes/Progression-Boost.py", line 4212, in <module> assert np.all(a_nan), "This indicates a bug in the original code. Please report this to the repository including this entire error message." ~~~~~~^^^^^^^ AssertionError: This indicates a bug in the original code. Please report this to the repository including this entire error message. ``` Attached is the corresponding npy, and the modified python script. [Progression-Boost.py](https://github.com/user-attachments/files/24535712/Progression-Boost.py) [character-003.zip](https://github.com/user-attachments/files/24535718/character-003.zip)

Akatmks

Wow, this is really strange. I see you're having occasional nans... ```py [ 1.00000000e+00, 1.00000000e+00, 8.46508145e-01, 3.02294910e-01, 8.24479535e-02, 9.25070327e-03, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00, nan, nan, nan, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00], [ 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00, 1.00000000e+00], [ 3.75599749e-02, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 2.40975887e-01, nan, nan, nan, 0.00000000e+00, 2.80443668e-01, 2.78797299e-01, 2.77377069e-01, 2.78363436e-01, 2.77598619e-01, 2.77028978e-01, 2.78088391e-01, 1.00000000e+00], ``` But it doesn't make any sense why this code will produce occasional nans.... https://github.com/Akatmks/Akatsumekusa-Encoding-Scripts/blob/7082f7f4b1de48f773c4ad75e10911850684a041/Progression-Boost/Progression-Boost.py#L3485 The result coming from vs-mlrt just shouldn't have nans... That said, this could potentially explain where the infinites at the start of the issue are coming from. These are probably from the same issue. --- Can you confirm that the same error happens in the same scene if you run the same script twice? If it doesn't, try upgrading vs-mlrt if you're on an old version, or downgrading vs-mlrt to a stable version if you're not on a stable version. If you're on Linux, make sure its dependency such as NCNN is on a stable version as well. Thank you!

alucryd

I am on the latest stable mlrt (15.14), running on Arch Linux with only a couple vs plugins that are only available as git on AUR. I'll run it again from scratch and see if I get the same result. Then I'll try MIGX on the desktop GPU, see if it fares better than NCNN.

alucryd

So, it happened on the second run too, but one scene earlier, so it's definitely not deterministic. As for the migraphx run, it fails with the original error, albeit all the way to scene 313 (instead of 16 on the very first run): ``` Time 22:42:52 / Progression Boost started Scene 331 Frame [36283:36437] / Calculating boost / 67 scenes per second/mnt/public/Videos/Encodes/Progression-Boost.py:4227: RuntimeWarning: invalid value encountered in divide character_roi_diff = np.divide(character_map_filled_diff, character_map_filled_sum, out=np.zeros_like(character_map_filled_diff), where=character_map_filled_sum != 0) Traceback (most recent call last): File "/mnt/public/Videos/Encodes/Progression-Boost.py", line 4288, in <module> np.savetxt(roi_map_f, line[1].reshape((1, -1)), fmt="%d") ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.13/site-packages/numpy/lib/_npyio_impl.py", line 1618, in savetxt v = format % tuple(row) + newline ~~~~~~~^~~~~~~~~~~~ OverflowError: cannot convert float infinity to integer ``` Here's the corresponding npy: [character-331.zip](https://github.com/user-attachments/files/24546605/character-331.zip)

Akatmks

Oh I see! Thank you so much. May you raise an issue on upstream vs-mlrt https://github.com/AmusementClub/vs-mlrt/issues ? Specifically your issue is that you're getting random `nan` and `inf` when using the `anime-segmentation/isnet_is.onnx` model. Also, if you're familiar with VapourSynth, you should use a preview application and run this to confirm that whether it's just random errors sometimes or the whole output is garbage. The expected output of this is a mask that selects where the characters are. ``` character_model = Path(vsmlrt.models_path) / "anime-segmentation" / "isnet_is.onnx" character_backend = vsmlrt.Backend.NCNN(fp16=True) character_block_width = math.ceil(clip.width / 64) character_block_height = math.ceil(clip.height / 64) clip = clip.resize.Bicubic(filter_param_a=0, filter_param_b=0.5, \ width=character_block_width*64, height=character_block_height*64, src_width=character_block_width*64, src_height=character_block_height*64, \ format=vs.RGBS, primaries_in=1, matrix_in=1, transfer_in=1, range_in=0, transfer=13, range=1) clip = vsmlrt.inference(clip, character_model, backend=character_backend) ```