TryOn AI Python SDK - Use this SDK to interact with TryOn AI API. Integrate virtual try-on, model swap, outfit generation and captioning in your application.
Project description
TryOn AI Python SDK
Use this SDK to interact with TryOn AI API. Integrate virtual try-on, model swap, outfit generation and captioning in your application.
Installation
pip install tryonai
Environment Variables
export TRYONAI_SERVER_URL=https://prod.server.tryonlabs.ai
export TRYONAI_EMAIL=your_email@example.com
export TRYONAI_PASSWORD=your_password
Usage
Get access token
from tryonai import get_access_token
# Get access token
access_token = get_access_token(email=os.getenv('TRYONAI_EMAIL'), password=os.getenv('TRYONAI_PASSWORD'))
print("access_token:", access_token)
Upload Image
from tryonai import upload_image
# Upload image
uploaded_image = upload_image(image_path="data/garment.jpg", data={"type": "garment", "gender": "male", "preprocess": "true"}, access_token=access_token)
print("uploaded_image:", uploaded_image)
Virtual Try On
from tryonai import perform_virtual_try_on
# Perform virtual try on
experiment = perform_virtual_try_on(garment_id=garment_id, person_id=person_id)
print("experiment:", experiment)
Model Swap
from tryonai import perform_model_swap
# Perform model swap
experiment = perform_model_swap(garment_id=garment_id, params={"prompt": "Indian male model with straight hair, blue eyes, round face, 4k resolution, high-resolution", "guidance_scale": 4.5, "num_inference_steps": 30, "seed":-1, "num_images": 3, "width":512, "height": 512})
print("experiment:", experiment)
Outfit Generation
from tryonai import generate_outfit
# Generate outfit
experiment = generate_outfit(params={"prompt": "A flat lay image of a T-shirt, round neck, blue color, high-resolution, 4k resolution", "height":256, "width": 256, "seed": -1, "guidance_scale": 4.5, "num_inference_steps": 20, "num_images_per_prompt": 2, "strength": 0.8})
print("experiment:", experiment)
Outfit Captioning
from tryonai import caption_outfit
# Caption outfit
experiment = caption_outfit(garment_id=garment_id, params={"output_format": "text"})
print("experiment:", experiment)
Get Experiment
from tryonai import get_experiment
# Get experiment
experiment = get_experiment(experiment_id=experiment_id)
print("experiment:", experiment)
Download Image
from tryonai import download_image
# Download image
download_image(image_url=experiment_result_image_url, image_path="data/result.png")
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
tryonai-0.1.0.tar.gz
(3.6 kB
view details)
File details
Details for the file tryonai-0.1.0.tar.gz.
File metadata
- Download URL: tryonai-0.1.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
311315309d114599c3d57f4bf4c54dd7f0697c922b89bfec0ba625f91eb9f4c6
|
|
| MD5 |
862ff71eac8318f0a2971a8623cc8547
|
|
| BLAKE2b-256 |
3855dfd1a371fe09655790aebdeac668ed7d92d8623be1a2d5a5ee8a7a6d7ea1
|