ai-forever / ai-forever/Real-ESRGAN

Crash while trying to upscale <16px per dimention images

Aperta
#33 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
654
Fork
223
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Tested with 4x4 and 8x8 image.
After trying to upscale the 4x4 image by a factor of 2, the program crashed with:
> ValueError: could not broadcast input array from shape (4,4,3) into shape (15,4,3)

on line:
> new_img[0:pad_size, pad_size:-pad_size, :] = np.flip(image[0:pad_size, :, :], axis=0) #top

in file:
> "{...}\site-packages\RealESRGAN\utils.py"

Image file:
![16-bit-P3-blue](https://github.com/user-attachments/assets/46886942-4dfc-4381-b985-42fa981969a3)

Test code:
```PY
# coding=utf-8
import PIL.Image
import torch

from RealESRGAN import RealESRGAN

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

image = PIL.Image.open("../../input/16-bit-P3-blue.png")

model = RealESRGAN(device, scale=2)
model.load_weights(f'weights/RealESRGAN_x{2}.pth')
image = model.predict(image)
```

As a temporal workaround I'm uscaling all input images to the minimum size of 16px for the smaller dimention using PIL scaling.
I haven't tested this much, so IDK if this workaround is fullproof. It may require minumum size of 8 or 32 for a scaling factor of 4 as far as I know.
I will return to this if I ever test it more.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.