Python SDK for InstantLight
Project description
InstantLight-sdk
Installation
Install the SDK using pip:
pip install InstantLight
Usage
Here’s an example of how to use the InstantLight SDK to make an API call and handle the response:
from InstantLight.sdk import InstantLightSDK
from PIL import Image
import base64
from io import BytesIO
# Initialize the SDK
sdk = YourSDK(
base_url='https://api.instantlight.example.com',
api_key='your_api_key',
email='your_email@example.com'
)
# Convert images to base64
def image_to_base64(image_path):
with Image.open(image_path) as img:
buffered = BytesIO()
img.save(buffered, format="PNG")
return base64.b64encode(buffered.getvalue()).decode('utf-8')
# Prepare the image data
foreground_image64 = image_to_base64('path_to_foreground_image.png')
background_image64 = image_to_base64('path_to_background_image.png')
# Define the image data
image_data = {
"foreground_image64": foreground_image64,
"background_image64": background_image64,
"prompt": "example prompt",
"mode": 2,
"prompt_strength": 0.8,
"inf_factor": 1.00,
"mask_strength": 0.5,
"image_width": 1400,
"image_height": 1400,
"additional_prompt": "",
"negative_prompt": "",
"lights": []
}
# Make the API call
response = sdk.image_generation.get_image_gen(image_data)
# Print the response keys for debugging
print("Response Keys:", response.keys())
# Print the keys at all levels of the response for debugging
for key, value in response.items():
if isinstance(value, dict):
print(f"Response[{key}] Keys: {value.keys()}")
# Save the image and mask image if they exist in the response
if 'image' in response:
image_data = response['image']
image_bytes = base64.b64decode(image_data)
image = Image.open(BytesIO(image_bytes))
image.save("output_image.png")
print("Image retrieved and saved as output_image.png.")
if 'mask_image' in response:
mask_data = response['mask_image']
mask_bytes = base64.b64decode(mask_data)
mask_image = Image.open(BytesIO(mask_bytes))
mask_image.save("output_mask_image.png")
print("Mask retrieved and saved as output_mask_image.png.")
else:
print("Response does not contain 'image'")
Replace your_api_key and your_email@example.com with your actual API key and email.
Make sure to update your_api_key and your_email@example.com with the actual values in the example usage section.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
InstantLight-1.1.0.tar.gz
(4.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file InstantLight-1.1.0.tar.gz.
File metadata
- Download URL: InstantLight-1.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
238c9845d741bb46a17d022f9161eade940aad827a67af5bc384a288d8950c06
|
|
| MD5 |
943a9d84fac0445f166b7beb52ba8a79
|
|
| BLAKE2b-256 |
a6b45720955cc2812715c128a5313611c537aeb9e9a7aedd953459b358c9a00e
|
File details
Details for the file InstantLight-1.1.0-py3-none-any.whl.
File metadata
- Download URL: InstantLight-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0ba77573330f8add0f50de0c4450276dc9cb3443f7c73aa2cf0e7a6c03165e8
|
|
| MD5 |
f8c0be9949cd10a0813f7868e239f9ed
|
|
| BLAKE2b-256 |
94b244461394ee2651709f870e3c45d74dbbb24c9789e5300f56156636086717
|