CodeFormer
CodeFormer copied to clipboard
[Feature Suggestion] - Output Control
I noticed that by default I can choose the INPUT directory but not the output.
Explanation how it works with the current version:
At the moment the output directory set to "results \ Name of chosen input directory \ Weight Number" and then 3 directories for: Final result, Cropped faces and Restored faces.
For Example, to check out the Final results I go to:
root master project\results\_SOURCE_1.0\ final_results\
In my case I just created batch files to make it easy to test, For each weight to experiment, I use 0.7 and 1.0 for now. Each one of them have scale of x1, x2, x4 and so on.. (that's a lot of batch files but it's easier since there is no GUI and I'm not a programmer) I use it for quick testing so it's faster.
Whenever I change the weight, I will get ANOTHER directory.
Suggestion for Output Control:
The current default output is really nice to keep all the other versions of the images, I wouldn't replace it but I would go for extra control.
But In most cases I just want to get the FINAL result and change the prefix of the output files, probably others will also like that as an extra option.
I can only compare to the way I use it with GFPGAN as example, this could be a very nice addition as extra control probably via more argument / commands.
EXAMPLE using GFPGAN arguments:
-i ./_SOURCE_ -o ./_RESULTS_ -v 1.2 -s 2 --suffix " (v1.2) - x2"
The result will be: Output directory is "RESULTS" inside the root of the master project. "Image Name (model version) - scale size" = "Image (v1.2) - x2.png"
In CodeFormer we can do the same with, instead of Model Version the Weight Number, and the scaling instead of me doing it manually, could be also an argument. The end _prefix is a good control just in case like I did in the example on GFPGAN outputs.
That will give me 1 input for FINAL version only with the specific details such as Weight Number used, Scaled used, and only 1 directory instead I don't need the Cropped and Restored versions. everything will be much cleaner and easier to compare.
Conclusion:
Just to be clear I'm not a programmer so I can't do this by myself, but maybe it is not very complex to add in the future as it's just adding: Output Path control + End Prefix text.
Sorry about my bad English, I hope my suggestion is clear enough.
@AlonDan well got it. I will modify it in a later update. Thanks!
Sounds great, thank you!
I also added in my batch files that whenever I use the same input details, First it will DELETE the files from that directory (if existed of course) and only then create a new one.
The problem was when I converted MORE images or longer video and the next conversion is shorter, so it just overwrite some of the images, but didn't CLEAN (delete) the last conversion process.
So please consider to also add an optional argument to DELETE directory + sub-directory + files inside before running, it will be very useful and easy to test instead of manually delete it every time before the next process.
Thanks ahead once again, you rocks! 💙
@AlonDan has updated, please try it out!
You're quick! thanks, I will try it when I'll get to my main PC. Keep on being so awesome, I'll post again if I'll ran into related issue.
You're quick! thanks, I will try it when I'll get to my main PC. Keep on being so awesome, I'll post again if I'll ran into related issue.
Hi again, I just did a quick rough test with the new update. I first tried it on a single image, it worked but for some reason it said something about input vide as you can see:
python inference_codeformer.py -w 1 -s 1 --bg_upsampler realesrgan -i ./_SOURCE_ -o ./_RESULTS_ --suffix " - CodeFormer x1"
Face detection model: retinaface_resnet50
Background upsampling: True, Face upsampling: False
[1/1] Processing: image.jpg
detect 1 faces
Traceback (most recent call last):
File "inference_codeformer.py", line 237, in <module>
if input_video:
NameError: name 'input_video' is not defined
So I'm not sure if I did something wrong or if it needs to be fixed? I didn't try on video yet...
UPDATE:
I just tried it on video and it's working fine, it seems like the error from above only happens on images. I hope this information helps.
I also noticed the result suffix won't be added to the video file: Example I tried:
Input: video.avi
Output: video.mp4
No suffix at the end of the video output filename, it only works when I tried converting images
If I may suggest few things:
- Can you please add another argument that will DELETE All Files + Sub-Directories inside the "OUTPUT" directory BEFORE it start processing?
For now I do it manually via my batch file, but it will be nice if you'll add this in the code as optional argument 🙏
- it will be GREAT to have all these new updates to your other older and upcoming projects (example: LEDNet which I'm curious about). It's is so much helpful to test things much organized in any prompt based project especially without GUI:
- input + out (directories and files paths)
- suffix + prefix (file naming)
- A dedicated page for usage with ALL the up to date arguments with Full Example (like you did on the main page)
At the moment I used -h (help)
but it will be nice to see all of them in one place.
so if you'll add or tweak an argument it will be easier to follow and see full command line examples.
I must mention again that the way you explained step-by-step how to install from scratch is VERY user-friendly, especially for newbies such as myself, so if you'll consider these 3 suggestions it will be even much more inviting and helpful for everyone.
Sorry about my bad English and thank you once again for your amazing work! 💙
Hi there, this is a great tool which I am using a lot for restoring my images. I'm running the previous version with no issues, but know a few people who installed it today and cannot get the inference.py to run.
There is some confusion over the parameters, where --w is indicated to be used, however now we need to use -w. In addition, some people are receiving an error with passing -w. I think this might be affecting the Colab Notebook too.
Hi there, this is a great tool which I am using a lot for restoring my images. I'm running the previous version with no issues, but know a few people who installed it today and cannot get the inference.py to run.
There is some confusion over the parameters, where --w is indicated to be used, however now we need to use -w. In addition, some people are receiving an error with passing -w. I think this might be affecting the Colab Notebook too.
Yeh I'm getting this in the Colab linked for testing:
Traceback (most recent call last):
File "inference_codeformer.py", line 80, in
Colab: https://colab.research.google.com/drive/1m52PNveE4PBhYrecj34cnpEeiHcC5LTb
!python inference_codeformer.py
Additional note, cloning the repo and changing back the arguments in the input to:
parser.add_argument('-w', '--w', type=float, default=0.5, help='Balance the quality and fidelity')
realigned the namespaces and everything worked again
@MushroomFleet @roboldham We updated input arguments with uniform naming. The readme file and official Colab have been modified accordingly.
Update:
-
--w
to--fidelity_weight
or-w
-
--test_path
to--input_path
or-i
Excelent job
Could you tell me if there is a collab that I could use to restore videos with Codeformer?
Is there an API for this ?
Thanks in advance