2.64 TB
1,834 files
Updated 23 days ago
Ctrl+K
| Name | Size | Uploaded | Xet hash |
|---|---|---|---|
| scheduler | 1 items | ||
| text_encoder | 2 items | ||
| tokenizer | 4 items | ||
| unet | 2 items | ||
| vae | 2 items | ||
| .gitattributes | 1.48 kB xet | b4195e66 | |
| README.md | 2.9 kB xet | 6e891156 | |
| Stable Diffusion Inference endpoints - inpainting.png | 220 kB xet | 705fcc2b | |
| create_handler.ipynb | 1.09 MB xet | dc2bf7f7 | |
| dog.png | 405 kB xet | 9e04038f | |
| handler.py | 2.59 kB xet | 57938c73 | |
| mask_dog.png | 12.1 kB xet | 971a7085 | |
| model_index.json | 519 Bytes xet | a6f7df1d | |
| result.png | 402 kB xet | aefba48f |
Fork of stabilityai/stable-diffusion-2-inpainting
Stable Diffusion is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input. For more information about how Stable Diffusion functions, please have a look at 🤗's Stable Diffusion with 🧨Diffusers blog.
For more information about the model, license and limitations check the original model card at stabilityai/stable-diffusion-2-inpainting.
This repository implements a custom handler task for text-guided-to-image-inpainting for 🤗 Inference Endpoints. The code for the customized pipeline is in the handler.py.
There is also a notebook included, on how to create the handler.py
expected Request payload
{
"inputs": "A prompt used for image generation",
"image" : "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAABGdBTUEAALGPC",
"mask_image": "iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAAABGdBTUEAALGPC",
}
below is an example on how to run a request using Python and requests.
Run Request
import json
from typing import List
import requests as r
import base64
from PIL import Image
from io import BytesIO
ENDPOINT_URL = ""
HF_TOKEN = ""
# helper image utils
def encode_image(image_path):
with open(image_path, "rb") as i:
b64 = base64.b64encode(i.read())
return b64.decode("utf-8")
def predict(prompt, image, mask_image):
image = encode_image(image)
mask_image = encode_image(mask_image)
# prepare sample payload
request = {"inputs": prompt, "image": image, "mask_image": mask_image}
# headers
headers = {
"Authorization": f"Bearer {HF_TOKEN}",
"Content-Type": "application/json",
"Accept": "image/png" # important to get an image back
}
response = r.post(ENDPOINT_URL, headers=headers, json=payload)
img = Image.open(BytesIO(response.content))
return img
prediction = predict(
prompt="Face of a bengal cat, high resolution, sitting on a park bench",
image="dog.png",
mask_image="mask_dog.png"
)
expected output
- Total size
- 2.64 TB
- Files
- 1,834
- Last updated
- Jun 16
- Pre-warmed CDN
- US EU US EU

