Closed miwaniza closed 1 year ago
Hi again @miwaniza! This is a very nice way to make a UI; I've never used Gradio before and haven't known this is so easy, but now I love it. I understand that switching to CV2 from PIL and Moviepy significantly boosts performance, right? If yes, then great! One thing I don't like is that it copies the code from zoom_video_composer.py; I believe it would be much better just to import the primary function from that file and wrap it with GUI and apply all the other changes directly to zoom_video_composer.py. WDYT?
Hi @mwydmuch ! Sorry for the delay in reply. I also tend to think that the import-wrapping approach is better. I just skipped this for the sake of fast POC. The refactoring should be done in two steps:
Hi @miwaniza, no problem. Thanks for the answer and POC! I agree, with you, and I propose we proceed in the following way:
When it comes to using OpenCV video writer, I wonder if it is better performance-wise than Moviepy and justify the change. I like Moviepy because it has a nicer API and it uses ffmpeg for all the platforms, while I believe cv2 uses different video backends. The custom logger can be passed to Moviepy, so integration with Gradio shouldn't be a problem.
I have kept both PIL and CV2 functions. You can choose preferable using the new switch --image-engine, cv2 is the default one. Also, moved functions to the helper file.
@mwydmuch can we go further?
Hi @miwaniza, yes, thank you for your changes. I'm sorry I haven't yet finished my part. I was super busy last few days. I will proceed with this PR tomorrow.
@mwydmuch no worries, fully understandable. Meanwhile, I can align the PR to the latest changes in the master.
Hi @miwaniza, I've made a small refactor of your changes. I wrapped cv2 and pil "image engines" into respective image classes to have an abstraction for all other functions and reduce code repetition. I also improved the gradio_ui by adding support for a progress bar to it. Please see if you like these changes and if you would like to add something more.
That's great! I like that!
Great, thank you for your contribution, this gradio UI is great and with CV2 frame generation is 30-50% faster!
The result can be checked here.