Open BGCP opened 6 months ago
Change first cell to:
# Clone Real-ESRGAN and enter the Real-ESRGAN
!git clone https://github.com/xinntao/Real-ESRGAN.git
%cd Real-ESRGAN
# Set up the environment
!pip install basicsr
!pip install facexlib
!pip install gfpgan
!pip install -r requirements.txt
!pip install torchvision==0.16.2
!python setup.py develop
and third cell to:
!python inference_realesrgan.py -n RealESRGAN_x4plus -i upload --outscale 3.5 --face_enhance --tile 400
it took me hours to fix it but finally made it work with these
The error you're encountering is because the torchvision
package does not contain a module named functional_tensor
. I'd the same issue and I solved it as follows:
/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py
file.Select the folder icon with ..
to go to the base directory:
Open the /usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py
file.
from torchvision.transforms.functional_tensor import rgb_to_grayscale
with:
from torchvision.transforms.functional import rgb_to_grayscale
Just save the file and that's all! :)
Pueden agregar este código en una celda y ya así hacen el cambio para cada vez que vayan a usar el código:
file_path = "/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py"
line_to_replace = "from torchvision.transforms.functional_tensor import rgb_to_grayscale"
new_line = "from torchvision.transforms.functional import rgb_to_grayscale"
# Leer el contenido del archivo
with open(file_path, 'r') as file:
lines = file.readlines()
# Reemplazar la línea específica
lines = [new_line if line.strip() == line_to_replace else line for line in lines]
# Escribir el contenido modificado de vuelta al archivo
with open(file_path, 'w') as file:
file.writelines(lines)
print(f"Reemplazada la línea '{line_to_replace}' con '{new_line}' en el archivo {file_path}")
I'm not sure on how to correct this error when I try to execute the interference on google colabs
Traceback (most recent call last): File "/content/Real-ESRGAN/inference_realesrgan.py", line 5, in <module> from basicsr.archs.rrdbnet_arch import RRDBNet File "/usr/local/lib/python3.10/dist-packages/basicsr/__init__.py", line 4, in <module> from .data import * File "/usr/local/lib/python3.10/dist-packages/basicsr/data/__init__.py", line 22, in <module> _dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames] File "/usr/local/lib/python3.10/dist-packages/basicsr/data/__init__.py", line 22, in <listcomp> _dataset_modules = [importlib.import_module(f'basicsr.data.{file_name}') for file_name in dataset_filenames] File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/usr/local/lib/python3.10/dist-packages/basicsr/data/realesrgan_dataset.py", line 11, in <module> from basicsr.data.degradations import circular_lowpass_kernel, random_mixed_kernels File "/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py", line 8, in <module> from torchvision.transforms.functional_tensor import rgb_to_grayscale ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'