!pip install diffusers --upgrade
zsh:1: command not found: pip
Modelex
October 12, 2023
Model type: Diffusion-based text-to-image generative model
Make sure to upgrade diffusers to >= 0.19.0:
In addition make sure to install transformers
, safetensors
, accelerate
as well as the invisible watermark:
Install torch:
Install io:
Inference API request:
token: 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
Generate image with prompt:
Astronaut riding a horse
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
image_bytes = query({
"inputs": "Astronaut riding a horse",
})
# You can access the image with PIL.Image for example
import io
from PIL import Image
image = Image.open(io.BytesIO(image_bytes))
image
Garfield on the moon
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
image_bytes = query({
"inputs": "Garfield on the moon",
})
# You can access the image with PIL.Image for example
import io
from PIL import Image
image = Image.open(io.BytesIO(image_bytes))
image
Minion at the grocery store
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
image_bytes = query({
"inputs": "Minion at the grocery store",
})
# You can access the image with PIL.Image for example
import io
from PIL import Image
image = Image.open(io.BytesIO(image_bytes))
image