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
.
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 importListimport requests as r
import base64
from PIL import Image
from io import BytesIO
ENDPOINT_URL = ""
HF_TOKEN = ""# helper image utilsdefencode_image(image_path):
withopen(image_path, "rb") as i:
b64 = base64.b64encode(i.read())
return b64.decode("utf-8")
defpredict(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
Runs of philschmid stable-diffusion-2-inpainting-endpoint on huggingface.co
61
Total runs
1
24-hour runs
-5
3-day runs
24
7-day runs
40
30-day runs
More Information About stable-diffusion-2-inpainting-endpoint huggingface.co Model
More stable-diffusion-2-inpainting-endpoint license Visit here:
stable-diffusion-2-inpainting-endpoint huggingface.co is an AI model on huggingface.co that provides stable-diffusion-2-inpainting-endpoint's model effect (), which can be used instantly with this philschmid stable-diffusion-2-inpainting-endpoint model. huggingface.co supports a free trial of the stable-diffusion-2-inpainting-endpoint model, and also provides paid use of the stable-diffusion-2-inpainting-endpoint. Support call stable-diffusion-2-inpainting-endpoint model through api, including Node.js, Python, http.
stable-diffusion-2-inpainting-endpoint huggingface.co is an online trial and call api platform, which integrates stable-diffusion-2-inpainting-endpoint's modeling effects, including api services, and provides a free online trial of stable-diffusion-2-inpainting-endpoint, you can try stable-diffusion-2-inpainting-endpoint online for free by clicking the link below.
philschmid stable-diffusion-2-inpainting-endpoint online free url in huggingface.co:
stable-diffusion-2-inpainting-endpoint is an open source model from GitHub that offers a free installation service, and any user can find stable-diffusion-2-inpainting-endpoint on GitHub to install. At the same time, huggingface.co provides the effect of stable-diffusion-2-inpainting-endpoint install, users can directly use stable-diffusion-2-inpainting-endpoint installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
stable-diffusion-2-inpainting-endpoint install url in huggingface.co: