File size: 1,513 Bytes
3762a22 68a5125 3762a22 4140515 3762a22 4140515 add5a0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
---
library_name: diffusers
tags:
- stable-diffusion-3.5
- diffusers
- text-to-image
- endpoints-template
inference: false
---
> [!IMPORTANT]
> This repo duplicates the [Stable Diffusion 3.5 Large](https://huggingface.co/stabilityai/stable-diffusion-3.5-large) weights for demonstration purposes and it doesn't own any credits to the model. So, please be mindful of that and respect the original license of the model.
```py
from handler import EndpointHandler
my_handler = EndpointHandler()
payload = {"inputs": {"prompt": "a dog waiting for its companion to come."}}
# test the handler
image = my_handler(payload)
image.save("image.png")
```
![](./image.png)
We can use this repo to deploy SD3.5 Large on [Inference Endpoints](https://huggingface.co/docs/inference-endpoints) as well.
```py
import json
import requests
import base64
from PIL import Image
from io import BytesIO
ENDPOINT_URL = ""
HF_TOKEN = ""
def decode_base64_image(image_string):
base64_image = base64.b64decode(image_string)
buffer = BytesIO(base64_image)
return Image.open(buffer).save("image.png")
def predict(prompt: str = "a dog waiting for its companion to come."):
payload = {"inputs": {"prompt": prompt}}
response = requests.post(ENDPOINT_URL, headers={"Authorization": f"Bearer {HF_TOKEN}"}, json=payload)
resp = response.json()
return decode_base64_image(resp)
prediction = predict(prompt="the first animal on the mars")
```
This is how the final image would look like:
![](./ie_image.png) |