Skip to content

Commit

Permalink
remove api doc in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
continue-revolution committed Apr 28, 2023
1 parent 91d23c5 commit d939fe1
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,55 +179,6 @@ Mask by Category batch demo
| --- | --- | --- | --- |
| ![1NHa6Wc](https://user-images.githubusercontent.com/63914308/234085498-70ca1d4c-cc5a-44d4-adb2-366630e5ce24.png) | ![1NHa6Wc_0_output](https://user-images.githubusercontent.com/63914308/234085495-0bfc4114-3e81-4ace-81d6-0f0f3186df25.png) | ![1NHa6Wc_0_mask](https://user-images.githubusercontent.com/63914308/234085491-8976f46c-2617-47ee-968e-0a9dd479c63a.png) | ![1NHa6Wc_0_blend](https://user-images.githubusercontent.com/63914308/234085503-7e041373-39cd-4f20-8696-986be517f188.png)

## API Support

### API Usage

We have added an API endpoint to allow for automated workflows.

The API utilizes both Segment Anything and GroundingDINO to return masks of all instances of whatever object is specified in the text prompt.

This is an extension of the existing [Stable Diffusion WebUI API](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API).

There are 2 endpoints exposed
- GET `/sam-webui/heartbeat`
- POST `/sam-webui/image-mask`

The heartbeat endpoint can be used to ensure that the API is up.

The image-mask endpoint accepts a payload that includes your base64-encoded image.

Below is an example of how to interface with the API using requests.

### API Example

```
import base64
import requests
from PIL import Image
from io import BytesIO
url = "http://127.0.0.1:7860/sam-webui/image-mask"
def image_to_base64(img_path: str) -> str:
with open(img_path, "rb") as img_file:
img_base64 = base64.b64encode(img_file.read()).decode()
return img_base64
payload = {
"image": image_to_base64("IMAGE_FILE_PATH"),
"prompt": "TEXT PROMPT",
"box_threshold": 0.3,
"padding": 30 #Optional param to pad masks
}
res = requests.post(url, json=payload)
for dct in res.json():
image_data = base64.b64decode(dct['image'])
image = Image.open(BytesIO(image_data))
image.show()
```

## Contribute

Disclaimer: I have not thoroughly tested this extension, so there might be bugs. Bear with me while I'm fixing them :)
Expand Down

0 comments on commit d939fe1

Please sign in to comment.