Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Fix] add openxlab link to powerpaint #2082

Merged
merged 5 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading