BrushNetApi / README.md
Juan Leal
Recent updates
ec9fa05
---
title: BrushNet
emoji:
colorFrom: yellow
colorTo: indigo
sdk: gradio
sdk_version: 3.50.2
python_version: 3.9
app_file: app.py
pinned: false
license: apache-2.0
---
# BrushNetApi
This repo implements an API that allows other applications to call it with http request.
## Instructions to Run the Application
Create a virtual environment and install dependencies.
```
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
## Run Honcho to Start all the Services
```
honcho start
```
## Or Run the Redis, Celery and Web Server in seperate tabs
Start Redis Server
```
redis-server
```
Start the Celery Worker
```
# In a new terminal window:
./start_celery_worker.sh
```
Run the FastAPI Application
```
# In a new terminal window:
uvicorn app_api:app --host 0.0.0.0 --port 8000
```
## How to Use the API
a. Initiate Image Generation
Send a POST request to /inpaint with the required parameters.
Request Body
```
{
"input_image": "<base64-encoded input image>",
"input_mask": "<base64-encoded input mask>",
"prompt": "A beautiful cake on the table",
"negative_prompt": "ugly, low quality",
"control_strength": 1.0,
"guidance_scale": 12.0,
"num_inference_steps": 50,
"seed": 551793204,
"randomize_seed": false,
"blended": false,
"invert_mask": true,
"count": 1,
"webhook_url": "http://your-webhook-url.com/notify" # Optional
}
```
Response
```
{
"job_id": "<task_id>"
}
```
b. Check Task Status
Send a GET request to /status/{job_id}.
Response
```
{
"status": "PENDING" # Or "STARTED", "SUCCESS", "FAILURE"
}
```
c. Retrieve Result
Once the status is “SUCCESS”, send a GET request to /result/{job_id}.
Response:
```
{
"images": ["<base64-encoded image>", "..."]
}
```
d. Webhook Notification
If you provided a webhook_url in your request, the server will send a POST request to that URL with the images once the task is complete.
```
{
"images": ["<base64-encoded image>", "..."]
}
```
The webhook functionality is included in the generate_image_task function. If a webhook_url is provided in the request, the server will send a POST request to that URL with the generated images.
# BrushNet(original README below )
This repository contains the gradio demo of the paper "BrushNet: A Plug-and-Play Image Inpainting Model with Decomposed Dual-Branch Diffusion"
Keywords: Image Inpainting, Diffusion Models, Image Generation
> [Xuan Ju](https://github.com/juxuan27)<sup>12</sup>, [Xian Liu](https://alvinliu0.github.io/)<sup>12</sup>, [Xintao Wang](https://xinntao.github.io/)<sup>1*</sup>, [Yuxuan Bian](https://scholar.google.com.hk/citations?user=HzemVzoAAAAJ&hl=zh-CN&oi=ao)<sup>2</sup>, [Ying Shan](https://www.linkedin.com/in/YingShanProfile/)<sup>1</sup>, [Qiang Xu](https://cure-lab.github.io/)<sup>2*</sup><br>
> <sup>1</sup>ARC Lab, Tencent PCG <sup>2</sup>The Chinese University of Hong Kong <sup>*</sup>Corresponding Author
<p align="center">
<a href="https://tencentarc.github.io/BrushNet/">Project Page</a> |
<a href="https://github.com/TencentARC/BrushNet">Code</a> |
<a href="https://arxiv.org/abs/2403.06976">Arxiv</a> |
<a href="https://forms.gle/9TgMZ8tm49UYsZ9s5">Data</a> |
<a href="https://drive.google.com/file/d/1IkEBWcd2Fui2WHcckap4QFPcCI0gkHBh/view">Video</a> |
</p>
## 🤝🏼 Cite Us
```
@misc{ju2024brushnet,
title={BrushNet: A Plug-and-Play Image Inpainting Model with Decomposed Dual-Branch Diffusion},
author={Xuan Ju and Xian Liu and Xintao Wang and Yuxuan Bian and Ying Shan and Qiang Xu},
year={2024},
eprint={2403.06976},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
```
## 💖 Acknowledgement
<span id="acknowledgement"></span>
Our code is modified based on [diffusers](https://github.com/huggingface/diffusers), thanks to all the contributors!