imagepipeline 0.3.0__tar.gz
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.
- imagepipeline-0.3.0/.github/workflows/publish-sdk-python.yml +33 -0
- imagepipeline-0.3.0/.gitignore +29 -0
- imagepipeline-0.3.0/LICENSE +21 -0
- imagepipeline-0.3.0/PKG-INFO +280 -0
- imagepipeline-0.3.0/README.md +247 -0
- imagepipeline-0.3.0/imagepipeline/__init__.py +7 -0
- imagepipeline-0.3.0/imagepipeline/_transport.py +114 -0
- imagepipeline-0.3.0/imagepipeline/client.py +88 -0
- imagepipeline-0.3.0/imagepipeline/exceptions.py +45 -0
- imagepipeline-0.3.0/imagepipeline/models.py +111 -0
- imagepipeline-0.3.0/imagepipeline/py.typed +0 -0
- imagepipeline-0.3.0/imagepipeline/resources/__init__.py +23 -0
- imagepipeline-0.3.0/imagepipeline/resources/generate.py +179 -0
- imagepipeline-0.3.0/imagepipeline/resources/identity.py +334 -0
- imagepipeline-0.3.0/imagepipeline/resources/misc.py +468 -0
- imagepipeline-0.3.0/pyproject.toml +59 -0
- imagepipeline-0.3.0/tests/__init__.py +0 -0
- imagepipeline-0.3.0/tests/test_sdk.py +211 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
name: Publish Python SDK to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published] # triggers when you publish a GitHub Release
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build-and-publish:
|
|
9
|
+
name: Build and publish
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
environment:
|
|
13
|
+
name: pypi
|
|
14
|
+
url: https://pypi.org/p/imagepipeline
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
id-token: write # required for OIDC trusted publisher
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.11"
|
|
25
|
+
|
|
26
|
+
- name: Install build tool
|
|
27
|
+
run: pip install build
|
|
28
|
+
|
|
29
|
+
- name: Build
|
|
30
|
+
run: python -m build
|
|
31
|
+
|
|
32
|
+
- name: Publish to PyPI
|
|
33
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Build artifacts
|
|
2
|
+
dist/
|
|
3
|
+
build/
|
|
4
|
+
*.egg-info/
|
|
5
|
+
*.egg
|
|
6
|
+
wheels/
|
|
7
|
+
|
|
8
|
+
# Bytecode
|
|
9
|
+
__pycache__/
|
|
10
|
+
*.py[cod]
|
|
11
|
+
*$py.class
|
|
12
|
+
|
|
13
|
+
# Test / tooling caches
|
|
14
|
+
.pytest_cache/
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.ruff_cache/
|
|
17
|
+
.coverage
|
|
18
|
+
htmlcov/
|
|
19
|
+
.tox/
|
|
20
|
+
|
|
21
|
+
# Virtual environments
|
|
22
|
+
.venv/
|
|
23
|
+
venv/
|
|
24
|
+
env/
|
|
25
|
+
|
|
26
|
+
# Editor / OS
|
|
27
|
+
.idea/
|
|
28
|
+
.vscode/
|
|
29
|
+
.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Model Pipeline AI, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: imagepipeline
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: On-model imagery for fast brands. The image AI API for fashion and ecommerce.
|
|
5
|
+
Project-URL: Homepage, https://www.imagepipeline.io
|
|
6
|
+
Project-URL: Documentation, https://docs.imagepipeline.io
|
|
7
|
+
Project-URL: Book a demo, https://cal.com/imagepipeline/30min
|
|
8
|
+
Project-URL: Repository, https://github.com/Model-Pipelines/imagepipeline-python
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/Model-Pipelines/imagepipeline-python/issues
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,background removal,ecommerce,fashion,image editing,image generation,imagepipeline,on-model,sdk,virtual try-on
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Requires-Dist: requests>=2.28.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-mock>=3.10; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: responses>=0.23; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.1; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# imagepipeline
|
|
35
|
+
|
|
36
|
+
**On-model imagery for fast brands.**
|
|
37
|
+
|
|
38
|
+
ImagePipeline is the image AI API for fashion and ecommerce. Turn flat-lays into on-model shots, run virtual try-on, and relight backgrounds — from one API. No studio, no photoshoot.
|
|
39
|
+
|
|
40
|
+
[imagepipeline.io](https://www.imagepipeline.io) · [Book a demo](https://cal.com/imagepipeline/30min) · [Docs](https://docs.imagepipeline.io)
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install imagepipeline
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Requires Python 3.9+ and a free API key from [imagepipeline.io](https://www.imagepipeline.io).
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quick start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from imagepipeline import ImagePipeline
|
|
58
|
+
|
|
59
|
+
ip = ImagePipeline("ip_live_xxxxxxxxxxxx")
|
|
60
|
+
|
|
61
|
+
# Turn a flat-lay into an on-model shot
|
|
62
|
+
result = ip.generate.image(
|
|
63
|
+
prompt="fashion model wearing the product, white studio background, editorial lighting"
|
|
64
|
+
)
|
|
65
|
+
print(result.url)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Core use cases
|
|
71
|
+
|
|
72
|
+
### Virtual try-on
|
|
73
|
+
|
|
74
|
+
Dress a real person in any clothing item. Pass the model photo and the product image — ImagePipeline handles the compositing.
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
result = ip.identity.tryon(
|
|
78
|
+
person_image="https://cdn.example.com/model.jpg",
|
|
79
|
+
clothing_image="https://cdn.example.com/shirt.jpg",
|
|
80
|
+
gender="woman",
|
|
81
|
+
)
|
|
82
|
+
print(result.url)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Background replacement
|
|
86
|
+
|
|
87
|
+
Swap a flat studio background for any scene. The subject is automatically isolated — no masking required. Describe the subject so it's preserved cleanly.
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
result = ip.background.change(
|
|
91
|
+
input_image="https://cdn.example.com/product-shot.jpg",
|
|
92
|
+
prompt="minimal white marble surface, soft natural light",
|
|
93
|
+
subject_description="glass perfume bottle",
|
|
94
|
+
)
|
|
95
|
+
print(result.url)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Background removal
|
|
99
|
+
|
|
100
|
+
Cut out the subject as a transparent PNG, or recolor onto a flat background with an optional drop shadow.
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
# Transparent cutout
|
|
104
|
+
job = ip.background.remove(input_image="https://cdn.example.com/product.jpg")
|
|
105
|
+
print(job.cutout_url)
|
|
106
|
+
|
|
107
|
+
# Flat background + drop shadow
|
|
108
|
+
job = ip.background.remove(
|
|
109
|
+
input_image="https://cdn.example.com/product.jpg",
|
|
110
|
+
recolor="#FFFFFF",
|
|
111
|
+
drop_shadow=True,
|
|
112
|
+
)
|
|
113
|
+
print(job.url)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### On-model image generation
|
|
117
|
+
|
|
118
|
+
Generate consistent AI models with your brand's look and feel using identity profiles.
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
# Create a reusable brand model profile
|
|
122
|
+
profile = ip.identity.create_profile(
|
|
123
|
+
name="Campaign Model",
|
|
124
|
+
prompt_template="{{ user_prompt }}, Caucasian woman, late 20s, blue eyes, studio lighting",
|
|
125
|
+
seed_strategy="fixed",
|
|
126
|
+
fixed_seed=42,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# Generate on-model imagery with consistent identity
|
|
130
|
+
result = ip.generate.image(
|
|
131
|
+
prompt="wearing a navy linen blazer, white background",
|
|
132
|
+
profile_id=profile["profile_id"],
|
|
133
|
+
)
|
|
134
|
+
print(result.url)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Image editing
|
|
138
|
+
|
|
139
|
+
Edit product images with natural-language instructions.
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
result = ip.edit.image(
|
|
143
|
+
input_image="https://cdn.example.com/product.jpg",
|
|
144
|
+
prompt="remove the wrinkles from the fabric, keep everything else identical",
|
|
145
|
+
)
|
|
146
|
+
print(result.url)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Upload & edit
|
|
150
|
+
|
|
151
|
+
Upload local assets and use them directly in any editing workflow.
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
# Upload a flat-lay image
|
|
155
|
+
upload = ip.upload.image("flat-lay.jpg")
|
|
156
|
+
|
|
157
|
+
# Then use it as an edit input
|
|
158
|
+
result = ip.edit.image(
|
|
159
|
+
input_image=[upload.url, "https://cdn.example.com/model.jpg"],
|
|
160
|
+
prompt="put the model in the flat-lay clothing",
|
|
161
|
+
mask_segment="upper-clothes",
|
|
162
|
+
)
|
|
163
|
+
print(result.url)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Targeted editing with segmentation
|
|
167
|
+
|
|
168
|
+
Use segment detection to edit only the clothing — face, hair, and background stay pixel-perfect.
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
# Optional: preview what segments exist in the image
|
|
172
|
+
seg = ip.segment.image("https://cdn.example.com/model.jpg")
|
|
173
|
+
for s in seg.segments:
|
|
174
|
+
print(s.label, "→", s.display)
|
|
175
|
+
# upper-clothes → Top / Shirt
|
|
176
|
+
# pants → Pants
|
|
177
|
+
|
|
178
|
+
# Edit only the detected segment
|
|
179
|
+
result = ip.edit.image(
|
|
180
|
+
input_image=["https://cdn.example.com/model.jpg", "https://cdn.example.com/new-shirt.jpg"],
|
|
181
|
+
prompt="dress the model in the shirt from image 2",
|
|
182
|
+
mask_segment="upper-clothes", # face, background, pants unchanged
|
|
183
|
+
)
|
|
184
|
+
print(result.url)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Async & webhooks
|
|
190
|
+
|
|
191
|
+
All methods default to `wait=True` (blocks until the job completes). For high-throughput pipelines:
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
# Fire-and-forget — returns immediately
|
|
195
|
+
job = ip.generate.image(prompt="...", wait=False)
|
|
196
|
+
print(job.job_id)
|
|
197
|
+
|
|
198
|
+
# Poll manually when ready
|
|
199
|
+
completed = ip._transport.poll("generate/image/v1", job.job_id)
|
|
200
|
+
print(completed.url)
|
|
201
|
+
|
|
202
|
+
# Or use a webhook — we POST a WebhookEvent to your URL on completion
|
|
203
|
+
job = ip.identity.tryon(
|
|
204
|
+
person_image="https://...",
|
|
205
|
+
clothing_image="https://...",
|
|
206
|
+
callback_url="https://yourserver.com/hooks/imagepipeline",
|
|
207
|
+
wait=False,
|
|
208
|
+
)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Error handling
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
from imagepipeline.exceptions import (
|
|
217
|
+
AuthenticationError,
|
|
218
|
+
RateLimitError,
|
|
219
|
+
JobFailedError,
|
|
220
|
+
JobTimeoutError,
|
|
221
|
+
APIError,
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
try:
|
|
225
|
+
result = ip.generate.image(prompt="...")
|
|
226
|
+
except AuthenticationError:
|
|
227
|
+
print("Invalid API key — get one at imagepipeline.io")
|
|
228
|
+
except RateLimitError as e:
|
|
229
|
+
print(f"Rate limited — retry after {e.retry_after}s")
|
|
230
|
+
except JobFailedError as e:
|
|
231
|
+
print(f"Job {e.job_id} failed: {e.reason}")
|
|
232
|
+
except JobTimeoutError as e:
|
|
233
|
+
print(f"Timed out after {e.timeout}s")
|
|
234
|
+
except APIError as e:
|
|
235
|
+
print(f"HTTP {e.status_code}")
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## API reference
|
|
241
|
+
|
|
242
|
+
| Resource | Method | Description |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| `ip.generate` | `.image(prompt, ...)` | Text-to-image generation |
|
|
245
|
+
| `ip.generate` | `.video(input_image, ...)` | Image-to-video |
|
|
246
|
+
| `ip.generate` | `.speech(text, ...)` | Text-to-speech |
|
|
247
|
+
| `ip.generate` | `.generate_3d(image_path, ...)` | Image-to-3D mesh |
|
|
248
|
+
| `ip.edit` | `.image(prompt, input_image, ...)` | Instruction-based image editing |
|
|
249
|
+
| `ip.background` | `.change(input_image, prompt, subject_description, ...)` | Background replacement |
|
|
250
|
+
| `ip.background` | `.remove(input_image, recolor=None, ...)` | Background removal / cutout |
|
|
251
|
+
| `ip.upscale` | `.image(input_image, scale=4, ...)` | AI image enhancement / upscale |
|
|
252
|
+
| `ip.branding` | `.logo(input_image, logo_url, ...)` | Stamp a logo onto an image |
|
|
253
|
+
| `ip.branding` | `.template(input_image, ...)` | Brand Scene Composer (palette-matched background) |
|
|
254
|
+
| `ip.upload` | `.image(file)` | Upload an image, receive a URL |
|
|
255
|
+
| `ip.segment` | `.image(image_url)` | Detect segments for targeted editing |
|
|
256
|
+
| `ip.identity` | `.tryon(person_image, clothing_image, ...)` | Virtual try-on |
|
|
257
|
+
| `ip.identity` | `.faceswap(source, target, ...)` | Face swap |
|
|
258
|
+
| `ip.identity` | `.lock(input_image, prompt, ...)` | Identity-locked generation |
|
|
259
|
+
| `ip.identity` | `.replace(input_image, prompt, ...)` | Person/model replacement |
|
|
260
|
+
| `ip.identity` | `.instamodel(face_image, prompt, ...)` | Consistent AI model imagery |
|
|
261
|
+
| `ip.identity` | `.voice_clone(text, reference_voice_url, ...)` | Voice cloning |
|
|
262
|
+
| `ip.identity` | `.create_profile(name, ...)` | Create a reusable identity profile |
|
|
263
|
+
| `ip.identity` | `.list_profiles()` | List identity profiles |
|
|
264
|
+
| `ip.identity` | `.get_profile(profile_id)` | Fetch a profile |
|
|
265
|
+
| `ip.identity` | `.delete_profile(profile_id)` | Delete a profile |
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Requirements
|
|
270
|
+
|
|
271
|
+
- Python 3.9+
|
|
272
|
+
- `requests`
|
|
273
|
+
|
|
274
|
+
## License
|
|
275
|
+
|
|
276
|
+
MIT — see [LICENSE](LICENSE).
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
[imagepipeline.io](https://www.imagepipeline.io) · [Book a demo](https://cal.com/imagepipeline/30min) · [Docs](https://docs.imagepipeline.io)
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# imagepipeline
|
|
2
|
+
|
|
3
|
+
**On-model imagery for fast brands.**
|
|
4
|
+
|
|
5
|
+
ImagePipeline is the image AI API for fashion and ecommerce. Turn flat-lays into on-model shots, run virtual try-on, and relight backgrounds — from one API. No studio, no photoshoot.
|
|
6
|
+
|
|
7
|
+
[imagepipeline.io](https://www.imagepipeline.io) · [Book a demo](https://cal.com/imagepipeline/30min) · [Docs](https://docs.imagepipeline.io)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install imagepipeline
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Python 3.9+ and a free API key from [imagepipeline.io](https://www.imagepipeline.io).
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
from imagepipeline import ImagePipeline
|
|
25
|
+
|
|
26
|
+
ip = ImagePipeline("ip_live_xxxxxxxxxxxx")
|
|
27
|
+
|
|
28
|
+
# Turn a flat-lay into an on-model shot
|
|
29
|
+
result = ip.generate.image(
|
|
30
|
+
prompt="fashion model wearing the product, white studio background, editorial lighting"
|
|
31
|
+
)
|
|
32
|
+
print(result.url)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Core use cases
|
|
38
|
+
|
|
39
|
+
### Virtual try-on
|
|
40
|
+
|
|
41
|
+
Dress a real person in any clothing item. Pass the model photo and the product image — ImagePipeline handles the compositing.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
result = ip.identity.tryon(
|
|
45
|
+
person_image="https://cdn.example.com/model.jpg",
|
|
46
|
+
clothing_image="https://cdn.example.com/shirt.jpg",
|
|
47
|
+
gender="woman",
|
|
48
|
+
)
|
|
49
|
+
print(result.url)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Background replacement
|
|
53
|
+
|
|
54
|
+
Swap a flat studio background for any scene. The subject is automatically isolated — no masking required. Describe the subject so it's preserved cleanly.
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
result = ip.background.change(
|
|
58
|
+
input_image="https://cdn.example.com/product-shot.jpg",
|
|
59
|
+
prompt="minimal white marble surface, soft natural light",
|
|
60
|
+
subject_description="glass perfume bottle",
|
|
61
|
+
)
|
|
62
|
+
print(result.url)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Background removal
|
|
66
|
+
|
|
67
|
+
Cut out the subject as a transparent PNG, or recolor onto a flat background with an optional drop shadow.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
# Transparent cutout
|
|
71
|
+
job = ip.background.remove(input_image="https://cdn.example.com/product.jpg")
|
|
72
|
+
print(job.cutout_url)
|
|
73
|
+
|
|
74
|
+
# Flat background + drop shadow
|
|
75
|
+
job = ip.background.remove(
|
|
76
|
+
input_image="https://cdn.example.com/product.jpg",
|
|
77
|
+
recolor="#FFFFFF",
|
|
78
|
+
drop_shadow=True,
|
|
79
|
+
)
|
|
80
|
+
print(job.url)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### On-model image generation
|
|
84
|
+
|
|
85
|
+
Generate consistent AI models with your brand's look and feel using identity profiles.
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# Create a reusable brand model profile
|
|
89
|
+
profile = ip.identity.create_profile(
|
|
90
|
+
name="Campaign Model",
|
|
91
|
+
prompt_template="{{ user_prompt }}, Caucasian woman, late 20s, blue eyes, studio lighting",
|
|
92
|
+
seed_strategy="fixed",
|
|
93
|
+
fixed_seed=42,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
# Generate on-model imagery with consistent identity
|
|
97
|
+
result = ip.generate.image(
|
|
98
|
+
prompt="wearing a navy linen blazer, white background",
|
|
99
|
+
profile_id=profile["profile_id"],
|
|
100
|
+
)
|
|
101
|
+
print(result.url)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Image editing
|
|
105
|
+
|
|
106
|
+
Edit product images with natural-language instructions.
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
result = ip.edit.image(
|
|
110
|
+
input_image="https://cdn.example.com/product.jpg",
|
|
111
|
+
prompt="remove the wrinkles from the fabric, keep everything else identical",
|
|
112
|
+
)
|
|
113
|
+
print(result.url)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Upload & edit
|
|
117
|
+
|
|
118
|
+
Upload local assets and use them directly in any editing workflow.
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
# Upload a flat-lay image
|
|
122
|
+
upload = ip.upload.image("flat-lay.jpg")
|
|
123
|
+
|
|
124
|
+
# Then use it as an edit input
|
|
125
|
+
result = ip.edit.image(
|
|
126
|
+
input_image=[upload.url, "https://cdn.example.com/model.jpg"],
|
|
127
|
+
prompt="put the model in the flat-lay clothing",
|
|
128
|
+
mask_segment="upper-clothes",
|
|
129
|
+
)
|
|
130
|
+
print(result.url)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Targeted editing with segmentation
|
|
134
|
+
|
|
135
|
+
Use segment detection to edit only the clothing — face, hair, and background stay pixel-perfect.
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
# Optional: preview what segments exist in the image
|
|
139
|
+
seg = ip.segment.image("https://cdn.example.com/model.jpg")
|
|
140
|
+
for s in seg.segments:
|
|
141
|
+
print(s.label, "→", s.display)
|
|
142
|
+
# upper-clothes → Top / Shirt
|
|
143
|
+
# pants → Pants
|
|
144
|
+
|
|
145
|
+
# Edit only the detected segment
|
|
146
|
+
result = ip.edit.image(
|
|
147
|
+
input_image=["https://cdn.example.com/model.jpg", "https://cdn.example.com/new-shirt.jpg"],
|
|
148
|
+
prompt="dress the model in the shirt from image 2",
|
|
149
|
+
mask_segment="upper-clothes", # face, background, pants unchanged
|
|
150
|
+
)
|
|
151
|
+
print(result.url)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Async & webhooks
|
|
157
|
+
|
|
158
|
+
All methods default to `wait=True` (blocks until the job completes). For high-throughput pipelines:
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
# Fire-and-forget — returns immediately
|
|
162
|
+
job = ip.generate.image(prompt="...", wait=False)
|
|
163
|
+
print(job.job_id)
|
|
164
|
+
|
|
165
|
+
# Poll manually when ready
|
|
166
|
+
completed = ip._transport.poll("generate/image/v1", job.job_id)
|
|
167
|
+
print(completed.url)
|
|
168
|
+
|
|
169
|
+
# Or use a webhook — we POST a WebhookEvent to your URL on completion
|
|
170
|
+
job = ip.identity.tryon(
|
|
171
|
+
person_image="https://...",
|
|
172
|
+
clothing_image="https://...",
|
|
173
|
+
callback_url="https://yourserver.com/hooks/imagepipeline",
|
|
174
|
+
wait=False,
|
|
175
|
+
)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Error handling
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from imagepipeline.exceptions import (
|
|
184
|
+
AuthenticationError,
|
|
185
|
+
RateLimitError,
|
|
186
|
+
JobFailedError,
|
|
187
|
+
JobTimeoutError,
|
|
188
|
+
APIError,
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
try:
|
|
192
|
+
result = ip.generate.image(prompt="...")
|
|
193
|
+
except AuthenticationError:
|
|
194
|
+
print("Invalid API key — get one at imagepipeline.io")
|
|
195
|
+
except RateLimitError as e:
|
|
196
|
+
print(f"Rate limited — retry after {e.retry_after}s")
|
|
197
|
+
except JobFailedError as e:
|
|
198
|
+
print(f"Job {e.job_id} failed: {e.reason}")
|
|
199
|
+
except JobTimeoutError as e:
|
|
200
|
+
print(f"Timed out after {e.timeout}s")
|
|
201
|
+
except APIError as e:
|
|
202
|
+
print(f"HTTP {e.status_code}")
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## API reference
|
|
208
|
+
|
|
209
|
+
| Resource | Method | Description |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| `ip.generate` | `.image(prompt, ...)` | Text-to-image generation |
|
|
212
|
+
| `ip.generate` | `.video(input_image, ...)` | Image-to-video |
|
|
213
|
+
| `ip.generate` | `.speech(text, ...)` | Text-to-speech |
|
|
214
|
+
| `ip.generate` | `.generate_3d(image_path, ...)` | Image-to-3D mesh |
|
|
215
|
+
| `ip.edit` | `.image(prompt, input_image, ...)` | Instruction-based image editing |
|
|
216
|
+
| `ip.background` | `.change(input_image, prompt, subject_description, ...)` | Background replacement |
|
|
217
|
+
| `ip.background` | `.remove(input_image, recolor=None, ...)` | Background removal / cutout |
|
|
218
|
+
| `ip.upscale` | `.image(input_image, scale=4, ...)` | AI image enhancement / upscale |
|
|
219
|
+
| `ip.branding` | `.logo(input_image, logo_url, ...)` | Stamp a logo onto an image |
|
|
220
|
+
| `ip.branding` | `.template(input_image, ...)` | Brand Scene Composer (palette-matched background) |
|
|
221
|
+
| `ip.upload` | `.image(file)` | Upload an image, receive a URL |
|
|
222
|
+
| `ip.segment` | `.image(image_url)` | Detect segments for targeted editing |
|
|
223
|
+
| `ip.identity` | `.tryon(person_image, clothing_image, ...)` | Virtual try-on |
|
|
224
|
+
| `ip.identity` | `.faceswap(source, target, ...)` | Face swap |
|
|
225
|
+
| `ip.identity` | `.lock(input_image, prompt, ...)` | Identity-locked generation |
|
|
226
|
+
| `ip.identity` | `.replace(input_image, prompt, ...)` | Person/model replacement |
|
|
227
|
+
| `ip.identity` | `.instamodel(face_image, prompt, ...)` | Consistent AI model imagery |
|
|
228
|
+
| `ip.identity` | `.voice_clone(text, reference_voice_url, ...)` | Voice cloning |
|
|
229
|
+
| `ip.identity` | `.create_profile(name, ...)` | Create a reusable identity profile |
|
|
230
|
+
| `ip.identity` | `.list_profiles()` | List identity profiles |
|
|
231
|
+
| `ip.identity` | `.get_profile(profile_id)` | Fetch a profile |
|
|
232
|
+
| `ip.identity` | `.delete_profile(profile_id)` | Delete a profile |
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Requirements
|
|
237
|
+
|
|
238
|
+
- Python 3.9+
|
|
239
|
+
- `requests`
|
|
240
|
+
|
|
241
|
+
## License
|
|
242
|
+
|
|
243
|
+
MIT — see [LICENSE](LICENSE).
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
[imagepipeline.io](https://www.imagepipeline.io) · [Book a demo](https://cal.com/imagepipeline/30min) · [Docs](https://docs.imagepipeline.io)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""ImagePipeline Python SDK"""
|
|
2
|
+
|
|
3
|
+
from .client import ImagePipeline
|
|
4
|
+
from .models import Job, JobStatus, SegmentItem, SegmentResult, UploadResult
|
|
5
|
+
|
|
6
|
+
__all__ = ["ImagePipeline", "Job", "JobStatus", "UploadResult", "SegmentItem", "SegmentResult"]
|
|
7
|
+
__version__ = "0.3.0"
|