Image Processing Models
We provide a set of image generating and processing model for the ease of use.
If there are models you'd like to try out and not available yet, free free to let us know by contacting us or submitting an issue on Github.
SDXL Model
Stable Diffusion XL for image generation. You may use this model to generate images from a prompt.
Usage
from leptonai.client import Client
c = Client("https://sdxl.lepton.run", token="YOUR_LEPTON_API_TOKEN")
image = c.run(
prompt="Astronaut on Mars During sunset",
height=1024,
width=1024,
guidance_scale=5,
high_noise_frac=0.75,
seed=1809774958,
steps=30,
use_refiner=False
)
with open('output_image.png', 'wb') as f:
f.write(image)
print("Image saved as output_image.png")
Artistic Text generation
Generate artistic text from a string.
Usage
from leptonai.client import Client
import base64
c = Client("https://aiqr.lepton.run", token="YOUR_LEPTON_API_TOKEN")
# List available models
print("==== Available models ====")
models = c.models()
model = models[0]
print("= Generate Control Image =")
control_image=c.art_text(
text="string" # Chage it to your text
)
listOfImageBase64 = c.generate(
control_image=control_image,
prompt="a architectural drawing of a new town square for Cambridge England, big traditional musuem with columns, fountain in middle, classical design, traditional design, trees",
model=model,
control_image_ratio=0.75,
control_weight=0.9,
guidance_start=0.3,
guidance_end=0.95,
seed=-1,
steps=30,
cfg_scale=7
)
for idx, imageBase64 in enumerate(listOfImageBase64):
with open(f'output_art_qrcode_image_{idx}.png', 'wb') as f:
f.write(base64.b64decode(imageBase64))
print(f"Image saved as output_image_{idx}.png")
QR Code generation
Generate QR Code from a prompt of a control_image and a web URL.
Usage
from leptonai.client import Client
import base64
c = Client("https://aiqr.lepton.run", token="YOUR_LEPTON_API_TOKEN")
# List available models
print("==== Available models ====")
models = c.models()
model = models[0]
print("= Generate Control Image =")
control_image=c.qrcode(
text="string"
)
listOfImageBase64 = c.generate(
control_image=control_image,
prompt="a architectural drawing of a new town square for Cambridge England, big traditional musuem with columns, fountain in middle, classical design, traditional design, trees",
model=model,
control_image_ratio=0.75,
control_weight=0.9,
guidance_start=0.3,
guidance_end=0.95,
seed=-1,
steps=30,
cfg_scale=7
)
for idx, imageBase64 in enumerate(listOfImageBase64):
with open(f'output_art_qrcode_image_{idx}.png', 'wb') as f:
f.write(base64.b64decode(imageBase64))
print(f"Image saved as output_image_{idx}.png")