GFPGAN
GFPGAN copied to clipboard
'torchvision.transforms.functional_tensor' has been depreciated to 'torchvision.transforms.functional'
Traceback (most recent call last):
File "/content/GFPGAN/inference_gfpgan.py", line 7, in
@sipsmehta run this code on colab before running 3. Inference. it will replace the degradation.py line 8 from torchvision.transforms.functional_tensor import rgb_to_grayscale to: from torchvision.transforms.functional import rgb_to_grayscale
then you're good to go...
# Define the file path
file_path = '/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py'
# Define the new import statement
new_import_statement = "from torchvision.transforms.functional import rgb_to_grayscale\n"
# Read the content of the file
with open(file_path, 'r') as file:
lines = file.readlines()
# Modify the desired line (line 8 in this case)
if len(lines) >= 8:
lines[7] = new_import_statement # Index 7 corresponds to line 8 (0-based indexing)
# Write the modified content back to the file
with open(file_path, 'w') as file:
file.writelines(lines)
print("Replacement completed successfully!")
@shishirahm3d Thank you!
@shishirahm3d i have a doubt. can i train the model on side faces . so it can enhance that. since now it dont work properluy on side faces
@sipsmehta run this code on colab before running 3. Inference. it will replace the degradation.py line 8 from torchvision.transforms.functional_tensor import rgb_to_grayscale to: from torchvision.transforms.functional import rgb_to_grayscale
then you're good to go...
# Define the file path file_path = '/usr/local/lib/python3.10/dist-packages/basicsr/data/degradations.py' # Define the new import statement new_import_statement = "from torchvision.transforms.functional import rgb_to_grayscale\n" # Read the content of the file with open(file_path, 'r') as file: lines = file.readlines() # Modify the desired line (line 8 in this case) if len(lines) >= 8: lines[7] = new_import_statement # Index 7 corresponds to line 8 (0-based indexing) # Write the modified content back to the file with open(file_path, 'w') as file: file.writelines(lines) print("Replacement completed successfully!")
It is realy helpful,ths!