Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Modules, Colab doesn't work anymore #556

Open
ma5termich opened this issue Jun 17, 2024 · 6 comments
Open

Missing Modules, Colab doesn't work anymore #556

ma5termich opened this issue Jun 17, 2024 · 6 comments

Comments

@ma5termich
Copy link

Until a few months ago the Google Colab worked perfectly, now I find this error when I execute the block of code relating to Inference:

Traceback (most recent call last):
File "/content/GFPGAN/inference_gfpgan.py", line 7, in
from basicsr.utils import imwrite
File "/usr/local/lib/python3.10/dist-packages/basicsr/init.py", line 4, in
from .data import *
File "/usr/local/lib/python3.10/dist-packages/basicsr/data/init.py", line 22, in
_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
_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
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
from torchvision.transforms.functional_tensor import rgb_to_grayscale
ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'
ls: cannot access 'results/cmp': No such file or directory

@SaintFresh
Copy link

@huangzekai
Copy link

I have the same problem, does anyone know how to solve it?

@G-force78
Copy link

Its a persistent annoying problem

#Open /usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py and on line 8, simply change:

#from torchvision.transforms.functional_tensor import rgb_to_grayscale
#to:

#from torchvision.transforms.functional import rgb_to_grayscale

@Epsilon-BUAP
Copy link

After u upload ur image, create a new code with mine:

import fileinput
import sys

def update_degradations_import(file_path):
# Línea original que queremos reemplazar
original_line = 'from torchvision.transforms.functional_tensor import rgb_to_grayscale\n'
# Línea nueva que queremos escribir
new_line = 'from torchvision.transforms.functional import rgb_to_grayscale\n'

# Abrir el archivo en modo de lectura y escritura
with fileinput.FileInput(file_path, inplace=True, backup='.bak') as file:
    for line in file:
        # Reemplazar la línea original por la nueva línea
        if line == original_line:
            sys.stdout.write(new_line)
        else:
            sys.stdout.write(line)

Ruta al archivo de degradaciones que queremos modificar

file_path = '/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py'

Llamar a la función para actualizar la importación

update_degradations_import(file_path)

print(f"Updated import in {file_path}")

@Epsilon-BUAP
Copy link

image

@SaintFresh
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants