Skip to main content

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")

Release files for tryonai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tryonai 0.1.0
File Size Uploaded
tryonai-0.1.0.tar.gz 3.6 kB Details

Release files / tryonai-0.1.0.tar.gz

Download URL tryonai-0.1.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
311315309d114599c3d57f4bf4c54dd7f0697c922b89bfec0ba625f91eb9f4c6
BLAKE2b-256 checksum
How to use checksums
3855dfd1a371fe09655790aebdeac668ed7d92d8623be1a2d5a5ee8a7a6d7ea1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page