Python SDK for ImageGen
Project description
InstantLight-sdk
Installation
Install the SDK using pip:
pip install FAImageGen
Usage
Here’s an example of how to use the InstantLight SDK to make an API call and handle the response:
# InstantLight-sdk
## Installation
Install the SDK using pip:
```bash
pip install FAImageGen
Usage
Here’s an example of how to use the InstantLight SDK to make an API call and handle the response:
from ImageGen import ImageGen
from PIL import Image
import base64
from io import BytesIO
# Initialize the SDK
sdk = ImageGen(
base_url='https://api.fotographer.ai/Image-gen',
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
image_path = 'path_to_image.png'
prompt = 'your_prompt_here'
# Make the API call
response = sdk.image_generation.get_image_gen(image_path, prompt)
# 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.")
else:
print("Response does not contain 'image'")
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
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 FAImageGen-0.1.0.tar.gz.
File metadata
- Download URL: FAImageGen-0.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 |
9fcdb8f15ba3efb99df2b8fd1b0c33a85ef710215ac5420056b12bdfd8f0c3fd
|
|
| MD5 |
2ed4442511b892bfcb341786bdd610a3
|
|
| BLAKE2b-256 |
db94de35ed3ba41bd8efd92f4be2b78f7b20c1456bd580f6e5fc7a8f0d4d05fd
|
File details
Details for the file FAImageGen-0.1.0-py3-none-any.whl.
File metadata
- Download URL: FAImageGen-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 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 |
60a917a3caa27a3dbbd6afcb345c96567c4b7d7789ccba429a564cc514d30906
|
|
| MD5 |
ee0acac5f2e8c2d2fa6766065ee41137
|
|
| BLAKE2b-256 |
c4ceb166aec1f23be9f4742c1d8f12095905317dbe565fda3cc755d3e08443d5
|