Replies: 1 comment 1 reply
-
Ok, this is no longer an issue. After ~ 24 grueling hours of trying to troubleshoot this I found that actually uninstalling opencv and reinstalling it does the trick. I also changed the format of the output file name, using r instead of \ (windows), but the reinstallation is more likely to be the actual fix. Unbelievable how these internal bugs can be a nightmare, giving us a lot of unnecessary labor/stress. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I used the command line to call the RealESRgan program along with the anime model and I was impressed with the results.
However, ever since I got that result almost like a fluke, I have not been able to replicate it and am scratching my head on what I'm doing wrong. I was trying to use ChatGpt for help, but it stresses me out with so many wrong answers and false leads.
I tried to replicate what had worked but I don't remember, it's been a nightmare, since nothing is working anymore with very strange behavior, both in the command line and in a modified version that can be run straight in VS Code.
The below is very similar to the cmd line that worked yesterday and I can't replicate anymore (the below has only a slight modification to use my dedicated GPU, but maybe other things changed, I can't tell):
C:\Python\MyEnv\Scripts\python "D:\iTunes\Balao\inference_realesrgan.py" --input "D:\iTunes\Balao\teaser.jpg" --output "D:\iTunes\Balao\teaser2.jpg" --model_name RealESRGAN_x4plus_anime_6B --gpu-id 0 --outscale 2
I remember that yesterday the model would be downloaded automatically if no model path provided, but that doesn't happen anymore no matter how I try. I don't remember if when it worked it was using a downloaded model on the fly or the model saved to my folder. Not sure if that matters anyway, but I can't get the model to be downloaded anymore, which makes me suspect my virtual environment went nuts??? I wonder if uninstalling and reinstalling packages to take advantage of CUDA messed up the environment that worked yesterday.
Here's my virtual env packages:
(MyEnv) D:\iTunes>pip list
Package Version
absl-py 2.1.0
addict 2.4.0
altgraph 0.17.4
basicsr 1.4.2
cachetools 5.5.0
certifi 2024.8.30
charset-normalizer 3.4.0
colorama 0.4.6
contourpy 1.1.1
cycler 0.12.1
facexlib 0.3.0
ffmpeg-python 0.2.0
filelock 3.16.1
filterpy 1.4.5
fonttools 4.54.1
fsspec 2024.10.0
future 1.0.0
gfpgan 1.3.8
google-auth 2.36.0
google-auth-oauthlib 1.0.0
grpcio 1.67.1
idna 3.10
imageio 2.35.1
importlib_metadata 8.5.0
importlib_resources 6.4.5
Jinja2 3.1.4
kiwisolver 1.4.7
lazy_loader 0.4
llvmlite 0.41.1
lmdb 1.5.1
Markdown 3.7
MarkupSafe 2.1.5
matplotlib 3.7.5
mpmath 1.3.0
networkx 3.1
numba 0.58.1
numpy 1.24.4
oauthlib 3.2.2
opencv-python 4.10.0.84
opencv-python-headless 4.10.0.84
packaging 24.1
pefile 2023.2.7
pillow 10.4.0
pip 24.3.1
platformdirs 4.3.6
protobuf 5.28.3
pyasn1 0.6.1
pyasn1_modules 0.4.1
pyinstaller 6.11.0
pyinstaller-hooks-contrib 2024.9
pyparsing 3.1.4
python-dateutil 2.9.0.post0
PyWavelets 1.4.1
pywin32-ctypes 0.2.3
PyYAML 6.0.2
realesrgan 0.3.0
requests 2.32.3
requests-oauthlib 2.0.0
rsa 4.9
scikit-image 0.21.0
scipy 1.10.1
setuptools 75.3.0
six 1.16.0
sympy 1.13.3
tb-nightly 2.14.0a20230808
tensorboard-data-server 0.7.2
tifffile 2023.7.10
tkinterdnd2 0.4.2
tomli 2.0.2
torch 2.0.1+cu117
torchvision 0.15.2+cu117
tqdm 4.67.0
typing_extensions 4.12.2
urllib3 2.2.3
Werkzeug 3.0.6
wheel 0.44.0
yapf 0.40.2
zipp 3.20.2
I'm not sure what happened. But maybe I'd like to start with the below code, which is a modification I created myself to do this from VS code. Can you guys please help me to point out what's wrong with the below code?
AI MODEL IS LOADED ONCE AND APPLIED TO MANY IMAGES
import argparse
import cv2
import glob
import os
from basicsr.archs.rrdbnet_arch import RRDBNet
from basicsr.utils.download_util import load_file_from_url
from realesrgan import RealESRGANer
from realesrgan.archs.srvgg_arch import SRVGGNetCompact
from time import time, strftime, localtime
from sys import exit
import os
LIST FILES FROM FOLDER
import os
def folder_files(folder_path, ext=None):
# List all files in the folder, filter out directories
files = [os.path.join(folder_path, f) for f in os.listdir(folder_path) if os.path.isfile(os.path.join(folder_path, f))] # and f.endswith(ext)
# Sort the files alphabetically
files.sort()
return files
def main():
# Mimicking the argparse behavior by creating a Namespace object
args = argparse.Namespace()
args.input = "D:\iTunes\Balao\Input2"
args.output = "D:\iTunes\Balao\Output"
args.denoise_strength = 0.5
args.outscale = 2
args.model_name = "RealESRGAN_x4plus_anime_6B"
args.model_path = None # "D:\iTunes\Balao\weights\RealESRGAN_x4plus_anime_6B.pth"
args.suffix = ""
args.tile = 0
args.tile_pad = 10
args.pre_pad =0
args.face_enhance = False
args.fp32 = False
args.alpha_upsampler = "realesrgan"
args.ext = "auto"
args.gpu_id = 0
Record the start time
start_time = time()
fmt_start_time = strftime("%H:%M:%S", localtime(start_time))
print(f"\nStart time: {fmt_start_time}")
CALL FUNCTION
main()
Record the end time
end_time = time()
Calculate the elapsed time in minutes
elapsed_time = (end_time - start_time) / 60
print(f"\nElapsed time: {elapsed_time:.2f} minutes")
Beta Was this translation helpful? Give feedback.
All reactions