From 4226175971c5a506b65538fab21affe6daf8b5ab Mon Sep 17 00:00:00 2001 From: JackLau1222 <2366536135@qq.com> Date: Fri, 24 May 2024 20:41:43 +0800 Subject: [PATCH 1/4] fix the bug of requirements and DeOldify path set --- bmf/demo/colorization_python/Readme.md | 6 +++--- bmf/demo/colorization_python/deoldify_demo.py | 6 ------ bmf/demo/colorization_python/py_deoldify_module.py | 6 ++++++ bmf/demo/colorization_python/requirements.txt | 9 +++++++++ 4 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 bmf/demo/colorization_python/requirements.txt diff --git a/bmf/demo/colorization_python/Readme.md b/bmf/demo/colorization_python/Readme.md index 1a8a6d52..de3f2ff1 100644 --- a/bmf/demo/colorization_python/Readme.md +++ b/bmf/demo/colorization_python/Readme.md @@ -35,7 +35,7 @@ git clone https://github.com/eefengwei/DeOldify.git DeOldify ### 1.2 install the dependent python packages ```Bash -pip3 install -r ./DeOldify/requirements-colab.txt +pip3 install -r ./requirements.txt ``` ### 1.3 download the pretrained-weights @@ -46,7 +46,7 @@ wget -c https://data.deepai.org/deoldify/ColorizeVideo_gen.pth -O ./DeOldify/mod ### 1.4 pip install BMF packages ```Bash -pip3 install bmf +pip3 install BabitMF BabitMF-GPU ``` ### 1.5 verify the FFmpeg libraries is installed and version is correct @@ -73,7 +73,7 @@ ffmpeg -version ```Python import sys -sys.path.insert(0, '/content/DeOldify') +sys.path.insert(0, './DeOldify') print(sys.path) ``` diff --git a/bmf/demo/colorization_python/deoldify_demo.py b/bmf/demo/colorization_python/deoldify_demo.py index 1e4f3842..260abcaa 100644 --- a/bmf/demo/colorization_python/deoldify_demo.py +++ b/bmf/demo/colorization_python/deoldify_demo.py @@ -1,12 +1,6 @@ import bmf import py_deoldify_module -# Add the DeOldify folder to the python search path -import sys - -sys.path.insert(0, './DeOldify') -print(sys.path) - input_video_path = './DeOldify/test_videos/test_video.mp4' output_video_path = 'colored_video.mp4' model_weight_path = './DeOldify/' diff --git a/bmf/demo/colorization_python/py_deoldify_module.py b/bmf/demo/colorization_python/py_deoldify_module.py index 3ad9ab1d..ed8d3339 100644 --- a/bmf/demo/colorization_python/py_deoldify_module.py +++ b/bmf/demo/colorization_python/py_deoldify_module.py @@ -4,6 +4,12 @@ import PIL import bmf.hml.hmp as mp +# Add the DeOldify folder to the python search path +import sys + +sys.path.insert(0, './DeOldify') +print(sys.path) + from deoldify import device from deoldify.device_id import DeviceId import torch diff --git a/bmf/demo/colorization_python/requirements.txt b/bmf/demo/colorization_python/requirements.txt new file mode 100644 index 00000000..b56cdb9d --- /dev/null +++ b/bmf/demo/colorization_python/requirements.txt @@ -0,0 +1,9 @@ +fastai==1.0.60 +tensorboardX>=1.6 +ffmpeg-python +yt-dlp +opencv-python>=4.2.0.32 +Pillow +tornado +imgaug==0.2.6 +ipython \ No newline at end of file From b68381010afdb06bb9dc380f34fb7fc852c6af48 Mon Sep 17 00:00:00 2001 From: Jack Lau <131463945+JackLau1222@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:38:09 +0800 Subject: [PATCH 2/4] Update Readme.md --- bmf/demo/colorization_python/Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bmf/demo/colorization_python/Readme.md b/bmf/demo/colorization_python/Readme.md index de3f2ff1..396f0b11 100644 --- a/bmf/demo/colorization_python/Readme.md +++ b/bmf/demo/colorization_python/Readme.md @@ -46,7 +46,7 @@ wget -c https://data.deepai.org/deoldify/ColorizeVideo_gen.pth -O ./DeOldify/mod ### 1.4 pip install BMF packages ```Bash -pip3 install BabitMF BabitMF-GPU +pip3 install BabitMF-GPU ``` ### 1.5 verify the FFmpeg libraries is installed and version is correct From e3983534aaba87fd93a3e237743dd1b28868ae4e Mon Sep 17 00:00:00 2001 From: Jack Lau <131463945+JackLau1222@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:46:38 +0800 Subject: [PATCH 3/4] resolve conflict --- bmf/demo/colorization_python/deoldify_demo.py | 8 ++++++-- bmf/demo/colorization_python/py_deoldify_module.py | 12 ++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bmf/demo/colorization_python/deoldify_demo.py b/bmf/demo/colorization_python/deoldify_demo.py index 260abcaa..897c5af0 100644 --- a/bmf/demo/colorization_python/deoldify_demo.py +++ b/bmf/demo/colorization_python/deoldify_demo.py @@ -1,5 +1,9 @@ import bmf -import py_deoldify_module + +# Add the DeOldify folder to the python search path +import sys +sys.path.insert(0, './DeOldify') +print(sys.path) input_video_path = './DeOldify/test_videos/test_video.mp4' output_video_path = 'colored_video.mp4' @@ -12,4 +16,4 @@ output_video = video['video'].module('py_deoldify_module', option={"model_path": model_weight_path}) -bmf.encode(output_video[0], None, {"output_path": output_video_path}).run() +bmf.encode(output_video[0], None, {"output_path": output_video_path}).run() \ No newline at end of file diff --git a/bmf/demo/colorization_python/py_deoldify_module.py b/bmf/demo/colorization_python/py_deoldify_module.py index ed8d3339..aea76c4e 100644 --- a/bmf/demo/colorization_python/py_deoldify_module.py +++ b/bmf/demo/colorization_python/py_deoldify_module.py @@ -4,11 +4,7 @@ import PIL import bmf.hml.hmp as mp -# Add the DeOldify folder to the python search path -import sys - -sys.path.insert(0, './DeOldify') -print(sys.path) +from bmf.lib._bmf import sdk from deoldify import device from deoldify.device_id import DeviceId @@ -73,8 +69,8 @@ def process(self, task): VideoFrame): vf = packet.get(VideoFrame) - rgb = mp.PixelInfo(mp.kPF_RGB24) - np_vf = vf.reformat(rgb).frame().plane(0).numpy() + dst_md = sdk.MediaDesc().pixel_format(mp.kPF_RGB24) + np_vf = sdk.bmf_convert(vf, sdk.MediaDesc(), dst_md).frame().plane(0).numpy() # numpy to PIL image = Image.fromarray(np_vf.astype('uint8'), 'RGB') @@ -111,4 +107,4 @@ def process(self, task): output_queue.put(pkt) - return ProcessResult.OK + return ProcessResult.OK \ No newline at end of file From ef8bf5d35a2edae02738a0c7be3b13226ab01c1c Mon Sep 17 00:00:00 2001 From: Jack Lau <131463945+JackLau1222@users.noreply.github.com> Date: Mon, 9 Sep 2024 22:56:17 +0800 Subject: [PATCH 4/4] Make deoldify_demo.py and py_deoldify_module.py consistent with the latest commit --- bmf/demo/colorization_python/deoldify_demo.py | 2 +- bmf/demo/colorization_python/py_deoldify_module.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bmf/demo/colorization_python/deoldify_demo.py b/bmf/demo/colorization_python/deoldify_demo.py index 897c5af0..c89ec3d6 100644 --- a/bmf/demo/colorization_python/deoldify_demo.py +++ b/bmf/demo/colorization_python/deoldify_demo.py @@ -16,4 +16,4 @@ output_video = video['video'].module('py_deoldify_module', option={"model_path": model_weight_path}) -bmf.encode(output_video[0], None, {"output_path": output_video_path}).run() \ No newline at end of file +bmf.encode(output_video[0], None, {"output_path": output_video_path}).run() diff --git a/bmf/demo/colorization_python/py_deoldify_module.py b/bmf/demo/colorization_python/py_deoldify_module.py index aea76c4e..fc106194 100644 --- a/bmf/demo/colorization_python/py_deoldify_module.py +++ b/bmf/demo/colorization_python/py_deoldify_module.py @@ -107,4 +107,4 @@ def process(self, task): output_queue.put(pkt) - return ProcessResult.OK \ No newline at end of file + return ProcessResult.OK