Louu007 commited on
Commit
f7ed7b2
·
verified ·
1 Parent(s): 8ed967d

Upload 72 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +39 -35
  2. .gitignore +149 -0
  3. README.md +29 -12
  4. app.py +291 -0
  5. docs/API.md +341 -0
  6. docs/images/accessory_result_01.jpg +3 -0
  7. docs/images/avatar_image_01.jpg +3 -0
  8. docs/images/avatar_image_02.jpg +3 -0
  9. docs/images/avatar_image_03.jpg +3 -0
  10. docs/images/avatar_image_04.jpg +3 -0
  11. docs/images/avatar_modification_result_01.jpg +3 -0
  12. docs/images/avatar_modification_result_02.jpg +3 -0
  13. docs/images/avatar_prompt_result_01.jpg +3 -0
  14. docs/images/avatar_prompt_result_02.jpg +3 -0
  15. docs/images/avatar_prompt_result_03.jpg +3 -0
  16. docs/images/background_image_01.jpg +3 -0
  17. docs/images/background_image_02.jpg +3 -0
  18. docs/images/background_image_03.jpg +3 -0
  19. docs/images/background_image_04.jpg +3 -0
  20. docs/images/clothing_image_01.jpg +3 -0
  21. docs/images/clothing_image_02.jpg +3 -0
  22. docs/images/clothing_image_03.jpg +3 -0
  23. docs/images/clothing_image_04.jpg +3 -0
  24. docs/images/clothing_prompt_result_01.jpg +3 -0
  25. docs/images/clothing_prompt_result_02.jpg +3 -0
  26. docs/images/image_based_background_result_01.jpg +3 -0
  27. docs/images/image_based_background_result_02.jpg +3 -0
  28. docs/images/image_based_result_01.jpg +3 -0
  29. docs/images/new_background_result_01.jpg +3 -0
  30. docs/images/same_crop_result_01.jpg +3 -0
  31. docs/images/same_crop_result_02.jpg +3 -0
  32. docs/images/txt2img_result_01.jpg +3 -0
  33. docs/images/txt2img_result_02.jpg +3 -0
  34. examples/avatar/female_01.jpg +3 -0
  35. examples/avatar/female_02.jpg +3 -0
  36. examples/avatar/female_03.jpg +3 -0
  37. examples/avatar/female_04.jpg +3 -0
  38. examples/avatar/female_05.jpg +3 -0
  39. examples/avatar/female_06.jpg +3 -0
  40. examples/avatar/male_01.jpg +3 -0
  41. examples/avatar/male_02.jpg +3 -0
  42. examples/avatar/male_03.jpg +3 -0
  43. examples/avatar/male_04.jpg +3 -0
  44. examples/avatar/male_05.jpg +3 -0
  45. examples/avatar/male_06.jpg +3 -0
  46. examples/background/01.jpg +3 -0
  47. examples/background/02.jpg +3 -0
  48. examples/background/03.jpg +3 -0
  49. examples/background/04.jpg +3 -0
  50. examples/background/05.jpg +3 -0
.gitattributes CHANGED
@@ -1,35 +1,39 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.jpg filter=lfs diff=lfs merge=lfs -text
37
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
38
+ *.png filter=lfs diff=lfs merge=lfs -text
39
+ *.webp filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ debug/
2
+ testing/output/
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ share/python-wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .nox/
46
+ .coverage
47
+ .coverage.*
48
+ .cache
49
+ nosetests.xml
50
+ coverage.xml
51
+ *.cover
52
+ *.py,cover
53
+ .hypothesis/
54
+ .pytest_cache/
55
+ cover/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ .pybuilder/
79
+ target/
80
+
81
+ # Jupyter Notebook
82
+ .ipynb_checkpoints
83
+
84
+ # IPython
85
+ profile_default/
86
+ ipython_config.py
87
+
88
+ # pyenv
89
+ # For a library or package, you might want to ignore these files since the code is
90
+ # intended to run in multiple environments; otherwise, check them in:
91
+ # .python-version
92
+
93
+ # pipenv
94
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
96
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
97
+ # install all needed dependencies.
98
+ #Pipfile.lock
99
+
100
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
101
+ __pypackages__/
102
+
103
+ # Celery stuff
104
+ celerybeat-schedule
105
+ celerybeat.pid
106
+
107
+ # SageMath parsed files
108
+ *.sage.py
109
+
110
+ # Environments
111
+ .env
112
+ .venv
113
+ env/
114
+ venv/
115
+ ENV/
116
+ env.bak/
117
+ venv.bak/
118
+
119
+ # PyCharm
120
+ .idea
121
+
122
+ # Spyder project settings
123
+ .spyderproject
124
+ .spyproject
125
+
126
+ # Rope project settings
127
+ .ropeproject
128
+
129
+ # mkdocs documentation
130
+ /site
131
+
132
+ # mypy
133
+ .mypy_cache/
134
+ .dmypy.json
135
+ dmypy.json
136
+
137
+ # Pyre type checker
138
+ .pyre/
139
+
140
+ # pytype static type analyzer
141
+ .pytype/
142
+
143
+ # Cython debug symbols
144
+ cython_debug/
145
+
146
+ # MacOS filesystem
147
+ .DS_Store
148
+
149
+ .gradio
README.md CHANGED
@@ -1,12 +1,29 @@
1
- ---
2
- title: ISSATM VTO
3
- emoji: 👁
4
- colorFrom: red
5
- colorTo: gray
6
- sdk: gradio
7
- sdk_version: 5.6.0
8
- app_file: app.py
9
- pinned: false
10
- ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Virtual Try-On Diffusion [VTON-D]
3
+ emoji: 👗
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: gradio
7
+ sdk_version: 5.6.0
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: Diffusion-based multi-modal virtual try-on pipeline demo
11
+ tags:
12
+ - virtual try-on
13
+ - vton
14
+ - clothing transfer
15
+ - diffusion
16
+ - img2img
17
+ - txt2img
18
+ ---
19
+
20
+ # Virtual Try-On Diffusion [VTON-D] by Texel.Moda
21
+
22
+ Virtual Try-On Diffusion [VTON-D] by [Texel.Moda](https://texelmoda.com/) is a custom diffusion-based pipeline for fast
23
+ and flexible multi-modal virtual try-on. Clothing, avatar and background can be specified by reference images or text
24
+ prompts allowing for clothing transfer, avatar replacement, fashion image generation and other virtual try-on related
25
+ tasks.
26
+
27
+ This API is available [through the RapidAPI Hub](https://rapidapi.com/texelmoda-texelmoda-apis/api/try-on-diffusion).
28
+ Additionally, you can find the extensive API documentation
29
+ [here](https://huggingface.co/spaces/texelmoda/try-on-diffusion/blob/main/docs/API.md).
app.py ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import gradio as gr
3
+ import numpy as np
4
+ import cv2
5
+ import os
6
+ import base64
7
+
8
+ from try_on_diffusion_client import TryOnDiffusionClient
9
+
10
+ LOG_LEVEL = logging.INFO
11
+ LOG_FORMAT = "%(asctime)s %(thread)-8s %(name)-16s %(levelname)-8s %(message)s"
12
+ LOG_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
13
+
14
+ EXAMPLE_PATH = os.path.join(os.path.dirname(__file__), "examples")
15
+
16
+ API_URL = os.getenv("TRY_ON_DIFFUSION_DEMO_API_URL", "http://localhost:8000")
17
+ API_KEY = os.getenv("TRY_ON_DIFFUSION_DEMO_API_KEY", "")
18
+
19
+ SHOW_RAPIDAPI_LINK = os.getenv("TRY_ON_DIFFUSION_DEMO_SHOW_RAPIDAPI_LINK", "1") == "1"
20
+
21
+ CONCURRENCY_LIMIT = int(os.getenv("TRY_ON_DIFFUSION_DEMO_CONCURRENCY_LIMIT", "2"))
22
+
23
+ logging.basicConfig(level=LOG_LEVEL, format=LOG_FORMAT, datefmt=LOG_DATE_FORMAT)
24
+
25
+ client = TryOnDiffusionClient(base_url=API_URL, api_key=API_KEY)
26
+
27
+
28
+ def get_image_base64(file_name: str) -> str:
29
+ _, ext = os.path.splitext(file_name.lower())
30
+
31
+ content_type = "image/jpeg"
32
+
33
+ if ext == ".png":
34
+ content_type = "image/png"
35
+ elif ext == ".webp":
36
+ content_type = "image/webp"
37
+ elif ext == ".gif":
38
+ content_type = "image/gif"
39
+
40
+ with open(file_name, "rb") as f:
41
+ return f"data:{content_type};base64," + base64.b64encode(f.read()).decode("utf-8")
42
+
43
+
44
+ def get_examples(example_dir: str) -> list[str]:
45
+ file_list = [f for f in os.listdir(os.path.join(EXAMPLE_PATH, example_dir)) if f.endswith(".jpg")]
46
+ file_list.sort()
47
+
48
+ return [os.path.join(EXAMPLE_PATH, example_dir, f) for f in file_list]
49
+
50
+
51
+ def try_on(
52
+ clothing_image: np.ndarray = None,
53
+ clothing_prompt: str = None,
54
+ avatar_image: np.ndarray = None,
55
+ avatar_prompt: str = None,
56
+ avatar_sex: str = None,
57
+ background_image: np.ndarray = None,
58
+ background_prompt: str = None,
59
+ seed: int = -1,
60
+ ) -> tuple:
61
+ result = client.try_on_file(
62
+ clothing_image=cv2.cvtColor(clothing_image, cv2.COLOR_RGB2BGR) if clothing_image is not None else None,
63
+ clothing_prompt=clothing_prompt,
64
+ avatar_image=cv2.cvtColor(avatar_image, cv2.COLOR_RGB2BGR) if avatar_image is not None else None,
65
+ avatar_prompt=avatar_prompt,
66
+ avatar_sex=avatar_sex if avatar_sex in ["male", "female"] else None,
67
+ background_image=cv2.cvtColor(background_image, cv2.COLOR_RGB2BGR) if background_image is not None else None,
68
+ background_prompt=background_prompt,
69
+ seed=seed,
70
+ )
71
+
72
+ if result.status_code == 200:
73
+ return cv2.cvtColor(result.image, cv2.COLOR_BGR2RGB), f"<h3>Success</h3><p>Seed: {result.seed}</p>"
74
+ else:
75
+ error_message = f"<h3>Error {result.status_code}</h3>"
76
+
77
+ if result.error_details is not None:
78
+ error_message += f"<p>{result.error_details}</p>"
79
+
80
+ return None, error_message
81
+
82
+
83
+ with gr.Blocks(theme=gr.themes.Soft(), delete_cache=(3600, 3600)) as app:
84
+ gr.HTML(
85
+ f"""
86
+ <div style="width: 100%; background-color: #001537; border-radius: 10px; padding-left: 10px">
87
+ <a href="https://texelmoda.com/" target="_blank">
88
+ <img src="{get_image_base64("images/logo.png")}" title="Texel.Moda" alt="Texel.Moda" style="float: left; margin-right: 10px; margin-left: -10px; border-radius: 10px; max-height: 50px;"/>
89
+ </a>
90
+ <h1 style="margin: 0; margin-right: 10px; line-height: 50px; color: #8cecd5; text-transform: uppercase">Virtual Try-On Diffusion</h1>
91
+ </div>
92
+ <br/>
93
+ <p>
94
+ Virtual Try-On Diffusion [VTON-D] by <a href="https://texelmoda.com/" target="_blank">Texel.Moda</a> is a
95
+ custom diffusion-based pipeline for fast and flexible multi-modal virtual try-on.
96
+ Clothing, avatar and background can be specified by reference images or text prompts allowing for clothing
97
+ transfer, avatar replacement, fashion image generation and other virtual try-on related tasks.
98
+ """
99
+ )
100
+
101
+ if SHOW_RAPIDAPI_LINK:
102
+ gr.Button(
103
+ value="Check out the API @ RapidAPI.com",
104
+ link="https://rapidapi.com/texelmoda-texelmoda-apis/api/try-on-diffusion",
105
+ icon="https://files.readme.io/9336831-small-rapid-logo-favicon.png",
106
+ )
107
+
108
+ gr.HTML(
109
+ """
110
+ <center>
111
+ <a href="https://huggingface.co/spaces/texelmoda/try-on-diffusion/blob/main/docs/API.md">API Documentation</a>
112
+ </center>
113
+ """
114
+ )
115
+
116
+ gr.HTML("</p>")
117
+
118
+ with gr.Row():
119
+ with gr.Column():
120
+ gr.HTML(
121
+ """
122
+ <h2>Clothing</h2>
123
+ <p>
124
+ Clothing may be specified with a reference image or a text prompt.
125
+ For more exotic use cases image and prompt can be also used together.
126
+ If both image and prompt are empty the model will generate random clothing.
127
+ <br/><br/>
128
+ </p>
129
+ """
130
+ )
131
+
132
+ with gr.Tab("Image"):
133
+ clothing_image = gr.Image(label="Clothing Image", sources=["upload"], type="numpy")
134
+
135
+ clothing_image_examples = gr.Examples(
136
+ inputs=clothing_image, examples_per_page=12, examples=get_examples("clothing")
137
+ )
138
+
139
+ with gr.Tab("Prompt"):
140
+ clothing_prompt = gr.TextArea(
141
+ label="Clothing Prompt",
142
+ info='Compel weighting <a href="https://github.com/damian0815/compel/blob/main/doc/syntax.md">syntax</a> is supported.',
143
+ )
144
+
145
+ clothing_prompt_examples = gr.Examples(
146
+ inputs=clothing_prompt,
147
+ examples_per_page=8,
148
+ examples=[
149
+ "a sheer blue sleeveless mini dress",
150
+ "a beige woolen sweater and white pleated skirt",
151
+ "a black leather jacket and dark blue slim-fit jeans",
152
+ "a floral pattern blouse and leggings",
153
+ "a paisley pattern purple shirt and beige chinos",
154
+ "a striped white and blue polo shirt and blue jeans",
155
+ "a colorful t-shirt and black shorts",
156
+ "a checked pattern shirt and dark blue cargo pants",
157
+ ],
158
+ )
159
+
160
+ with gr.Column():
161
+ gr.HTML(
162
+ """
163
+ <h2>Avatar</h2>
164
+ <p>
165
+ Avatar may be specified with a subject photo or a text prompt.
166
+ Latter can be used, for example, to replace person while preserving clothing.
167
+ For more exotic use cases image and prompt can be also used together.
168
+ If both image and prompt are empty the model will generate random avatars.
169
+ </p>
170
+ """
171
+ )
172
+
173
+ with gr.Tab("Image"):
174
+ avatar_image = gr.Image(label="Avatar Image", sources=["upload"], type="numpy")
175
+
176
+ avatar_image_examples = gr.Examples(
177
+ inputs=avatar_image,
178
+ examples_per_page=12,
179
+ examples=get_examples("avatar"),
180
+ )
181
+
182
+ with gr.Tab("Prompt"):
183
+ avatar_prompt = gr.TextArea(
184
+ label="Avatar Prompt",
185
+ info='Compel weighting <a href="https://github.com/damian0815/compel/blob/main/doc/syntax.md">syntax</a> is supported.',
186
+ )
187
+
188
+ avatar_prompt_examples = gr.Examples(
189
+ inputs=avatar_prompt,
190
+ examples_per_page=8,
191
+ examples=[
192
+ "a beautiful blond girl with long hair",
193
+ "a cute redhead girl with freckles",
194
+ "a plus size female model wearing sunglasses",
195
+ "a woman with dark hair and blue eyes",
196
+ "a fit man with dark beard and blue eyes",
197
+ "a young blond man posing for a photo",
198
+ "a gentleman with beard and mustache",
199
+ "a plus size man walking",
200
+ ],
201
+ )
202
+
203
+ avatar_sex = gr.Dropdown(
204
+ label="Avatar Sex",
205
+ choices=[("Auto", ""), ("Male", "male"), ("Female", "female")],
206
+ value="",
207
+ info="Avatar sex selector can be used to enforce a specific sex of the avatar.",
208
+ )
209
+
210
+ with gr.Column():
211
+ gr.HTML(
212
+ """
213
+ <h2>Background</h2>
214
+ <p>
215
+ Replacing background is optional.
216
+ Background may be specified with a reference image or a text prompt.
217
+ If omitted original avatar background will be preserved.
218
+ <br/><br/><br/>
219
+ </p>
220
+ """
221
+ )
222
+
223
+ with gr.Tab("Image"):
224
+ background_image = gr.Image(label="Background Image", sources=["upload"], type="numpy")
225
+
226
+ background_image_examples = gr.Examples(
227
+ inputs=background_image, examples_per_page=12, examples=get_examples("background")
228
+ )
229
+
230
+ with gr.Tab("Prompt"):
231
+ background_prompt = gr.TextArea(
232
+ label="Background Prompt",
233
+ info='Compel weighting <a href="https://github.com/damian0815/compel/blob/main/doc/syntax.md">syntax</a> is supported.',
234
+ )
235
+
236
+ background_prompt_examples = gr.Examples(
237
+ inputs=background_prompt,
238
+ examples_per_page=8,
239
+ examples=[
240
+ "in an autumn park",
241
+ "in front of a brick wall",
242
+ "near an old tree",
243
+ "on a busy city street",
244
+ "in front of a staircase",
245
+ "on an ocean beach with palm trees",
246
+ "in a shopping mall",
247
+ "in a modern office",
248
+ ],
249
+ )
250
+
251
+ with gr.Column():
252
+ gr.HTML(
253
+ """
254
+ <h2>Generation</h2>
255
+ """
256
+ )
257
+
258
+ seed = gr.Number(
259
+ label="Seed",
260
+ value=-1,
261
+ minimum=-1,
262
+ info="Seed used for generation, specify -1 for random seed for each generation.",
263
+ )
264
+
265
+ generate_button = gr.Button(value="Generate", variant="primary")
266
+
267
+ result_image = gr.Image(label="Result", show_share_button=False, format="jpeg")
268
+ result_details = gr.HTML(label="Details")
269
+
270
+ generate_button.click(
271
+ fn=try_on,
272
+ inputs=[
273
+ clothing_image,
274
+ clothing_prompt,
275
+ avatar_image,
276
+ avatar_prompt,
277
+ avatar_sex,
278
+ background_image,
279
+ background_prompt,
280
+ seed,
281
+ ],
282
+ outputs=[result_image, result_details],
283
+ api_name=False,
284
+ concurrency_limit=CONCURRENCY_LIMIT,
285
+ )
286
+
287
+ app.title = "Virtual Try-On Diffusion by Texel.Moda"
288
+
289
+
290
+ if __name__ == "__main__":
291
+ app.queue(api_open=False).launch(show_api=False)
docs/API.md ADDED
@@ -0,0 +1,341 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Virtual Try-On Diffusion API
2
+
3
+ <!-- TOC -->
4
+ * [Virtual Try-On Diffusion API](#virtual-try-on-diffusion-api)
5
+ * [Summary](#summary)
6
+ * [Consuming the API](#consuming-the-api)
7
+ * [Try-On Endpoints](#try-on-endpoints)
8
+ * [Try-On Input Parameters](#try-on-input-parameters)
9
+ * [Clothing image](#clothing-image)
10
+ * [Clothing prompt](#clothing-prompt)
11
+ * [Avatar image](#avatar-image)
12
+ * [Avatar prompt](#avatar-prompt)
13
+ * [Background image](#background-image)
14
+ * [Background prompt](#background-prompt)
15
+ * [Additional notes](#additional-notes)
16
+ * [Try-On Output](#try-on-output)
17
+ * [Response codes](#response-codes)
18
+ * [NSFW content](#nsfw-content)
19
+ * [Use Cases and Recipes](#use-cases-and-recipes)
20
+ * [Image-based virtual try-on](#image-based-virtual-try-on)
21
+ * [Image-based virtual try-on with background](#image-based-virtual-try-on-with-background)
22
+ * [Avatar from a text prompt](#avatar-from-a-text-prompt)
23
+ * [Clothing from a text prompt](#clothing-from-a-text-prompt)
24
+ * [Modifying avatar's body](#modifying-avatars-body)
25
+ * [Txt2Img](#txt2img)
26
+ * [Other creative possibilities](#other-creative-possibilities)
27
+ * [Performance](#performance)
28
+ * [Known Issues and Limitations](#known-issues-and-limitations)
29
+ <!-- TOC -->
30
+
31
+ ## Summary
32
+
33
+ Virtual Try-On Diffusion [VTON-D] by [Texel.Moda](https://texelmoda.com) is a custom diffusion-based pipeline for fast
34
+ and flexible multi-modal virtual try-on. Clothing, avatar and background can be specified by reference images or text
35
+ prompts allowing for clothing transfer, avatar replacement, fashion image generation and other virtual try-on related
36
+ tasks. Check out the [demo on Hugging Face](https://huggingface.co/spaces/texelmoda/try-on-diffusion) to try the API in
37
+ a user-friendly way.
38
+
39
+ ## Consuming the API
40
+
41
+ The API is exposed through the RapidAPI Hub which manages API subscriptions, API keys, payments and other things. Please
42
+ refer to the [RapidAPI Documentation](https://docs.rapidapi.com/docs/consumer-quick-start-guide) to get started.
43
+
44
+ Generally, in order to use an API you need to perform the following steps:
45
+ - Create a RapidAPI.com account.
46
+ - [Navigate to the API page](https://rapidapi.com/texelmoda-texelmoda-apis/api/try-on-diffusion) and subscribe to a
47
+ suitable pricing plan. We also provide a free BASIC plan with 100 API requests per month.
48
+ - Use the obtained RapidAPI key to authenticate (via the _X-RapidAPI-Key_ header) and use an API from any programming
49
+ language or tool you like.
50
+
51
+ Example API call using cURL:
52
+ ```shell
53
+ curl --request POST \
54
+ --url https://try-on-diffusion.p.rapidapi.com/try-on-file \
55
+ --header 'Content-Type: multipart/form-data' \
56
+ --header 'x-rapidapi-host: try-on-diffusion.p.rapidapi.com' \
57
+ --header 'x-rapidapi-key: <RapidAPI Key>' \
58
+ --form clothing_image=1.jpg \
59
+ --form avatar_image=2.jpg
60
+ ```
61
+
62
+ For a simple Python client implementation please see the
63
+ [Hugging Face demo application source](https://huggingface.co/spaces/texelmoda/try-on-diffusion/blob/main/try_on_diffusion_client.py).
64
+
65
+ ## Try-On Endpoints
66
+
67
+ Try-On API consists of two endpoints that differ only in the method of passing reference images:
68
+
69
+ - **POST** _/try-on-file_ - takes reference images as uploaded files in the request body (using multipart/form-data).
70
+
71
+
72
+ - **POST** _/try-on-url_ - takes reference images as image URLs in POST parameters.
73
+
74
+ All image requirements, behavior and status codes are the same for both endpoints, choose the one that best suits your
75
+ application architecture.
76
+
77
+ ## Try-On Input Parameters
78
+
79
+ All input parameters for the try-on endpoints are currently optional. Images and prompts serve as additional generation
80
+ conditions and can even be used in combination. Below is the short parameter summary with links to extended information
81
+ on certain parameters.
82
+
83
+ List of input parameters for the **POST** _/try-on-file_ endpoint:
84
+
85
+ | Parameter | Description | Required |
86
+ |-----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|
87
+ | [clothing_image](#clothing-image) | Clothing reference image in JPEG, PNG or WEBP format, maximum file size is 12 MB. | No |
88
+ | [clothing_prompt](#clothing-prompt) | Text prompt for clothing, can be used instead of an image. Compel weighting syntax is supported. Example: _red sleeveless mini dress_ | No |
89
+ | [avatar_image](#avatar-image) | Avatar image in JPEG, PNG or WEBP format, maximum file size is 12 MB. | No |
90
+ | avatar_sex | Avatar sex, either "male" or "female". Will be detected automatically, if left empty or omitted. Will enforce certain avatar sex if specified. | No |
91
+ | [avatar_prompt](#avatar-prompt) | Text prompt for the avatar, can be used instead of an image or with image to modify the avatar. Compel weighting syntax is supported. Example: _a gentleman with beard and mustache_ | No |
92
+ | [background_image](#background-image) | Optional background reference image in JPEG, PNG or WEBP format, maximum file size is 12 MB. Original avatar background is preserved if background is not specified. | No |
93
+ | [background_prompt](#background-prompt) | Optional background text prompt. Original avatar background is preserved if background is not specified. Example: _in an autumn park_ | No |
94
+ | seed | Seed for image generation. Default is -1 (random seed). Actual seed will also be output in the "X-Seed" response header. Example: _42_ | No |
95
+
96
+ List of input parameters for the **POST** _/try-on-url_ endpoint:
97
+
98
+ | Parameter | Description | Required |
99
+ |-------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|
100
+ | [clothing_image_url](#clothing-image) | Clothing reference image URL. Image should be in JPEG, PNG or WEBP format, maximum file size is 12 MB. | No |
101
+ | [clothing_prompt](#clothing-prompt) | Text prompt for clothing, can be used instead of an image. Compel weighting syntax is supported. Example: _red sleeveless mini dress_ | No |
102
+ | [avatar_image_url](#avatar-image) | Avatar image URL. Image should be in JPEG, PNG or WEBP format, maximum file size is 12 MB. | No |
103
+ | avatar_sex | Avatar sex, either "male" or "female". Will be detected automatically, if left empty or omitted. Will enforce certain avatar sex if specified. | No |
104
+ | [avatar_prompt](#avatar-prompt) | Text prompt for the avatar, can be used instead of an image or with image to modify the avatar. Compel weighting syntax is supported. Example: _a gentleman with beard and mustache_ | No |
105
+ | [background_image_url](#background-image) | Optional background reference image URL. Image should be in JPEG, PNG or WEBP format, maximum file size is 12 MB. Original avatar background is preserved if background is not specified. | No |
106
+ | [background_prompt](#background-prompt) | Optional background text prompt. Original avatar background is preserved if background is not specified. Example: _in an autumn park_ | No |
107
+ | seed | Seed for image generation. Default is -1 (random seed). Actual seed will also be output in the "X-Seed" response header. Example: _42_ | No |
108
+
109
+ ### Clothing image
110
+
111
+ For best results clothing reference images should meet a number of requirements:
112
+
113
+ - File format: **JPEG**, **PNG** or **WEBP**
114
+ - Maximum file size: **12 MB**
115
+ - Minimum image size: **256x256**
116
+ - Recommended image size: **768x1024 and above**
117
+ - Clothing should be **dressed on a person**. Some flat lay clothing photos might work, but currently it's not guaranteed
118
+ - **Single person** on the image (though multiple persons might also work)
119
+ - **Frontal** photo, though some degree of rotation is fine
120
+ - **Good lighting** conditions and **high image quality** as it directly affects the result
121
+ - **Minimal occlusion** by hair, hands or accessories
122
+
123
+ To summarize: the better is the clothing image the better is the final result.
124
+
125
+ Examples of good clothing images:
126
+
127
+ | <img src="images/clothing_image_01.jpg" width="240"> | <img src="images/clothing_image_02.jpg" width="240"> | <img src="images/clothing_image_03.jpg" width="240"> | <img src="images/clothing_image_04.jpg" width="240"> |
128
+ |------------------------------------------------------|------------------------------------------------------|------------------------------------------------------|------------------------------------------------------|
129
+
130
+ ### Clothing prompt
131
+
132
+ Instead of a clothing image you can use text prompt to describe the garment. Short and clear prompts work best.
133
+ Additionally, [Compel weighting syntax](https://github.com/damian0815/compel/blob/main/doc/syntax.md) is supported to
134
+ increase or decrease weight of certain tokens. Examples:
135
+ - _a sheer blue sleeveless mini dress_
136
+ - _a beige woolen sweater and white pleated skirt_
137
+ - _a black leather jacket and dark blue slim-fit jeans_
138
+ - _a floral pattern blouse and leggings_
139
+ - _a colorful+++ t-shirt and black shorts_
140
+
141
+ ### Avatar image
142
+
143
+ Avatar images should also meet a some requirements:
144
+
145
+ - File format: **JPEG**, **PNG** or **WEBP**
146
+ - Maximum file size: **12 MB**
147
+ - Minimum image size: **256x256**
148
+ - Recommended image size: **768x1024 and above**
149
+ - **Single person** on the image (though multiple persons might also work)
150
+ - **Frontal** photo, though some degree of rotation is fine
151
+ - **Good lighting** conditions and **high image quality**
152
+
153
+ Examples of good avatar images:
154
+
155
+ | <img src="images/avatar_image_01.jpg" width="240"> | <img src="images/avatar_image_02.jpg" width="240"> | <img src="images/avatar_image_03.jpg" width="240"> | <img src="images/avatar_image_04.jpg" width="240"> |
156
+ |----------------------------------------------------|----------------------------------------------------|----------------------------------------------------|----------------------------------------------------|
157
+
158
+ ### Avatar prompt
159
+
160
+ Instead of an avatar image you can use text prompt to describe the person. Short and clear prompts work best.
161
+ Additionally, [Compel weighting syntax](https://github.com/damian0815/compel/blob/main/doc/syntax.md) is supported to
162
+ increase or decrease weight of certain tokens. Examples:
163
+ - _a beautiful blond girl with long hair_
164
+ - _a cute redhead girl with freckles_
165
+ - _a (plus size)++ female model wearing sunglasses_
166
+ - _a fit man with dark beard and blue eyes_
167
+ - _a gentleman with beard and mustache_
168
+
169
+ ### Background image
170
+
171
+ Background images are used to extract high-level background features only and serve as a reference (and not exact
172
+ background). Below are basic image requirements:
173
+
174
+ - File format: **JPEG**, **PNG** or **WEBP**
175
+ - Maximum file size: **12 MB**
176
+ - Recommended image size: **256x256 and above**
177
+
178
+ Examples of background images:
179
+
180
+ | <img src="images/background_image_01.jpg" width="240"> | <img src="images/background_image_02.jpg" width="240"> | <img src="images/background_image_03.jpg" width="240"> | <img src="images/background_image_04.jpg" width="240"> |
181
+ |--------------------------------------------------------|--------------------------------------------------------|--------------------------------------------------------|--------------------------------------------------------|
182
+
183
+ ### Background prompt
184
+
185
+ Instead of a background image you can use text prompt to describe the background. Short and clear prompts work best.
186
+ Additionally, [Compel weighting syntax](https://github.com/damian0815/compel/blob/main/doc/syntax.md) is supported to
187
+ increase or decrease weight of certain tokens. Examples:
188
+ - _in an autumn park_
189
+ - _in front of a brick wall_
190
+ - _on an ocean beach with (palm trees)++_
191
+ - _in a shopping mall_
192
+ - _in a modern office_
193
+
194
+ ### Additional notes
195
+
196
+ We use the "same-crop" approach for clothing and avatar images: images will be cropped roughly the same way (using pose
197
+ estimation), so we don't have to add too much new information (e.g. assume lower body clothing). So, if you use only a
198
+ photo of an upper body clothing the result will also be cropped the same way regardless of the avatar image (and the
199
+ other way around):
200
+
201
+ | Clothing Image | Avatar Image | Result Image |
202
+ |------------------------------------------------------|-----------------------------------------------------|--------------------------------------------------------|
203
+ | <img src="images/clothing_image_02.jpg" width="240"> | <img src="images/avatar_image_02.jpg" width="240"> | <img src="images/same_crop_result_01.jpg" width="240"> |
204
+ | <img src="images/clothing_image_03.jpg" width="240"> | <img src="images/avatar_image_03.jpg" width="240"> | <img src="images/same_crop_result_02.jpg" width="240"> |
205
+
206
+ ## Try-On Output
207
+
208
+ ### Response codes
209
+
210
+ HTTP status code is used as a high-level response status. In case of a successful API call HTTP code 200 will be
211
+ returned and response body will contain a resulting JPEG image with the maximum size of 768x1024 pixels. Response
212
+ will also have the "X-Seed" header set that should contain the actual seed used for image generation (for
213
+ reproducibility). Other status codes (not 200) indicate unsuccessful request, see the table below for additional
214
+ details:
215
+
216
+ | Response Code | Content-Type | Headers | Description | Example |
217
+ |:-------------:|:------------------:|:--------------:|-----------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------:|
218
+ | **200** | image/jpeg | X-Seed: {seed} | Successful API call. Response body contains the resulting image in JPEG format. | <img src="images/same_crop_result_01.jpg" width="160"> |
219
+ | **400** | application/json | | Bad request: at least one of request parameters is invalid. Response body should contain additional error details in JSON format. | { "detail": "Invalid upload file type: application/x-zip-compressed" } |
220
+ | **403** | application/json | | Indicates authentication issue (e.g. invalid API key). | |
221
+ | **422** | application/json | | Request validation error. Response body should contain error details in JSON format. | { "detail": [ { "loc": [ "string", 0], "msg": "string", "type": "string" } ] } |
222
+ | **429** | | | Too many requests. Might be triggered by the RapidAPI proxy in case of reaching maximum request rate or API call limit. | |
223
+ | **500** | | | Indicates an internal server error, might not have any details. | |
224
+
225
+ ### NSFW content
226
+
227
+ We use NSFW content checker to ensure we don't output inappropriate images. If potential NSFW content is detected in the
228
+ generated image, the API will return HTTP status code 400 with a corresponding error message in JSON response.
229
+
230
+ ## Use Cases and Recipes
231
+
232
+ Our Virtual Try-On API offers a flexible way to specify clothing, avatar and background, which makes it possible to not
233
+ only perform a classic task of virtual try-on, but also generate entirely new images or alter existing images in some
234
+ interesting aspects. Feel free to try and explore!
235
+
236
+ In all the examples below all unmentioned inputs are assumed to be empty.
237
+
238
+ ### Image-based virtual try-on
239
+
240
+ The most common use case is to transfer clothing from one photo (e.g. from a product page) to another photo (e.g.
241
+ user avatar) while maintaining the avatar and the background.
242
+
243
+ | Clothing Image | Avatar Image | Result Image |
244
+ |------------------------------------------------------|----------------------------------------------------|----------------------------------------------------------|
245
+ | <img src="images/clothing_image_01.jpg" width="240"> | <img src="images/avatar_image_02.jpg" width="240"> | <img src="images/image_based_result_01.jpg" width="240"> |
246
+
247
+ ### Image-based virtual try-on with background
248
+
249
+ Additionally, it's possible to replace the avatar background with a reference image or a text prompt.
250
+
251
+ | Clothing Image | Avatar Image | Background Image | Result Image |
252
+ |------------------------------------------------------|----------------------------------------------------|--------------------------------------------------------|---------------------------------------------------------------------|
253
+ | <img src="images/clothing_image_04.jpg" width="240"> | <img src="images/avatar_image_03.jpg" width="240"> | <img src="images/background_image_01.jpg" width="240"> | <img src="images/image_based_background_result_01.jpg" width="240"> |
254
+
255
+ And with a text prompt for the background:
256
+
257
+ | Clothing Image | Avatar Image | Background Prompt | Result Image |
258
+ |------------------------------------------------------|----------------------------------------------------|------------------------------|---------------------------------------------------------------------|
259
+ | <img src="images/clothing_image_04.jpg" width="240"> | <img src="images/avatar_image_03.jpg" width="240"> | in front of a snowy mountain | <img src="images/image_based_background_result_02.jpg" width="240"> |
260
+
261
+ ### Avatar from a text prompt
262
+
263
+ It's possible to replace the person on the clothing image with an avatar, described in a text prompt. Background will be
264
+ changed as well and will be a random one if not specified:
265
+
266
+ | Clothing Image | Avatar Prompt | Background Prompt | Result Image |
267
+ |------------------------------------------------------|--------------------------------------------|--------------------|------------------------------------------------------------|
268
+ | <img src="images/clothing_image_02.jpg" width="240"> | a beautiful blond girl with long hair | | <img src="images/avatar_prompt_result_01.jpg" width="240"> |
269
+ | <img src="images/clothing_image_03.jpg" width="240"> | a gentleman with a long beard and mustache | near a fireplace | <img src="images/avatar_prompt_result_02.jpg" width="240"> |
270
+
271
+ You may also experiment with avatar prompts for more interesting results:
272
+
273
+ | Clothing Image | Avatar Prompt | Background Prompt | Result Image |
274
+ |------------------------------------------------------|---------------------|-----------------------|------------------------------------------------------------|
275
+ | <img src="images/clothing_image_03.jpg" width="240"> | (iron man mask)+++ | in the Sahara Desert | <img src="images/avatar_prompt_result_03.jpg" width="240"> |
276
+
277
+ ### Clothing from a text prompt
278
+
279
+ Similarly, you can specify clothing with a text prompt while providing an avatar image:
280
+
281
+ | Clothing Prompt | Avatar Image | Result Image |
282
+ |-------------------------------------|----------------------------------------------------|--------------------------------------------------------------|
283
+ | a sheer blue sleeveless mini dress | <img src="images/avatar_image_02.jpg" width="240"> | <img src="images/clothing_prompt_result_01.jpg" width="240"> |
284
+ | a colorful t-shirt and black shorts | <img src="images/avatar_image_03.jpg" width="240"> | <img src="images/clothing_prompt_result_02.jpg" width="240"> |
285
+
286
+ ### Modifying avatar's body
287
+
288
+ If you specify clothing and avatar images to be the same while providing an avatar prompt it's possible to change
289
+ avatar's body proportions. Note that it may require using additional term weighting to achieve stronger changes.
290
+
291
+ | Clothing Image | Avatar Image | Avatar Prompt | Result Image |
292
+ |------------------------------------------------------|------------------------------------------------------|-------------------------------|------------------------------------------------------------------|
293
+ | <img src="images/clothing_image_01.jpg" width="240"> | <img src="images/clothing_image_01.jpg" width="240"> | a (plus size)+ woman | <img src="images/avatar_modification_result_01.jpg" width="240"> |
294
+ | <img src="images/clothing_image_03.jpg" width="240"> | <img src="images/clothing_image_03.jpg" width="240"> | a (muscular bodybuilder)+++++ | <img src="images/avatar_modification_result_02.jpg" width="240"> |
295
+
296
+ ### Txt2Img
297
+
298
+ As our diffusion model was fine-tuned to produce people wearing various clothing, it can better follow a clothing prompt
299
+ and output realistic people and garments:
300
+
301
+ | Clothing Prompt | Avatar Prompt | Background Prompt | Result Image |
302
+ |-------------------------------------------------|--------------------------------|------------------------|------------------------------------------------------|
303
+ | a paisley pattern purple shirt and beige chinos | a fit man with dark beard | plain white background | <img src="images/txt2img_result_01.jpg" width="240"> |
304
+ | a white polka dot pattern dress | a beautiful petite blond woman | on a yacht | <img src="images/txt2img_result_02.jpg" width="240"> |
305
+
306
+ ### Other creative possibilities
307
+
308
+ If you specify the same image for clothing and avatar while providing a background prompt (or background image) you can
309
+ replace the background in a creative way:
310
+
311
+ | Clothing Image | Avatar Image | Background Prompt | Result Image |
312
+ |----------------------------------------------------|----------------------------------------------------|-------------------------|-------------------------------------------------------------|
313
+ | <img src="images/avatar_image_02.jpg" width="240"> | <img src="images/avatar_image_02.jpg" width="240"> | on a snowy mountain top | <img src="images/new_background_result_01.jpg" width="240"> |
314
+
315
+ It's also possible to use a combination of clothing image, clothing prompt, avatar image and a background to add some
316
+ accessories:
317
+
318
+ | Clothing Image | Clothing Prompt | Avatar Image | Background Image | Result Image |
319
+ |------------------------------------------------------|--------------------------|------------------------------------------------------|--------------------------------------------------------|------------------------------------------------------------------|
320
+ | <img src="images/avatar_image_02.jpg" width="240"> | a (light brown purse)+++ | <img src="images/avatar_image_02.jpg" width="240"> | <img src="images/background_image_03.jpg" width="240"> | <img src="images/accessory_result_01.jpg" width="240"> |
321
+
322
+ ## Performance
323
+
324
+ Typically, one try-on request is processed in 5-10 seconds (depending on type of conditions) excluding network latency.
325
+ In order to reduce network overhead you might want to compress your images before feeding to the API (e.g. using JPEG).
326
+ Please note that in case of a high demand processing time might increase due to request being queued, though we
327
+ constantly monitor our GPU cluster capacity and perform scaling as needed.
328
+
329
+ ## Known Issues and Limitations
330
+
331
+ As any generative model, our models are not perfect (though we constantly work on improvements):
332
+ - Currently, we do not fully support flat lay clothing images. Some might work, but that's not guaranteed.
333
+ - Prompt following might not be perfect, especially in case of long and sophisticated prompts. Prefer simpler and more
334
+ straightforward prompts whenever possible. Also be pretty verbose (e.g. use the word "plain" if you need something of
335
+ solid color). Additionally, Compel weighting might be used to increase weight of certain tokens.
336
+ - As usual, generative models struggle with hands, fingers and toes, though we try to mitigate it to a certain extent.
337
+ - Currently, we do not support trying on a single garment, only the full look.
338
+ - Hats and sunglasses are not currently transferred, but we are working on it.
339
+ - Backgrounds might lack some clarity as currently we focus more on clothing.
340
+ - In case of a specified background a hairstyle might change.
341
+ - Body shape of the avatar might change towards smaller sizes.
docs/images/accessory_result_01.jpg ADDED

Git LFS Details

  • SHA256: 4b1660d9df9205715cf017df5a6f520f0bb170ba20e34ac37f87eaeb6ad3f74b
  • Pointer size: 131 Bytes
  • Size of remote file: 193 kB
docs/images/avatar_image_01.jpg ADDED

Git LFS Details

  • SHA256: 1291a821607d3630318961f184987c8a494bfcc70ac93a315d5aeb8842475b50
  • Pointer size: 131 Bytes
  • Size of remote file: 425 kB
docs/images/avatar_image_02.jpg ADDED

Git LFS Details

  • SHA256: a8f92656f1243d3d9562f91807fa8d3ca11bf66ad9dd3736630f88862d76110b
  • Pointer size: 131 Bytes
  • Size of remote file: 262 kB
docs/images/avatar_image_03.jpg ADDED

Git LFS Details

  • SHA256: d9226c7ff9b67969cfa413c77c4c07974806009d59a96a15c4fbecdee1a5c8e2
  • Pointer size: 131 Bytes
  • Size of remote file: 191 kB
docs/images/avatar_image_04.jpg ADDED

Git LFS Details

  • SHA256: 02831ba12b974525a94e439c353fd720a7dae14c102b4b11baf38c56822807f9
  • Pointer size: 131 Bytes
  • Size of remote file: 352 kB
docs/images/avatar_modification_result_01.jpg ADDED

Git LFS Details

  • SHA256: 5c4d2adebeb2a27599b6a0ea532b8b25b5703697878c2bd4994466729c3e6f6b
  • Pointer size: 131 Bytes
  • Size of remote file: 191 kB
docs/images/avatar_modification_result_02.jpg ADDED

Git LFS Details

  • SHA256: 7447675d79262d0120d6054c96e6723222c2d74451a4ba83a4b28e78fc900c76
  • Pointer size: 131 Bytes
  • Size of remote file: 144 kB
docs/images/avatar_prompt_result_01.jpg ADDED

Git LFS Details

  • SHA256: 06df6a8f830cff7c71459712c8c8bb4edb394580a818bd681644760f96c92dd9
  • Pointer size: 131 Bytes
  • Size of remote file: 260 kB
docs/images/avatar_prompt_result_02.jpg ADDED

Git LFS Details

  • SHA256: b20354374b2366729696d55ede627dc5fbb0cab22d374d4f4200b7283eb60417
  • Pointer size: 131 Bytes
  • Size of remote file: 160 kB
docs/images/avatar_prompt_result_03.jpg ADDED

Git LFS Details

  • SHA256: a40abc74cd27451b6b439a91b8c26e3e2318cd5202b2f0113faecc36a2c44f49
  • Pointer size: 131 Bytes
  • Size of remote file: 116 kB
docs/images/background_image_01.jpg ADDED

Git LFS Details

  • SHA256: cc6ad7187561a6a29044accc996aa242c48ea92f707d245dfdd75d545affd0bf
  • Pointer size: 131 Bytes
  • Size of remote file: 492 kB
docs/images/background_image_02.jpg ADDED

Git LFS Details

  • SHA256: 7a92ab3827aecf1c683f2a5c3f44ae546ede0769e74bbae238ca0380a50fcc6b
  • Pointer size: 131 Bytes
  • Size of remote file: 700 kB
docs/images/background_image_03.jpg ADDED

Git LFS Details

  • SHA256: 661a22b8d8442ad42d6dfa3e0ff563ed421ee7afab07d9bcf4ff5359f41c9d5f
  • Pointer size: 131 Bytes
  • Size of remote file: 511 kB
docs/images/background_image_04.jpg ADDED

Git LFS Details

  • SHA256: e865e32c08a6f98fb92e9da07d646f927f08aa577b8fa30283ec7624474d5286
  • Pointer size: 131 Bytes
  • Size of remote file: 357 kB
docs/images/clothing_image_01.jpg ADDED

Git LFS Details

  • SHA256: 185a51562b6b04b8bc52eaf56c21451325af4379f6cfde4a7dcca8a15f1575c3
  • Pointer size: 131 Bytes
  • Size of remote file: 398 kB
docs/images/clothing_image_02.jpg ADDED

Git LFS Details

  • SHA256: 533de7bd0e3ae1862304523e2035d8ba0015109e8a39368a017a9a757144bafa
  • Pointer size: 131 Bytes
  • Size of remote file: 434 kB
docs/images/clothing_image_03.jpg ADDED

Git LFS Details

  • SHA256: 9495af8b97285a3456bfbb684881cd8c1ba9bfd76e215843d24caeb22c64c9f8
  • Pointer size: 131 Bytes
  • Size of remote file: 313 kB
docs/images/clothing_image_04.jpg ADDED

Git LFS Details

  • SHA256: dfee3b092114533daf468a03707da516433acfc2076ced135e604ba4a7904512
  • Pointer size: 131 Bytes
  • Size of remote file: 407 kB
docs/images/clothing_prompt_result_01.jpg ADDED

Git LFS Details

  • SHA256: 3143f5aedd059a43325c6e5f99a408f04966beea840f64c2170839de97ada65c
  • Pointer size: 131 Bytes
  • Size of remote file: 120 kB
docs/images/clothing_prompt_result_02.jpg ADDED

Git LFS Details

  • SHA256: 5c5400a8899eccfd85a8550f1240aae2a6a3b838894e1afa72535a18cf9100a5
  • Pointer size: 131 Bytes
  • Size of remote file: 178 kB
docs/images/image_based_background_result_01.jpg ADDED

Git LFS Details

  • SHA256: 359ba35386a578aea598df4044020e5ce5f1b5ce323f98e024c906d23d1a671b
  • Pointer size: 131 Bytes
  • Size of remote file: 216 kB
docs/images/image_based_background_result_02.jpg ADDED

Git LFS Details

  • SHA256: 7fb59f6770466a27bccc396cd7040b5bce90cd8c9b3d8daf7466ab95c53272a4
  • Pointer size: 131 Bytes
  • Size of remote file: 282 kB
docs/images/image_based_result_01.jpg ADDED

Git LFS Details

  • SHA256: b907d7e15cbd2a6bc822acd3bb580421cacf6f057c28c4d891d5db9f3365b4fb
  • Pointer size: 131 Bytes
  • Size of remote file: 148 kB
docs/images/new_background_result_01.jpg ADDED

Git LFS Details

  • SHA256: 643f043d2c9fd5553851021d55aef549d610cba36ac2169ae1173d55278b22b5
  • Pointer size: 131 Bytes
  • Size of remote file: 240 kB
docs/images/same_crop_result_01.jpg ADDED

Git LFS Details

  • SHA256: 014b109c9fd456dd2389031283ba5ce7ddf7a674f0eca47ade4c9044de907f84
  • Pointer size: 131 Bytes
  • Size of remote file: 190 kB
docs/images/same_crop_result_02.jpg ADDED

Git LFS Details

  • SHA256: 5e48023a99d70ecc69975e5618a3789b6503d40d856a5767e3a2d564acad224c
  • Pointer size: 131 Bytes
  • Size of remote file: 159 kB
docs/images/txt2img_result_01.jpg ADDED

Git LFS Details

  • SHA256: 68fddf34ccabc2ce5580af2d3bb1415ab20971711d64d4cd078a74c5513e9cec
  • Pointer size: 131 Bytes
  • Size of remote file: 186 kB
docs/images/txt2img_result_02.jpg ADDED

Git LFS Details

  • SHA256: a818bab8929bca1c23d16b0bd9c440d9a2247bff4c69e839f9594d838d1fc9a1
  • Pointer size: 131 Bytes
  • Size of remote file: 171 kB
examples/avatar/female_01.jpg ADDED

Git LFS Details

  • SHA256: feb60696275f5276bcc0dc65e14bd972440b7973baa41609d0b6334d8b1c9880
  • Pointer size: 131 Bytes
  • Size of remote file: 211 kB
examples/avatar/female_02.jpg ADDED

Git LFS Details

  • SHA256: 0b02efe2043a9af0fa79bdc892b2e8535cc9fe83e3887e6ae49f14bff2f6faa0
  • Pointer size: 131 Bytes
  • Size of remote file: 294 kB
examples/avatar/female_03.jpg ADDED

Git LFS Details

  • SHA256: 70653888c42588a919f5eec01f7ce861cb19dd906f97f0c446d266d4c791b51b
  • Pointer size: 131 Bytes
  • Size of remote file: 195 kB
examples/avatar/female_04.jpg ADDED

Git LFS Details

  • SHA256: 4711e7d8e08cda7b29f331c1a790c729bbe264587c59dd76b6370c9e6491845c
  • Pointer size: 131 Bytes
  • Size of remote file: 416 kB
examples/avatar/female_05.jpg ADDED

Git LFS Details

  • SHA256: 1291a821607d3630318961f184987c8a494bfcc70ac93a315d5aeb8842475b50
  • Pointer size: 131 Bytes
  • Size of remote file: 425 kB
examples/avatar/female_06.jpg ADDED

Git LFS Details

  • SHA256: a8f92656f1243d3d9562f91807fa8d3ca11bf66ad9dd3736630f88862d76110b
  • Pointer size: 131 Bytes
  • Size of remote file: 262 kB
examples/avatar/male_01.jpg ADDED

Git LFS Details

  • SHA256: d9226c7ff9b67969cfa413c77c4c07974806009d59a96a15c4fbecdee1a5c8e2
  • Pointer size: 131 Bytes
  • Size of remote file: 191 kB
examples/avatar/male_02.jpg ADDED

Git LFS Details

  • SHA256: 02831ba12b974525a94e439c353fd720a7dae14c102b4b11baf38c56822807f9
  • Pointer size: 131 Bytes
  • Size of remote file: 352 kB
examples/avatar/male_03.jpg ADDED

Git LFS Details

  • SHA256: 2d9441acd683a497d4108582abb99bc333643de3368c05fffb9e911c7d3d1106
  • Pointer size: 131 Bytes
  • Size of remote file: 123 kB
examples/avatar/male_04.jpg ADDED

Git LFS Details

  • SHA256: 99ecc2bf9d21bdd22d1c42bfeab8537ee3dd1ce7139c3d15c6be9e782040a0fb
  • Pointer size: 131 Bytes
  • Size of remote file: 361 kB
examples/avatar/male_05.jpg ADDED

Git LFS Details

  • SHA256: bf364572f22b23c3567dc8f169e329a20f3e3def7cf1bc2e4349d98f16351d87
  • Pointer size: 131 Bytes
  • Size of remote file: 170 kB
examples/avatar/male_06.jpg ADDED

Git LFS Details

  • SHA256: bba21beb25ff292a6917e9cd377ccd53a63b46c97a4bb1e87d8c324a0187a52a
  • Pointer size: 131 Bytes
  • Size of remote file: 308 kB
examples/background/01.jpg ADDED

Git LFS Details

  • SHA256: cc6ad7187561a6a29044accc996aa242c48ea92f707d245dfdd75d545affd0bf
  • Pointer size: 131 Bytes
  • Size of remote file: 492 kB
examples/background/02.jpg ADDED

Git LFS Details

  • SHA256: 7a92ab3827aecf1c683f2a5c3f44ae546ede0769e74bbae238ca0380a50fcc6b
  • Pointer size: 131 Bytes
  • Size of remote file: 700 kB
examples/background/03.jpg ADDED

Git LFS Details

  • SHA256: 0f7f1044891103c2e5697c3b7cbd36ca869c63982f11a266077601b51549b74c
  • Pointer size: 131 Bytes
  • Size of remote file: 336 kB
examples/background/04.jpg ADDED

Git LFS Details

  • SHA256: 661a22b8d8442ad42d6dfa3e0ff563ed421ee7afab07d9bcf4ff5359f41c9d5f
  • Pointer size: 131 Bytes
  • Size of remote file: 511 kB
examples/background/05.jpg ADDED

Git LFS Details

  • SHA256: e311072b112866f7201474d83ba49eaa0fa695f2e589e83fd922d05e0c28195d
  • Pointer size: 131 Bytes
  • Size of remote file: 392 kB