From b9afc33b533e178f3f58c6cd19cc7694b42944bf Mon Sep 17 00:00:00 2001 From: liuwenran <448073814@qq.com> Date: Fri, 8 Dec 2023 11:28:45 +0800 Subject: [PATCH 1/5] add openxlab link --- projects/powerpaint/README.md | 2 +- projects/powerpaint/gradio_PowerPaint.py | 2 +- projects/powerpaint/requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/powerpaint/README.md b/projects/powerpaint/README.md index f122e47d2..7fd6d2cd0 100644 --- a/projects/powerpaint/README.md +++ b/projects/powerpaint/README.md @@ -1,6 +1,6 @@ # A Task is Worth One Word: Learning with Task Prompts for High-Quality Versatile Image Inpainting -### [Project Page](https://powerpaint.github.io/) | [Paper](https://arxiv.org/abs/2312.03594) +### [Project Page](https://powerpaint.github.io/) | [Paper](https://arxiv.org/abs/2312.03594) | [OpenXLab](https://openxlab.org.cn/apps/detail/rangoliu/PowerPaint#basic-information) This README provides a step-by-step guide to download the repository, set up the required virtual environment named "PowerPaint" using conda, and run PowerPaint with or without ControlNet. diff --git a/projects/powerpaint/gradio_PowerPaint.py b/projects/powerpaint/gradio_PowerPaint.py index 86bf3f7fe..3361b98a7 100644 --- a/projects/powerpaint/gradio_PowerPaint.py +++ b/projects/powerpaint/gradio_PowerPaint.py @@ -30,7 +30,7 @@ add_tokens( tokenizer=pipe.tokenizer, text_encoder=pipe.text_encoder, - placeholder_tokens=['MMcontext', 'MMshape', 'MMobject'], + placeholder_tokens=['P_ctxt', 'P_shape', 'P_obj'], initialize_tokens=['a', 'a', 'a'], num_vectors_per_token=10) pipe.unet.load_state_dict( diff --git a/projects/powerpaint/requirements.txt b/projects/powerpaint/requirements.txt index 14755c0ff..84023324d 100644 --- a/projects/powerpaint/requirements.txt +++ b/projects/powerpaint/requirements.txt @@ -1,6 +1,6 @@ controlnet-aux==0.0.3 diffusers==0.23.1 -gradio==3.23.0 +gradio==3.38.0 mmengine opencv-python torch From a5555600cb2db1edcd22719b52d1e09739e848d6 Mon Sep 17 00:00:00 2001 From: liuwenran <448073814@qq.com> Date: Fri, 8 Dec 2023 14:47:13 +0800 Subject: [PATCH 2/5] fix path --- projects/powerpaint/gradio_PowerPaint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/powerpaint/gradio_PowerPaint.py b/projects/powerpaint/gradio_PowerPaint.py index 3361b98a7..f85ef4642 100644 --- a/projects/powerpaint/gradio_PowerPaint.py +++ b/projects/powerpaint/gradio_PowerPaint.py @@ -34,9 +34,9 @@ initialize_tokens=['a', 'a', 'a'], num_vectors_per_token=10) pipe.unet.load_state_dict( - torch.load('./models/diffusion_pytorch_model.bin'), strict=False) + torch.load('./models/unet/diffusion_pytorch_model.bin'), strict=False) pipe.text_encoder.load_state_dict( - torch.load('./models/pytorch_model.bin'), strict=False) + torch.load('./models/text_encoder/pytorch_model.bin'), strict=False) pipe = pipe.to('cuda') depth_estimator = DPTForDepthEstimation.from_pretrained( From 55a3a2d471b53c08ace3e89de971c28f463354bc Mon Sep 17 00:00:00 2001 From: liuwenran <448073814@qq.com> Date: Fri, 8 Dec 2023 16:08:35 +0800 Subject: [PATCH 3/5] update scale --- projects/powerpaint/gradio_PowerPaint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/powerpaint/gradio_PowerPaint.py b/projects/powerpaint/gradio_PowerPaint.py index f85ef4642..b68f4c3da 100644 --- a/projects/powerpaint/gradio_PowerPaint.py +++ b/projects/powerpaint/gradio_PowerPaint.py @@ -261,6 +261,7 @@ def infer(input_image, text_guided_prompt, text_guided_negative_prompt, else: prompt = '' negative_prompt = '' + scale = 10.0 if enable_control: return predict_controlnet(input_image, input_control_image, From 687f16b13794c20631a459c01f3e994343c88993 Mon Sep 17 00:00:00 2001 From: liuwenran <448073814@qq.com> Date: Fri, 8 Dec 2023 16:47:13 +0800 Subject: [PATCH 4/5] fix text-guided bug --- projects/powerpaint/gradio_PowerPaint.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/projects/powerpaint/gradio_PowerPaint.py b/projects/powerpaint/gradio_PowerPaint.py index b68f4c3da..373245687 100644 --- a/projects/powerpaint/gradio_PowerPaint.py +++ b/projects/powerpaint/gradio_PowerPaint.py @@ -258,10 +258,14 @@ def infer(input_image, text_guided_prompt, text_guided_negative_prompt, elif task == 'shape-guided': prompt = shape_guided_prompt negative_prompt = shape_guided_negative_prompt - else: + elif task == 'object-removal': prompt = '' negative_prompt = '' scale = 10.0 + else: + task = 'text-guided' + prompt = text_guided_prompt + negative_prompt = text_guided_negative_prompt if enable_control: return predict_controlnet(input_image, input_control_image, @@ -374,8 +378,7 @@ def select_tab_shape_guided(): inpaint_result = gr.Image() gr.Markdown('### Mask') gallery = gr.Gallery( - label='Generated images', show_label=False).style( - grid=[2], height='auto') + label='Generated images', show_label=False, columns=2) run_button.click( fn=infer, From a8cb8a0d7ab716598fafac30a677d45ee732b1ff Mon Sep 17 00:00:00 2001 From: liuwenran <448073814@qq.com> Date: Fri, 8 Dec 2023 16:48:15 +0800 Subject: [PATCH 5/5] use 3.41 --- projects/powerpaint/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/powerpaint/requirements.txt b/projects/powerpaint/requirements.txt index 84023324d..8a0cf9b0f 100644 --- a/projects/powerpaint/requirements.txt +++ b/projects/powerpaint/requirements.txt @@ -1,6 +1,6 @@ controlnet-aux==0.0.3 diffusers==0.23.1 -gradio==3.38.0 +gradio==3.41.0 mmengine opencv-python torch