butaixianran / VIdeo_Upscaler_by_GFPGAN

A VIdeo Upscaler script based on GFPGAN
MIT License
2 stars 0 forks source link

Loadnet stuck #2

Open ell28 opened 3 weeks ago

ell28 commented 3 weeks ago

I already did all the things on readme but still when I run video.py it always stuck on "loadnet = torch.load(model_path)"

Here is the full command line C:\Users\ellie\Downloads\GFPGAN-master\GFPGAN-master>python video.py start handle_video PROCESSING :C:\Users\ellie\Downloads\GFPGAN-master\GFPGAN-master\data\videos\Video.mp4 run inference_gfpgan.py C:\Python312\Lib\site-packages\realesrgan\utils.py:63: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. loadnet = torch.load(model_path, map_location=torch.device('cpu')) C:\Python312\Lib\site-packages\torchvision\models_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and may be removed in the future, please use 'weights' instead. warnings.warn( C:\Python312\Lib\site-packages\torchvision\models_utils.py:223: UserWarning: Arguments other than a weight enum or None for 'weights' are deprecated since 0.13 and may be removed in the future. The current behavior is equivalent to passing weights=None. warnings.warn(msg) C:\Python312\Lib\site-packages\facexlib\detection__init.py:22: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. load_net = torch.load(model_path, map_location=lambda storage, loc: storage) C:\Python312\Lib\site-packages\facexlib\parsing\init__.py:20: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. load_net = torch.load(model_path, map_location=lambda storage, loc: storage) C:\Users\ellie\Downloads\GFPGAN-master\GFPGAN-master\gfpgan\utils.py:92: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature. loadnet = torch.load(model_path)

butaixianran commented 2 weeks ago

ok, seems torch has some breaking changes with latest version. I'll try to add a quick fix at weekend.

Also, your error msg shows it is just a warning, not an error, so this project should still work even with those warnings.

ell28 commented 2 weeks ago

Hey man i'm encountering another issue with inference-gfpgan.py file that says invalid arguments. I check the argument on this line is correct.

command = f"python inference_gfpgan.py -i {upload_folder} -o {result_folder} -v 1.4 -s {upscale} --bg_upsampler realesrgan"

This is the full command line from running video.py D:\Machine Learning\GFPGAN-master\GFPGAN-master>python video.py start handle_video PROCESSING :D:\Machine Learning\GFPGAN-master\GFPGAN-master\data\videos\@r07qxo - R⤓Download (1).mp4 run inference_gfpgan.py usage: inference_gfpgan.py [-h] [-i INPUT] [-o OUTPUT] [-v VERSION] [-s UPSCALE] [--bg_upsampler BG_UPSAMPLER] [--bg_tile BG_TILE] [--suffix SUFFIX] [--only_center_face] [--aligned] [--ext EXT] [-w WEIGHT] inference_gfpgan.py: error: unrecognized arguments: Learning\GFPGAN-master\GFPGAN-master\data\upload Learning\GFPGAN-master\GFPGAN-master\data\results walking [INFO] 1 video1.avi [INFO] 1 D:\Machine Learning\GFPGAN-master\GFPGAN-master\data\results_videos\video1.avi ffmpeg version 2024-08-26-git-98610fe95f-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libopenjpeg --enable-libquirc --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-libqrencode --enable-librav1e --enable-libsvtav1 --enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 59. 34.100 / 59. 34.100 libavcodec 61. 11.100 / 61. 11.100 libavformat 61. 5.101 / 61. 5.101 libavdevice 61. 2.100 / 61. 2.100 libavfilter 10. 2.102 / 10. 2.102 libswscale 8. 2.100 / 8. 2.100 libswresample 5. 2.100 / 5. 2.100 libpostproc 58. 2.100 / 58. 2.100 [avi @ 000001455c535340] Format avi detected only with low score of 1, misdetection possible! [in#0 @ 000001455c518a80] Error opening input: Invalid data found when processing input Error opening input file D:\Machine Learning\GFPGAN-master\GFPGAN-master\data\results_videos\video1.avi. Error opening input files: Invalid data found when processing input end handle_video

butaixianran commented 2 weeks ago

Hey man i'm encountering another issue with inference-gfpgan.py file that says invalid arguments. I check the argument on this line is correct.

Ok, did some test, get the same error when using a short clip which is cut from a long video. Seems there is something missing in that video's header and need to be fixed before using with ffmpeg and this script.

I'll figure something out.

butaixianran commented 2 weeks ago

Hey man i'm encountering another issue with inference-gfpgan.py file that says invalid arguments. I check the argument on this line is correct.

command = f"python inference_gfpgan.py -i {upload_folder} -o {result_folder} -v 1.4 -s {upscale} --bg_upsampler realesrgan" Format avi detected only with low score of 1, misdetection possible! [in#0 @ 000001455c518a80] Error opening input: Invalid data found when processing input Error opening input file D:\Machine Learning\GFPGAN-master\GFPGAN-master\data\results_videos\video1.avi. Error opening input files: Invalid data found when processing input end handle_video

ok, figure it out. When GFPGAN process is failed, ffmpeg can not get the result video, then you get this error.

So, the real error msg, is the line before "walking". In your case, it is:
"error: unrecognized arguments: Learning\GFPGAN-master\GFPGAN-master\data\upload Learning\GFPGAN-master\GFPGAN-master\data\results".

So, I guess the space in folder name is the issue here.

Also, Project GFPGAN is based on another project named "basicsr" which does not work with torch 2.*. It uses a package named torchvision.transforms.functional_tensor, which is not there anymore.

So, you have to install pytorch 1.x and torchvision by following torch's official website:
https://pytorch.org/get-started/previous-versions/

Another possible issue is, when using GFPGAN for the first time, it gonna download 4 models from github to your local disk. If that downloading failed, then this project will fail too. If you got a downloading error, just downloat that model manually, the error msg will show the downloading link.

The base line is, if your GFPGAN works, this project works. If your GFPGAN fails, this project fails too.

I'll update the document for all those details.

butaixianran commented 2 weeks ago

Updated document, check it to make this work.

Also, since you are using torch 2.x, you can check the Working with torch 2.x part at the end of document.