Skip to content

Commit

Permalink
[Fix] add openxlab link to powerpaint (#2082)
Browse files Browse the repository at this point in the history
* add openxlab link

* fix path

* update scale

* fix text-guided bug

* use 3.41
  • Loading branch information
liuwenran authored Dec 9, 2023
1 parent 374ee50 commit 71d0e95
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion projects/powerpaint/README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
16 changes: 10 additions & 6 deletions projects/powerpaint/gradio_PowerPaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
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(
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(
Expand Down Expand Up @@ -258,9 +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,
Expand Down Expand Up @@ -373,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,
Expand Down
2 changes: 1 addition & 1 deletion projects/powerpaint/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
controlnet-aux==0.0.3
diffusers==0.23.1
gradio==3.23.0
gradio==3.41.0
mmengine
opencv-python
torch
Expand Down

0 comments on commit 71d0e95

Please # to comment.