tryiton 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/lib/tryiton/client.rb +10 -4
- data/lib/tryiton/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '097cafef70c6dc514c07c210bab0ab6f14689de7dc2ad4a66117009e159831c6'
|
|
4
|
+
data.tar.gz: 814198bb65bfc55761267344ea53e35a334b02d19f5e92e6e0a79830c22373d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ffe674da6cc6caf4b03fd11e2cf4c9ba85c5c8ffec4f580bc657e3b62bfb4c7c8c5ff7d9c2ca44b14c5e845cd143badc28b5809a99f2242d7036c2cbc9130bc4
|
|
7
|
+
data.tar.gz: 9c905fe3606de104c25ff63ca180c6579c29ce334b4d4453ef176414faac2055a0011e3e1204acc4c1e51109905ae7116a0c7249630fa0afa4d74f568bfd65dc
|
data/README.md
CHANGED
|
@@ -32,7 +32,7 @@ require "tryiton"
|
|
|
32
32
|
client = Tryiton::Client.new(api_key: ENV["TRYITON_API_KEY"])
|
|
33
33
|
|
|
34
34
|
# Submit a clothing try-on
|
|
35
|
-
job_id = client.
|
|
35
|
+
job_id = client.try_on_fashion(
|
|
36
36
|
model_image: "https://example.com/model.jpg",
|
|
37
37
|
garment_image: "https://example.com/tshirt.jpg",
|
|
38
38
|
category: "clothing",
|
|
@@ -48,7 +48,7 @@ Image inputs accept a public URL or a base64 data URL (`data:image/png;base64,..
|
|
|
48
48
|
|
|
49
49
|
## Core parameters
|
|
50
50
|
|
|
51
|
-
`
|
|
51
|
+
`try_on_fashion` covers clothing and accessory try-on. The most important parameters:
|
|
52
52
|
|
|
53
53
|
| Parameter | Type | Required | Description |
|
|
54
54
|
| --------- | ---- | -------- | ----------- |
|
|
@@ -65,8 +65,10 @@ Additional options (`mode` and `moderation_level` for clothing; `num_samples` 1
|
|
|
65
65
|
# Hairstyle try-on (see Tryiton::HAIRCUTS for all supported values)
|
|
66
66
|
client.try_on_hairstyle(face_image: face_url, haircut: "BuzzCut", hair_color: "ash blonde")
|
|
67
67
|
|
|
68
|
-
# Tattoo try-on
|
|
68
|
+
# Tattoo try-on — place it with free text...
|
|
69
69
|
client.try_on_tattoo(body_image: body_url, design_image: design_url, placement: "on the right forearm, small")
|
|
70
|
+
# ...or pin the exact spot with a region box (normalized 0-1, from the image's top-left)
|
|
71
|
+
client.try_on_tattoo(body_image: body_url, design_image: design_url, region: { x: 0.32, y: 0.18, w: 0.28, h: 0.34 })
|
|
70
72
|
|
|
71
73
|
# Poll a job manually, or check your credit balance
|
|
72
74
|
status = client.get_status(job_id) # { "status" => ..., "output" => [...], "error" => ... }
|
|
@@ -79,7 +81,7 @@ All failures raise `Tryiton::Error`, which carries the HTTP status code and the
|
|
|
79
81
|
|
|
80
82
|
```ruby
|
|
81
83
|
begin
|
|
82
|
-
client.
|
|
84
|
+
client.try_on_fashion(...)
|
|
83
85
|
rescue Tryiton::Error => e
|
|
84
86
|
puts "#{e.status} #{e.error_name} #{e.message}" # e.g. 429 OutOfCredits
|
|
85
87
|
end
|
data/lib/tryiton/client.rb
CHANGED
|
@@ -31,7 +31,7 @@ module Tryiton
|
|
|
31
31
|
# Client for the TryItOn virtual try-on API.
|
|
32
32
|
#
|
|
33
33
|
# client = Tryiton::Client.new(api_key: ENV["TRYITON_API_KEY"])
|
|
34
|
-
# job_id = client.
|
|
34
|
+
# job_id = client.try_on_fashion(
|
|
35
35
|
# model_image: "https://example.com/model.jpg",
|
|
36
36
|
# garment_image: "https://example.com/tshirt.jpg",
|
|
37
37
|
# category: "clothing", subcategory: "tops"
|
|
@@ -54,8 +54,8 @@ module Tryiton
|
|
|
54
54
|
# Keys: model_image (required), garment_image (required), category,
|
|
55
55
|
# subcategory, mode, num_samples (1-4), output_format ("png"/"jpeg"),
|
|
56
56
|
# moderation_level ("conservative"/"permissive"/"none").
|
|
57
|
-
def
|
|
58
|
-
request(:post, "/tryon/
|
|
57
|
+
def try_on_fashion(**params)
|
|
58
|
+
request(:post, "/tryon/fashion", params)["jobId"]
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# Restyle a person's hair. Returns the job id.
|
|
@@ -66,8 +66,14 @@ module Tryiton
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# Ink a design onto skin. Returns the job id.
|
|
69
|
-
# Keys: body_image (required), design_image (required), placement,
|
|
69
|
+
# Keys: body_image (required), design_image (required), placement, region,
|
|
70
70
|
# num_samples (1-4), output_format ("png"/"jpeg").
|
|
71
|
+
#
|
|
72
|
+
# Position the ink two ways, and they compose: +placement+ is free text
|
|
73
|
+
# ("on the right forearm, small"); +region+ pins the exact spot as
|
|
74
|
+
# { x:, y:, w:, h: }, normalized 0-1 from the body image's top-left corner,
|
|
75
|
+
# each side at least 0.06. With a region, +placement+ only describes
|
|
76
|
+
# size/style.
|
|
71
77
|
def try_on_tattoo(**params)
|
|
72
78
|
request(:post, "/tryon/tattoo", params)["jobId"]
|
|
73
79
|
end
|
data/lib/tryiton/version.rb
CHANGED