giorgio-caparvi commited on
Commit
bed9a40
·
1 Parent(s): cc90697

First commit

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Dockerfile +28 -0
  2. api/Dockerfile_backend +14 -0
  3. api/app.py +66 -0
  4. api/environment.yml +58 -0
  5. api/model/.gitattributes +35 -0
  6. api/model/.gitignore +335 -0
  7. api/model/LICENSE +407 -0
  8. api/model/README_git.md +219 -0
  9. api/model/assets/data/dresscode/coarse_captions.json +0 -0
  10. api/model/assets/data/dresscode/dresses/im_sketch/052012_1.png +0 -0
  11. api/model/assets/data/dresscode/dresses/im_sketch_unpaired/052012_0_052033_1.png +0 -0
  12. api/model/assets/data/dresscode/dresses/keypoints/051994_2.json +1 -0
  13. api/model/assets/data/dresscode/dresses/keypoints/052012_2.json +1 -0
  14. api/model/assets/data/dresscode/dresses/label_maps/051994_4.png +0 -0
  15. api/model/assets/data/dresscode/dresses/label_maps/052012_4.png +0 -0
  16. api/model/assets/data/dresscode/dresses/test_pairs_paired.txt +1 -0
  17. api/model/assets/data/dresscode/dresses/test_pairs_unpaired.txt +1 -0
  18. api/model/assets/data/dresscode/fine_captions.json +0 -0
  19. api/model/assets/data/dresscode/lower_body/im_sketch/050855_1.png +0 -0
  20. api/model/assets/data/dresscode/lower_body/im_sketch/050915_1.png +0 -0
  21. api/model/assets/data/dresscode/lower_body/im_sketch_unpaired/050855_0_050908_1.png +0 -0
  22. api/model/assets/data/dresscode/lower_body/im_sketch_unpaired/050915_0_051078_1.png +0 -0
  23. api/model/assets/data/dresscode/lower_body/keypoints/050855_2.json +1 -0
  24. api/model/assets/data/dresscode/lower_body/keypoints/050915_2.json +1 -0
  25. api/model/assets/data/dresscode/lower_body/label_maps/050855_4.png +0 -0
  26. api/model/assets/data/dresscode/lower_body/label_maps/050915_4.png +0 -0
  27. api/model/assets/data/dresscode/lower_body/test_pairs_paired.txt +2 -0
  28. api/model/assets/data/dresscode/lower_body/test_pairs_unpaired.txt +2 -0
  29. api/model/assets/data/dresscode/test_stitchmap/048462_0.png +0 -0
  30. api/model/assets/data/dresscode/test_stitchmap/048466_0.png +0 -0
  31. api/model/assets/data/dresscode/test_stitchmap/050855_0.png +0 -0
  32. api/model/assets/data/dresscode/test_stitchmap/050915_0.png +0 -0
  33. api/model/assets/data/dresscode/test_stitchmap/051994_0.png +0 -0
  34. api/model/assets/data/dresscode/test_stitchmap/052012_0.png +0 -0
  35. api/model/assets/data/dresscode/upper_body/im_sketch/048462_1.png +0 -0
  36. api/model/assets/data/dresscode/upper_body/im_sketch_unpaired/048462_0_049951_1.png +0 -0
  37. api/model/assets/data/dresscode/upper_body/im_sketch_unpaired/048466_0_049534_1.png +0 -0
  38. api/model/assets/data/dresscode/upper_body/keypoints/048462_2.json +1 -0
  39. api/model/assets/data/dresscode/upper_body/keypoints/048466_2.json +1 -0
  40. api/model/assets/data/dresscode/upper_body/label_maps/048462_4.png +0 -0
  41. api/model/assets/data/dresscode/upper_body/label_maps/048466_4.png +0 -0
  42. api/model/assets/data/dresscode/upper_body/test_pairs_paired.txt +1 -0
  43. api/model/assets/data/dresscode/upper_body/test_pairs_unpaired.txt +1 -0
  44. api/model/assets/data/vitonhd/captions.json +0 -0
  45. api/model/assets/data/vitonhd/test/im_sketch/03191_00.png +0 -0
  46. api/model/assets/data/vitonhd/test/im_sketch/12419_00.png +0 -0
  47. api/model/assets/data/vitonhd/test/im_sketch_unpaired/03191_00_00349_00.png +0 -0
  48. api/model/assets/data/vitonhd/test/im_sketch_unpaired/12419_00_01944_00.png +0 -0
  49. api/model/assets/data/vitonhd/test/image-parse-v3/03191_00.png +0 -0
  50. api/model/assets/data/vitonhd/test/image-parse-v3/12419_00.png +0 -0
Dockerfile ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # syntax=docker/dockerfile:1.4
2
+
3
+ # Step 1: Setup backend environment with Miniconda
4
+ FROM continuumio/miniconda3:latest AS backend
5
+
6
+ # Create a non-root user for security purposes
7
+ RUN useradd -m -u 1000 user
8
+ USER user
9
+ ENV PATH="/home/user/.local/bin:$PATH"
10
+
11
+ # Set the working directory for the backend
12
+ WORKDIR /api
13
+
14
+ # Copy the environment file and install dependencies
15
+ COPY --chown=user api/environment.yml ./
16
+ RUN conda env create -f environment.yml && conda clean -a -y
17
+
18
+ # Ensure conda is initialized and available for subsequent RUN commands
19
+ SHELL ["conda", "run", "-n", "mgd", "/bin/bash", "-c"]
20
+
21
+ # Copy the backend application code
22
+ COPY --chown=user api/ .
23
+
24
+ # Expose port 7860 for the backend service
25
+ EXPOSE 7860
26
+
27
+ # Set default command to run the backend model using the specified port
28
+ CMD ["conda", "run", "-n", "mgd", "python", "app.py", "--port", "7860"]
api/Dockerfile_backend ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import conda
2
+ FROM continuumio/miniconda3:latest
3
+
4
+ RUN conda create -n mgd -y python=3.9
5
+ RUN conda activate mgd
6
+ RUN pip install torch==1.12.1 torchmetrics==0.11.0 opencv-python==4.7.0.68 diffusers==0.12.0 transformers==4.25.1 accelerate==0.15.0 clean-fid==0.1.35 torchmetrics[image]==0.11.0 flask
7
+
8
+
9
+ WORKDIR /app
10
+ #COPY requirements.txt requirements.txt
11
+ #RUN pip install -r requirements.txt
12
+ COPY . .
13
+
14
+ CMD ["python", "app.py"]
api/app.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ from flask_cors import CORS
3
+ #import base64
4
+ #from flask_limiter import Limiter
5
+ #from flask_limiter.util import get_remote_address
6
+
7
+ app = Flask(__name__)
8
+ #CORS(app, resources={r"/generate-design": {"origins": "https://uomolepre-github-io.vercel.app"}})
9
+
10
+ CORS(app, resources={r"/generate-design": {"origins": "*"}})
11
+
12
+ '''
13
+ limiter = Limiter(
14
+ get_remote_address,
15
+ app=app,
16
+ default_limits=["10 per minute"] # Limita a 10 richieste al minuto per ogni IP
17
+ )'''
18
+
19
+ @app.route('/generate-design', methods=['POST'])
20
+ #@limiter.limit("10 per minute")
21
+
22
+ def generate_design():
23
+ '''
24
+ data = request.json
25
+
26
+ # Extract image and json
27
+ image_data = data.get('image')
28
+ design_data = data.get('designData')
29
+
30
+ ## Extract image
31
+ if image_data:
32
+ image_bytes = base64.b64decode(image_data.split(',')[1]) # Decodifica la parte base64
33
+ with open("received_design.png", "wb") as image_file:
34
+ image_file.write(image_bytes)
35
+
36
+ # Update JSON
37
+ design_data['status'] = 'success'
38
+ design_data['message'] = 'Design received and processed'
39
+
40
+ return jsonify(design_data)
41
+ '''
42
+
43
+ command = [
44
+ 'python', 'app/model/src/eval.py',
45
+ '--dataset_path', './assets/data/vitonhd',
46
+ '--batch_size', '1',
47
+ '--mixed_precision', 'fp16',
48
+ '--output_dir', '../FINALE',
49
+ '--save_name', 'generato_paired',
50
+ '--num_workers_test', '4',
51
+ '--sketch_cond_rate', '0.2',
52
+ '--dataset', 'vitonhd',
53
+ '--start_cond_rate', '0.0',
54
+ '--test_order', 'paired'
55
+ ]
56
+
57
+ # Esegue il comando
58
+ try:
59
+ subprocess.run(command, check=True)
60
+ return jsonify({"status": "success", "message": "Command executed successfully"})
61
+ except subprocess.CalledProcessError as e:
62
+ return jsonify({"status": "error", "message": str(e)}), 500
63
+
64
+
65
+ if __name__ == '__main__':
66
+ app.run(host='0.0.0.0', port=7860)
api/environment.yml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: mgd
2
+ channels:
3
+ - defaults
4
+ dependencies:
5
+ - _libgcc_mutex=0.1=main
6
+ - _openmp_mutex=5.1=1_gnu
7
+ - ca-certificates=2023.08.22=h06a4308_0
8
+ - ld_impl_linux-64=2.38=h1181459_1
9
+ - libffi=3.4.4=h6a678d5_0
10
+ - libgcc-ng=11.2.0=h1234567_1
11
+ - libgomp=11.2.0=h1234567_1
12
+ - libstdcxx-ng=11.2.0=h1234567_1
13
+ - ncurses=6.4=h6a678d5_0
14
+ - openssl=3.0.11=h7f8727e_2
15
+ - pip=23.2.1=py39h06a4308_0
16
+ - python=3.9.18=h955ad1f_0
17
+ - readline=8.2=h5eee18b_0
18
+ - setuptools=68.0.0=py39h06a4308_0
19
+ - sqlite=3.41.2=h5eee18b_0
20
+ - tk=8.6.12=h1ccaba5_0
21
+ - tzdata=2023c=h04d1e81_0
22
+ - wheel=0.38.4=py39h06a4308_0
23
+ - xz=5.4.2=h5eee18b_0
24
+ - zlib=1.2.13=h5eee18b_0
25
+ - pip:
26
+ - accelerate==0.15.0
27
+ - certifi==2023.7.22
28
+ - charset-normalizer==3.2.0
29
+ - clean-fid==0.1.35
30
+ - diffusers==0.12.0
31
+ - filelock==3.12.4
32
+ - flask
33
+ - flask-cors
34
+ - fsspec==2023.9.1
35
+ - huggingface-hub==0.17.2
36
+ - idna==3.4
37
+ - importlib-metadata==6.8.0
38
+ - lpips==0.1.4
39
+ - numpy==1.26.0
40
+ - opencv-python==4.7.0.68
41
+ - packaging==23.1
42
+ - pillow==10.0.1
43
+ - psutil==5.9.5
44
+ - pyyaml==6.0.1
45
+ - regex==2023.8.8
46
+ - requests==2.31.0
47
+ - scipy==1.11.2
48
+ - tokenizers==0.13.3
49
+ - torch==1.12.1
50
+ - torch-fidelity==0.3.0
51
+ - torchmetrics==0.11.0
52
+ - torchmetrics[image]==0.11.0
53
+ - torchvision==0.13.1
54
+ - tqdm==4.66.1
55
+ - transformers==4.25.1
56
+ - typing-extensions==4.8.0
57
+ - urllib3==2.0.5
58
+ - zipp==3.17.0
api/model/.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
api/model/.gitignore ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by https://www.toptal.com/developers/gitignore/api/pycharm,visualstudiocode,opencv,python,git
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=pycharm,visualstudiocode,opencv,python,git
3
+
4
+ ### Git ###
5
+ # Created by git for backups. To disable backups in Git:
6
+ # $ git config --global mergetool.keepBackup false
7
+ *.orig
8
+
9
+ # Created by git when using merge tools for conflicts
10
+ *.BACKUP.*
11
+ *.BASE.*
12
+ *.LOCAL.*
13
+ *.REMOTE.*
14
+ *_BACKUP_*.txt
15
+ *_BASE_*.txt
16
+ *_LOCAL_*.txt
17
+ *_REMOTE_*.txt
18
+
19
+ ### OpenCV ###
20
+ #OpenCV for Mac and Linux
21
+ #build and release folders
22
+ */CMakeFiles
23
+ */CMakeCache.txt
24
+ */Makefile
25
+ */cmake_install.cmake
26
+ .DS_Store
27
+
28
+ ### PyCharm ###
29
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
30
+ # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
31
+
32
+ # User-specific stuff
33
+ .idea/**/workspace.xml
34
+ .idea/**/tasks.xml
35
+ .idea/**/usage.statistics.xml
36
+ .idea/**/dictionaries
37
+ .idea/**/shelf
38
+
39
+ # AWS User-specific
40
+ .idea/**/aws.xml
41
+
42
+ # Generated files
43
+ .idea/**/contentModel.xml
44
+
45
+ # Sensitive or high-churn files
46
+ .idea/**/dataSources/
47
+ .idea/**/dataSources.ids
48
+ .idea/**/dataSources.local.xml
49
+ .idea/**/sqlDataSources.xml
50
+ .idea/**/dynamic.xml
51
+ .idea/**/uiDesigner.xml
52
+ .idea/**/dbnavigator.xml
53
+
54
+ # Gradle
55
+ .idea/**/gradle.xml
56
+ .idea/**/libraries
57
+
58
+ # Gradle and Maven with auto-import
59
+ # When using Gradle or Maven with auto-import, you should exclude module files,
60
+ # since they will be recreated, and may cause churn. Uncomment if using
61
+ # auto-import.
62
+ # .idea/artifacts
63
+ # .idea/compiler.xml
64
+ # .idea/jarRepositories.xml
65
+ # .idea/modules.xml
66
+ # .idea/*.iml
67
+ # .idea/modules
68
+ # *.iml
69
+ # *.ipr
70
+
71
+ # CMake
72
+ cmake-build-*/
73
+
74
+ # Mongo Explorer plugin
75
+ .idea/**/mongoSettings.xml
76
+
77
+ # File-based project format
78
+ *.iws
79
+
80
+ # IntelliJ
81
+ out/
82
+
83
+ # mpeltonen/sbt-idea plugin
84
+ .idea_modules/
85
+
86
+ # JIRA plugin
87
+ atlassian-ide-plugin.xml
88
+
89
+ # Cursive Clojure plugin
90
+ .idea/replstate.xml
91
+
92
+ # SonarLint plugin
93
+ .idea/sonarlint/
94
+
95
+ # Crashlytics plugin (for Android Studio and IntelliJ)
96
+ com_crashlytics_export_strings.xml
97
+ crashlytics.properties
98
+ crashlytics-build.properties
99
+ fabric.properties
100
+
101
+ # Editor-based Rest Client
102
+ .idea/httpRequests
103
+
104
+ # Android studio 3.1+ serialized cache file
105
+ .idea/caches/build_file_checksums.ser
106
+
107
+ ### PyCharm Patch ###
108
+ # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
109
+
110
+ # *.iml
111
+ # modules.xml
112
+ # .idea/misc.xml
113
+ # *.ipr
114
+
115
+ # Sonarlint plugin
116
+ # https://plugins.jetbrains.com/plugin/7973-sonarlint
117
+ .idea/**/sonarlint/
118
+
119
+ # SonarQube Plugin
120
+ # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
121
+ .idea/**/sonarIssues.xml
122
+
123
+ # Markdown Navigator plugin
124
+ # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
125
+ .idea/**/markdown-navigator.xml
126
+ .idea/**/markdown-navigator-enh.xml
127
+ .idea/**/markdown-navigator/
128
+
129
+ # Cache file creation bug
130
+ # See https://youtrack.jetbrains.com/issue/JBR-2257
131
+ .idea/$CACHE_FILE$
132
+
133
+ # CodeStream plugin
134
+ # https://plugins.jetbrains.com/plugin/12206-codestream
135
+ .idea/codestream.xml
136
+
137
+ # Azure Toolkit for IntelliJ plugin
138
+ # https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
139
+ .idea/**/azureSettings.xml
140
+
141
+ ### Python ###
142
+ # Byte-compiled / optimized / DLL files
143
+ __pycache__/
144
+ *.py[cod]
145
+ *$py.class
146
+
147
+ # C extensions
148
+ *.so
149
+
150
+ # Distribution / packaging
151
+ .Python
152
+ build/
153
+ develop-eggs/
154
+ dist/
155
+ downloads/
156
+ eggs/
157
+ .eggs/
158
+ lib/
159
+ lib64/
160
+ parts/
161
+ sdist/
162
+ var/
163
+ wheels/
164
+ share/python-wheels/
165
+ *.egg-info/
166
+ .installed.cfg
167
+ *.egg
168
+ MANIFEST
169
+
170
+ # PyInstaller
171
+ # Usually these files are written by a python script from a template
172
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
173
+ *.manifest
174
+ *.spec
175
+
176
+ # Installer logs
177
+ pip-log.txt
178
+ pip-delete-this-directory.txt
179
+
180
+ # Unit test / coverage reports
181
+ htmlcov/
182
+ .tox/
183
+ .nox/
184
+ .coverage
185
+ .coverage.*
186
+ .cache
187
+ nosetests.xml
188
+ coverage.xml
189
+ *.cover
190
+ *.py,cover
191
+ .hypothesis/
192
+ .pytest_cache/
193
+ cover/
194
+
195
+ # Translations
196
+ *.mo
197
+ *.pot
198
+
199
+ # Django stuff:
200
+ *.log
201
+ local_settings.py
202
+ db.sqlite3
203
+ db.sqlite3-journal
204
+
205
+ # Flask stuff:
206
+ instance/
207
+ .webassets-cache
208
+
209
+ # Scrapy stuff:
210
+ .scrapy
211
+
212
+ # Sphinx documentation
213
+ docs/_build/
214
+
215
+ # PyBuilder
216
+ .pybuilder/
217
+ target/
218
+
219
+ # Jupyter Notebook
220
+ .ipynb_checkpoints
221
+
222
+ # IPython
223
+ profile_default/
224
+ ipython_config.py
225
+
226
+ # pyenv
227
+ # For a library or package, you might want to ignore these files since the code is
228
+ # intended to run in multiple environments; otherwise, check them in:
229
+ # .python-version
230
+
231
+ # pipenv
232
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
233
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
234
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
235
+ # install all needed dependencies.
236
+ #Pipfile.lock
237
+
238
+ # poetry
239
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
240
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
241
+ # commonly ignored for libraries.
242
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
243
+ #poetry.lock
244
+
245
+ # pdm
246
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
247
+ #pdm.lock
248
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
249
+ # in version control.
250
+ # https://pdm.fming.dev/#use-with-ide
251
+ .pdm.toml
252
+
253
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
254
+ __pypackages__/
255
+
256
+ # Celery stuff
257
+ celerybeat-schedule
258
+ celerybeat.pid
259
+
260
+ # SageMath parsed files
261
+ *.sage.py
262
+
263
+ # Environments
264
+ .env
265
+ .venv
266
+ env/
267
+ venv/
268
+ ENV/
269
+ env.bak/
270
+ venv.bak/
271
+
272
+ # Spyder project settings
273
+ .spyderproject
274
+ .spyproject
275
+
276
+ # Rope project settings
277
+ .ropeproject
278
+
279
+ # mkdocs documentation
280
+ /site
281
+
282
+ # mypy
283
+ .mypy_cache/
284
+ .dmypy.json
285
+ dmypy.json
286
+
287
+ # Pyre type checker
288
+ .pyre/
289
+
290
+ # pytype static type analyzer
291
+ .pytype/
292
+
293
+ # Cython debug symbols
294
+ cython_debug/
295
+
296
+ # PyCharm
297
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
298
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
299
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
300
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
301
+ .idea/
302
+
303
+ ### Python Patch ###
304
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
305
+ poetry.toml
306
+
307
+ # ruff
308
+ .ruff_cache/
309
+
310
+ # LSP config files
311
+ pyrightconfig.json
312
+
313
+ ### VisualStudioCode ###
314
+ .vscode/*
315
+ !.vscode/settings.json
316
+ !.vscode/tasks.json
317
+ !.vscode/launch.json
318
+ !.vscode/extensions.json
319
+ !.vscode/*.code-snippets
320
+
321
+ # Local History for Visual Studio Code
322
+ .history/
323
+
324
+ # Built Visual Studio Code Extensions
325
+ *.vsix
326
+
327
+ ### VisualStudioCode Patch ###
328
+ # Ignore all local history of files
329
+ .history
330
+ .ionide
331
+
332
+
333
+ images/
334
+
335
+ # End of https://www.toptal.com/developers/gitignore/api/pycharm,visualstudiocode,opencv,python,git
api/model/LICENSE ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution-NonCommercial 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More_considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution-NonCommercial 4.0 International Public
58
+ License
59
+
60
+ By exercising the Licensed Rights (defined below), You accept and agree
61
+ to be bound by the terms and conditions of this Creative Commons
62
+ Attribution-NonCommercial 4.0 International Public License ("Public
63
+ License"). To the extent this Public License may be interpreted as a
64
+ contract, You are granted the Licensed Rights in consideration of Your
65
+ acceptance of these terms and conditions, and the Licensor grants You
66
+ such rights in consideration of benefits the Licensor receives from
67
+ making the Licensed Material available under these terms and
68
+ conditions.
69
+
70
+
71
+ Section 1 -- Definitions.
72
+
73
+ a. Adapted Material means material subject to Copyright and Similar
74
+ Rights that is derived from or based upon the Licensed Material
75
+ and in which the Licensed Material is translated, altered,
76
+ arranged, transformed, or otherwise modified in a manner requiring
77
+ permission under the Copyright and Similar Rights held by the
78
+ Licensor. For purposes of this Public License, where the Licensed
79
+ Material is a musical work, performance, or sound recording,
80
+ Adapted Material is always produced where the Licensed Material is
81
+ synched in timed relation with a moving image.
82
+
83
+ b. Adapter's License means the license You apply to Your Copyright
84
+ and Similar Rights in Your contributions to Adapted Material in
85
+ accordance with the terms and conditions of this Public License.
86
+
87
+ c. Copyright and Similar Rights means copyright and/or similar rights
88
+ closely related to copyright including, without limitation,
89
+ performance, broadcast, sound recording, and Sui Generis Database
90
+ Rights, without regard to how the rights are labeled or
91
+ categorized. For purposes of this Public License, the rights
92
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
93
+ Rights.
94
+ d. Effective Technological Measures means those measures that, in the
95
+ absence of proper authority, may not be circumvented under laws
96
+ fulfilling obligations under Article 11 of the WIPO Copyright
97
+ Treaty adopted on December 20, 1996, and/or similar international
98
+ agreements.
99
+
100
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
101
+ any other exception or limitation to Copyright and Similar Rights
102
+ that applies to Your use of the Licensed Material.
103
+
104
+ f. Licensed Material means the artistic or literary work, database,
105
+ or other material to which the Licensor applied this Public
106
+ License.
107
+
108
+ g. Licensed Rights means the rights granted to You subject to the
109
+ terms and conditions of this Public License, which are limited to
110
+ all Copyright and Similar Rights that apply to Your use of the
111
+ Licensed Material and that the Licensor has authority to license.
112
+
113
+ h. Licensor means the individual(s) or entity(ies) granting rights
114
+ under this Public License.
115
+
116
+ i. NonCommercial means not primarily intended for or directed towards
117
+ commercial advantage or monetary compensation. For purposes of
118
+ this Public License, the exchange of the Licensed Material for
119
+ other material subject to Copyright and Similar Rights by digital
120
+ file-sharing or similar means is NonCommercial provided there is
121
+ no payment of monetary compensation in connection with the
122
+ exchange.
123
+
124
+ j. Share means to provide material to the public by any means or
125
+ process that requires permission under the Licensed Rights, such
126
+ as reproduction, public display, public performance, distribution,
127
+ dissemination, communication, or importation, and to make material
128
+ available to the public including in ways that members of the
129
+ public may access the material from a place and at a time
130
+ individually chosen by them.
131
+
132
+ k. Sui Generis Database Rights means rights other than copyright
133
+ resulting from Directive 96/9/EC of the European Parliament and of
134
+ the Council of 11 March 1996 on the legal protection of databases,
135
+ as amended and/or succeeded, as well as other essentially
136
+ equivalent rights anywhere in the world.
137
+
138
+ l. You means the individual or entity exercising the Licensed Rights
139
+ under this Public License. Your has a corresponding meaning.
140
+
141
+
142
+ Section 2 -- Scope.
143
+
144
+ a. License grant.
145
+
146
+ 1. Subject to the terms and conditions of this Public License,
147
+ the Licensor hereby grants You a worldwide, royalty-free,
148
+ non-sublicensable, non-exclusive, irrevocable license to
149
+ exercise the Licensed Rights in the Licensed Material to:
150
+
151
+ a. reproduce and Share the Licensed Material, in whole or
152
+ in part, for NonCommercial purposes only; and
153
+
154
+ b. produce, reproduce, and Share Adapted Material for
155
+ NonCommercial purposes only.
156
+
157
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
158
+ Exceptions and Limitations apply to Your use, this Public
159
+ License does not apply, and You do not need to comply with
160
+ its terms and conditions.
161
+
162
+ 3. Term. The term of this Public License is specified in Section
163
+ 6(a).
164
+
165
+ 4. Media and formats; technical modifications allowed. The
166
+ Licensor authorizes You to exercise the Licensed Rights in
167
+ all media and formats whether now known or hereafter created,
168
+ and to make technical modifications necessary to do so. The
169
+ Licensor waives and/or agrees not to assert any right or
170
+ authority to forbid You from making technical modifications
171
+ necessary to exercise the Licensed Rights, including
172
+ technical modifications necessary to circumvent Effective
173
+ Technological Measures. For purposes of this Public License,
174
+ simply making modifications authorized by this Section 2(a)
175
+ (4) never produces Adapted Material.
176
+
177
+ 5. Downstream recipients.
178
+
179
+ a. Offer from the Licensor -- Licensed Material. Every
180
+ recipient of the Licensed Material automatically
181
+ receives an offer from the Licensor to exercise the
182
+ Licensed Rights under the terms and conditions of this
183
+ Public License.
184
+
185
+ b. No downstream restrictions. You may not offer or impose
186
+ any additional or different terms or conditions on, or
187
+ apply any Effective Technological Measures to, the
188
+ Licensed Material if doing so restricts exercise of the
189
+ Licensed Rights by any recipient of the Licensed
190
+ Material.
191
+
192
+ 6. No endorsement. Nothing in this Public License constitutes or
193
+ may be construed as permission to assert or imply that You
194
+ are, or that Your use of the Licensed Material is, connected
195
+ with, or sponsored, endorsed, or granted official status by,
196
+ the Licensor or others designated to receive attribution as
197
+ provided in Section 3(a)(1)(A)(i).
198
+
199
+ b. Other rights.
200
+
201
+ 1. Moral rights, such as the right of integrity, are not
202
+ licensed under this Public License, nor are publicity,
203
+ privacy, and/or other similar personality rights; however, to
204
+ the extent possible, the Licensor waives and/or agrees not to
205
+ assert any such rights held by the Licensor to the limited
206
+ extent necessary to allow You to exercise the Licensed
207
+ Rights, but not otherwise.
208
+
209
+ 2. Patent and trademark rights are not licensed under this
210
+ Public License.
211
+
212
+ 3. To the extent possible, the Licensor waives any right to
213
+ collect royalties from You for the exercise of the Licensed
214
+ Rights, whether directly or through a collecting society
215
+ under any voluntary or waivable statutory or compulsory
216
+ licensing scheme. In all other cases the Licensor expressly
217
+ reserves any right to collect such royalties, including when
218
+ the Licensed Material is used other than for NonCommercial
219
+ purposes.
220
+
221
+
222
+ Section 3 -- License Conditions.
223
+
224
+ Your exercise of the Licensed Rights is expressly made subject to the
225
+ following conditions.
226
+
227
+ a. Attribution.
228
+
229
+ 1. If You Share the Licensed Material (including in modified
230
+ form), You must:
231
+
232
+ a. retain the following if it is supplied by the Licensor
233
+ with the Licensed Material:
234
+
235
+ i. identification of the creator(s) of the Licensed
236
+ Material and any others designated to receive
237
+ attribution, in any reasonable manner requested by
238
+ the Licensor (including by pseudonym if
239
+ designated);
240
+
241
+ ii. a copyright notice;
242
+
243
+ iii. a notice that refers to this Public License;
244
+
245
+ iv. a notice that refers to the disclaimer of
246
+ warranties;
247
+
248
+ v. a URI or hyperlink to the Licensed Material to the
249
+ extent reasonably practicable;
250
+
251
+ b. indicate if You modified the Licensed Material and
252
+ retain an indication of any previous modifications; and
253
+
254
+ c. indicate the Licensed Material is licensed under this
255
+ Public License, and include the text of, or the URI or
256
+ hyperlink to, this Public License.
257
+
258
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
259
+ reasonable manner based on the medium, means, and context in
260
+ which You Share the Licensed Material. For example, it may be
261
+ reasonable to satisfy the conditions by providing a URI or
262
+ hyperlink to a resource that includes the required
263
+ information.
264
+
265
+ 3. If requested by the Licensor, You must remove any of the
266
+ information required by Section 3(a)(1)(A) to the extent
267
+ reasonably practicable.
268
+
269
+ 4. If You Share Adapted Material You produce, the Adapter's
270
+ License You apply must not prevent recipients of the Adapted
271
+ Material from complying with this Public License.
272
+
273
+
274
+ Section 4 -- Sui Generis Database Rights.
275
+
276
+ Where the Licensed Rights include Sui Generis Database Rights that
277
+ apply to Your use of the Licensed Material:
278
+
279
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
280
+ to extract, reuse, reproduce, and Share all or a substantial
281
+ portion of the contents of the database for NonCommercial purposes
282
+ only;
283
+
284
+ b. if You include all or a substantial portion of the database
285
+ contents in a database in which You have Sui Generis Database
286
+ Rights, then the database in which You have Sui Generis Database
287
+ Rights (but not its individual contents) is Adapted Material; and
288
+
289
+ c. You must comply with the conditions in Section 3(a) if You Share
290
+ all or a substantial portion of the contents of the database.
291
+
292
+ For the avoidance of doubt, this Section 4 supplements and does not
293
+ replace Your obligations under this Public License where the Licensed
294
+ Rights include other Copyright and Similar Rights.
295
+
296
+
297
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
298
+
299
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
300
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
301
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
302
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
303
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
304
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
305
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
306
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
307
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
308
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
309
+
310
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
311
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
312
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
313
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
314
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
315
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
316
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
317
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
318
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
319
+
320
+ c. The disclaimer of warranties and limitation of liability provided
321
+ above shall be interpreted in a manner that, to the extent
322
+ possible, most closely approximates an absolute disclaimer and
323
+ waiver of all liability.
324
+
325
+
326
+ Section 6 -- Term and Termination.
327
+
328
+ a. This Public License applies for the term of the Copyright and
329
+ Similar Rights licensed here. However, if You fail to comply with
330
+ this Public License, then Your rights under this Public License
331
+ terminate automatically.
332
+
333
+ b. Where Your right to use the Licensed Material has terminated under
334
+ Section 6(a), it reinstates:
335
+
336
+ 1. automatically as of the date the violation is cured, provided
337
+ it is cured within 30 days of Your discovery of the
338
+ violation; or
339
+
340
+ 2. upon express reinstatement by the Licensor.
341
+
342
+ For the avoidance of doubt, this Section 6(b) does not affect any
343
+ right the Licensor may have to seek remedies for Your violations
344
+ of this Public License.
345
+
346
+ c. For the avoidance of doubt, the Licensor may also offer the
347
+ Licensed Material under separate terms or conditions or stop
348
+ distributing the Licensed Material at any time; however, doing so
349
+ will not terminate this Public License.
350
+
351
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
352
+ License.
353
+
354
+
355
+ Section 7 -- Other Terms and Conditions.
356
+
357
+ a. The Licensor shall not be bound by any additional or different
358
+ terms or conditions communicated by You unless expressly agreed.
359
+
360
+ b. Any arrangements, understandings, or agreements regarding the
361
+ Licensed Material not stated herein are separate from and
362
+ independent of the terms and conditions of this Public License.
363
+
364
+
365
+ Section 8 -- Interpretation.
366
+
367
+ a. For the avoidance of doubt, this Public License does not, and
368
+ shall not be interpreted to, reduce, limit, restrict, or impose
369
+ conditions on any use of the Licensed Material that could lawfully
370
+ be made without permission under this Public License.
371
+
372
+ b. To the extent possible, if any provision of this Public License is
373
+ deemed unenforceable, it shall be automatically reformed to the
374
+ minimum extent necessary to make it enforceable. If the provision
375
+ cannot be reformed, it shall be severed from this Public License
376
+ without affecting the enforceability of the remaining terms and
377
+ conditions.
378
+
379
+ c. No term or condition of this Public License will be waived and no
380
+ failure to comply consented to unless expressly agreed to by the
381
+ Licensor.
382
+
383
+ d. Nothing in this Public License constitutes or may be interpreted
384
+ as a limitation upon, or waiver of, any privileges and immunities
385
+ that apply to the Licensor or You, including from the legal
386
+ processes of any jurisdiction or authority.
387
+
388
+ =======================================================================
389
+
390
+ Creative Commons is not a party to its public
391
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
392
+ its public licenses to material it publishes and in those instances
393
+ will be considered the "Licensor." The text of the Creative Commons
394
+ public licenses is dedicated to the public domain under the CC0 Public
395
+ Domain Dedication. Except for the limited purpose of indicating that
396
+ material is shared under a Creative Commons public license or as
397
+ otherwise permitted by the Creative Commons policies published at
398
+ creativecommons.org/policies, Creative Commons does not authorize the
399
+ use of the trademark "Creative Commons" or any other trademark or logo
400
+ of Creative Commons without its prior written consent including,
401
+ without limitation, in connection with any unauthorized modifications
402
+ to any of its public licenses or any other arrangements,
403
+ understandings, or agreements concerning use of licensed material. For
404
+ the avoidance of doubt, this paragraph does not form part of the
405
+ public licenses.
406
+
407
+ Creative Commons may be contacted at creativecommons.org.
api/model/README_git.md ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Multimodal Garment Designer (ICCV 2023)
2
+ ### Human-Centric Latent Diffusion Models for Fashion Image Editing
3
+ [**Alberto Baldrati**](https://scholar.google.com/citations?hl=en&user=I1jaZecAAAAJ)**\***,
4
+ [**Davide Morelli**](https://scholar.google.com/citations?user=UJ4D3rYAAAAJ&hl=en)**\***,
5
+ [**Giuseppe Cartella**](https://scholar.google.com/citations?hl=en&user=0sJ4VCcAAAAJ),
6
+ [**Marcella Cornia**](https://scholar.google.com/citations?hl=en&user=DzgmSJEAAAAJ),
7
+ [**Marco Bertini**](https://scholar.google.com/citations?user=SBm9ZpYAAAAJ&hl=en),
8
+ [**Rita Cucchiara**](https://scholar.google.com/citations?hl=en&user=OM3sZEoAAAAJ)
9
+
10
+ **\*** Equal contribution.
11
+
12
+ [![arXiv](https://img.shields.io/badge/arXiv-Paper-<COLOR>.svg)](https://arxiv.org/abs/2304.02051)
13
+ [![GitHub Stars](https://img.shields.io/github/stars/aimagelab/multimodal-garment-designer?style=social)](https://github.com/aimagelab/multimodal-garment-designer)
14
+
15
+ This is the **official repository** for the [**paper**](https://arxiv.org/abs/2304.02051) "*Multimodal Garment Designer: Human-Centric Latent Diffusion Models for Fashion Image Editing*".
16
+
17
+ 🔥🔥 **[21/03/2024] If you are interested in multimodal fashion image editing take a look at our most recent work [Multimodal-Conditioned Latent Diffusion Models for Fashion Image Editing](https://arxiv.org/abs/2403.14828). We introduce Ti-MGD a novel approach that also integrates fabric texture conditioning [![Repo](https://badgen.net/badge/icon/GitHub?icon=github&label)](https://github.com/aimagelab/Ti-MGD)**
18
+
19
+ ## Overview
20
+
21
+ <p align="center">
22
+ <img src="images/1.gif" style="max-width:500px">
23
+ </p>
24
+
25
+ >**Abstract**: <br>
26
+ > Fashion illustration is used by designers to communicate their vision and to bring the design idea from conceptualization to realization, showing how clothes interact with the human body. In this context, computer vision can thus be used to improve the fashion design process. Differently from previous works that mainly focused on the virtual try-on of garments, we propose the task of multimodal-conditioned fashion image editing, guiding the generation of human-centric fashion images by following multimodal prompts, such as text, human body poses, and garment sketches. We tackle this problem by proposing a new architecture based on latent diffusion models, an approach that has not been used before in the fashion domain. Given the lack of existing datasets suitable for the task, we also extend two existing fashion datasets, namely Dress Code and VITON-HD, with multimodal annotations collected in a semi-automatic manner. Experimental results on these new datasets demonstrate the effectiveness of our proposal, both in terms of realism and coherence with the given multimodal inputs.
27
+
28
+ ## Citation
29
+ If you make use of our work, please cite our paper:
30
+
31
+ ```bibtex
32
+ @inproceedings{baldrati2023multimodal,
33
+ title={Multimodal Garment Designer: Human-Centric Latent Diffusion Models for Fashion Image Editing},
34
+ author={Baldrati, Alberto and Morelli, Davide and Cartella, Giuseppe and Cornia, Marcella and Bertini, Marco and Cucchiara, Rita},
35
+ booktitle={Proceedings of the IEEE/CVF International Conference on Computer Vision},
36
+ year={2023}
37
+ }
38
+ ```
39
+
40
+ ## Getting Started
41
+
42
+ We recommend using the [**Anaconda**](https://www.anaconda.com/) package manager to avoid dependency/reproducibility
43
+ problems.
44
+ For Linux systems, you can find a conda installation
45
+ guide [here](https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html).
46
+
47
+ ### Installation
48
+
49
+ 1. Clone the repository
50
+
51
+ ```sh
52
+ git clone https://github.com/aimagelab/multimodal-garment-designer
53
+ ```
54
+
55
+ 2. Install Python dependencies
56
+
57
+ ```sh
58
+ conda env create -n mgd -f environment.yml
59
+ conda activate mgd
60
+ ```
61
+
62
+ Alternatively, you can create a new conda environment and install the required packages manually:
63
+
64
+ ```sh
65
+ conda create -n mgd -y python=3.9
66
+ conda activate mgd
67
+ pip install torch==1.12.1 torchmetrics==0.11.0 opencv-python==4.7.0.68 diffusers==0.12.0 transformers==4.25.1 accelerate==0.15.0 clean-fid==0.1.35 torchmetrics[image]==0.11.0
68
+ ```
69
+
70
+ ## Inference
71
+
72
+ To run the inference please use the following:
73
+
74
+ ```
75
+ python src/eval.py --dataset_path <path> --batch_size <int> --mixed_precision fp16 --output_dir <path> --save_name <string> --num_workers_test <int> --sketch_cond_rate 0.2 --dataset <dresscode|vitonhd> --start_cond_rate 0.0 --test_order <paired|unpaired>
76
+ ```
77
+
78
+ - ```dataset_path``` is the path to the dataset (change accordingly to the dataset parameter)
79
+ - ```dataset``` dataset name to be used
80
+ - ```output_dir``` path to the output directory
81
+ - ```save_name``` name of the output dir subfolder where the generated images are saved
82
+ - ```start_cond_rate``` rate {0.0,1.0} of denoising steps that will be used as offset to start sketch conditioning
83
+ - ```sketch_cond_rate``` rate {0.0,1.0} of denoising steps in which sketch cond is applied
84
+ - ```test_order``` test setting (paired | unpaired)
85
+
86
+ Note that we provide a few sample images to test MGD simply by cloning this repo (*i.e.*, assets/data). To execute the code set
87
+ - Dress Code Multimodal dataset
88
+ - ```dataset_path``` to ```../assets/data/dresscode```
89
+ - ```dataset``` to ```dresscode```
90
+ - Viton-HD Multimodal dataset
91
+ - ```dataset_path``` to ```../assets/data/vitonhd```
92
+ - ```dataset``` to ```vitonhd```
93
+
94
+ It is possible to run the inference on the whole Dress Code Multimodal or Viton-HD Multimodal dataset simply changing the ```dataset_path``` and ```dataset``` according with the downloaded and prepared datasets (see sections below).
95
+
96
+
97
+ ## Pre-trained models
98
+ The model and checkpoints are available via torch.hub.
99
+
100
+ Load the MGD denoising UNet model using the following code:
101
+
102
+ ```
103
+ import torch
104
+ unet = torch.hub.load(
105
+ dataset=<dataset>,
106
+ repo_or_dir='aimagelab/multimodal-garment-designer',
107
+ source='github',
108
+ model='mgd',
109
+ pretrained=True
110
+ )
111
+ ```
112
+
113
+ - ```dataset``` dataset name (dresscode | vitonhd)
114
+
115
+ Use the denoising network with our custom diffusers pipeline as follow:
116
+
117
+ ```
118
+ from src.mgd_pipelines.mgd_pipe import MGDPipe
119
+ from diffusers import AutoencoderKL, DDIMScheduler
120
+ from transformers import CLIPTextModel, CLIPTokenizer
121
+
122
+ pretrained_model_name_or_path = "runwayml/stable-diffusion-inpainting"
123
+
124
+ text_encoder = CLIPTextModel.from_pretrained(
125
+ pretrained_model_name_or_path,
126
+ subfolder="text_encoder"
127
+ )
128
+
129
+ vae = AutoencoderKL.from_pretrained(
130
+ pretrained_model_name_or_path,
131
+ subfolder="vae"
132
+ )
133
+
134
+ tokenizer = CLIPTokenizer.from_pretrained(
135
+ pretrained_model_name_or_path,
136
+ subfolder="tokenizer",
137
+ )
138
+
139
+ val_scheduler = DDIMScheduler.from_pretrained(
140
+ pretrained_model_name_or_path,
141
+ subfolder="scheduler"
142
+ )
143
+ val_scheduler.set_timesteps(50)
144
+
145
+ mgd_pipe = MGDPipe(
146
+ text_encoder=text_encoder,
147
+ vae=vae,
148
+ unet=unet,
149
+ tokenizer=tokenizer,
150
+ scheduler=val_scheduler,
151
+ )
152
+ ```
153
+
154
+ For an extensive usage case see the file ```eval.py``` in the main repo.
155
+
156
+ ## Datasets
157
+ We do not hold rights on the original Dress Code and Viton-HD datasets. Please refer to the original papers for more information.
158
+
159
+ Start by downloading the original datasets from the following links:
160
+ - Viton-HD **[[link](https://github.com/shadow2496/VITON-HD)]**
161
+ - Dress Code **[[link](https://github.com/aimagelab/dress-code)]**
162
+
163
+
164
+ Download the Dress Code Multimodal and Viton-HD Multimodal additional data annotations from here.
165
+
166
+ - Dress Code Multimodal **[[link](https://drive.google.com/file/d/1dwnAi1CNmmF_YdbIDfm8078dGh4ci47L/view?usp=sharing)]**
167
+ - Viton-HD Multimodal **[[link](https://drive.google.com/file/d/1Z2b9YkyBPA_9ZDC54Y5muW9Q8yfAqWSH/view?usp=sharing)]**
168
+
169
+ ### Dress Code Multimodal Data Preparation
170
+ Once data is downloaded prepare the dataset folder as follows:
171
+
172
+ <pre>
173
+ Dress Code
174
+ | <b>fine_captions.json</b>
175
+ | <b>coarse_captions.json</b>
176
+ | test_pairs_paired.txt
177
+ | test_pairs_unpaired.txt
178
+ | train_pairs.txt
179
+ | <b>test_stitch_map</b>
180
+ |---- [category]
181
+ |-------- images
182
+ |-------- keypoints
183
+ |-------- skeletons
184
+ |-------- dense
185
+ |-------- <b>im_sketch</b>
186
+ |-------- <b>im_sketch_unpaired</b>
187
+ ...
188
+ </pre>
189
+
190
+ ### Viton-HD Multimodal Data Preparation
191
+ Once data is downloaded prepare the dataset folder as follows:
192
+
193
+ <pre>
194
+ Viton-HD
195
+ | <b>captions.json</b>
196
+ |---- train
197
+ |-------- image
198
+ |-------- cloth
199
+ |-------- image-parse-v3
200
+ |-------- openpose_json
201
+ |-------- <b>im_sketch</b>
202
+ |-------- <b>im_sketch_unpaired</b>
203
+ ...
204
+ |---- test
205
+ ...
206
+ |-------- <b>im_sketch</b>
207
+ |-------- <b>im_sketch_unpaired</b>
208
+ ...
209
+ </pre>
210
+
211
+
212
+ ## TODO
213
+ - [ ] training code
214
+
215
+ ## Acknowledgements
216
+ This work has partially been supported by the PNRR project “Future Artificial Intelligence Research (FAIR)”, by the PRIN project “CREATIVE: CRoss-modal understanding and gEnerATIon of Visual and tExtual content” (CUP B87G22000460001), both co-funded by the Italian Ministry of University and Research, and by the European Commission under European Horizon 2020 Programme, grant number 101004545 - ReInHerit.
217
+
218
+ ## LICENSE
219
+ <a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc/4.0/88x31.png" /></a><br />All material is available under [Creative Commons BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/). You can **use, redistribute, and adapt** the material for **non-commercial purposes**, as long as you give appropriate credit by **citing our paper** and **indicate any changes** you've made.
api/model/assets/data/dresscode/coarse_captions.json ADDED
The diff for this file is too large to render. See raw diff
 
api/model/assets/data/dresscode/dresses/im_sketch/052012_1.png ADDED
api/model/assets/data/dresscode/dresses/im_sketch_unpaired/052012_0_052033_1.png ADDED
api/model/assets/data/dresscode/dresses/keypoints/051994_2.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"keypoints": [[205.0, 0.0, 0.7454180121421814, 0.0], [193.0, 54.0, 0.9695595502853394, 1.0], [153.0, 46.0, 0.9210028052330017, 2.0], [163.0, 133.0, 0.8196305632591248, 3.0], [182.0, 193.0, 0.8251658082008362, 4.0], [234.0, 59.0, 0.9184455871582031, 5.0], [252.0, 133.0, 0.9567239880561829, 6.0], [186.0, 139.0, 0.8934434652328491, 7.0], [180.0, 199.0, 0.803178071975708, 8.0], [164.0, 323.0, 0.9721584916114807, 9.0], [140.0, 438.0, 0.8884657025337219, 10.0], [230.0, 199.0, 0.7910050749778748, 11.0], [223.0, 322.0, 0.8632205128669739, 12.0], [211.0, 436.0, 0.8701340556144714, 13.0], [197.0, 0.0, 0.5216715931892395, 14.0], [214.0, 0.0, 0.610032856464386, 15.0], [186.0, 0.0, 0.5596458911895752, 16.0], [224.0, 0.0, 0.6544457077980042, 17.0]]}
api/model/assets/data/dresscode/dresses/keypoints/052012_2.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"keypoints": [[209.0, 0.0, 0.5854654312133789, 0.0], [194.0, 46.0, 0.9134835004806519, 1.0], [152.0, 37.0, 0.9346101880073547, 2.0], [137.0, 118.0, 0.8949743509292603, 3.0], [142.0, 188.0, 0.9262046813964844, 4.0], [235.0, 53.0, 0.9443597793579102, 5.0], [242.0, 134.0, 0.8160827159881592, 6.0], [249.0, 208.0, 0.7443605065345764, 7.0], [167.0, 194.0, 0.8199771046638489, 8.0], [160.0, 319.0, 0.907497763633728, 9.0], [143.0, 447.0, 0.8496435284614563, 10.0], [224.0, 195.0, 0.7766034007072449, 11.0], [214.0, 307.0, 0.8796323537826538, 12.0], [195.0, 430.0, 0.9041213393211365, 13.0], [201.0, 0.0, 0.36648842692375183, 14.0], [217.0, 0.0, 0.44042539596557617, 15.0], [187.0, 0.0, 0.40841901302337646, 16.0], [227.0, 0.0, 0.2826925814151764, 17.0]]}
api/model/assets/data/dresscode/dresses/label_maps/051994_4.png ADDED
api/model/assets/data/dresscode/dresses/label_maps/052012_4.png ADDED
api/model/assets/data/dresscode/dresses/test_pairs_paired.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 052012_0.jpg 052012_1.jpg
api/model/assets/data/dresscode/dresses/test_pairs_unpaired.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 052012_0.jpg 052033_1.jpg
api/model/assets/data/dresscode/fine_captions.json ADDED
The diff for this file is too large to render. See raw diff
 
api/model/assets/data/dresscode/lower_body/im_sketch/050855_1.png ADDED
api/model/assets/data/dresscode/lower_body/im_sketch/050915_1.png ADDED
api/model/assets/data/dresscode/lower_body/im_sketch_unpaired/050855_0_050908_1.png ADDED
api/model/assets/data/dresscode/lower_body/im_sketch_unpaired/050915_0_051078_1.png ADDED
api/model/assets/data/dresscode/lower_body/keypoints/050855_2.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"keypoints": [[183.0, 0.0, 0.5823147296905518, 0.0], [208.0, 53.0, 0.9465193152427673, 1.0], [166.0, 48.0, 0.9355934262275696, 2.0], [149.0, 138.0, 0.8791153430938721, 3.0], [142.0, 213.0, 0.9196943640708923, 4.0], [249.0, 54.0, 0.9031239151954651, 5.0], [257.0, 143.0, 0.8434740900993347, 6.0], [269.0, 214.0, 0.9049280881881714, 7.0], [181.0, 196.0, 0.7393415570259094, 8.0], [162.0, 321.0, 0.8804817795753479, 9.0], [125.0, 435.0, 0.8968222141265869, 10.0], [235.0, 199.0, 0.7837328314781189, 11.0], [233.0, 322.0, 0.927562415599823, 12.0], [217.0, 439.0, 0.8323052525520325, 13.0], [176.0, 0.0, 0.2889324426651001, 14.0], [190.0, 0.0, 0.395557701587677, 15.0], [-1.0, -1.0, 0.0, -1.0], [213.0, 0.0, 0.4816431403160095, 16.0]]}
api/model/assets/data/dresscode/lower_body/keypoints/050915_2.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"keypoints": [[204.0, 0.0, 0.7293938398361206, 0.0], [199.0, 62.0, 0.9325352907180786, 1.0], [152.0, 67.0, 0.9000401496887207, 2.0], [144.0, 146.0, 0.9149616956710815, 3.0], [132.0, 213.0, 0.8797067999839783, 4.0], [246.0, 59.0, 0.8685039281845093, 5.0], [279.0, 135.0, 0.9230703115463257, 6.0], [228.0, 163.0, 0.908068835735321, 7.0], [160.0, 218.0, 0.8140541315078735, 8.0], [160.0, 327.0, 0.9113076329231262, 9.0], [162.0, 432.0, 0.8555663228034973, 10.0], [220.0, 218.0, 0.7834039926528931, 11.0], [227.0, 327.0, 0.8965063691139221, 12.0], [225.0, 434.0, 0.876929759979248, 13.0], [190.0, 0.0, 0.510018527507782, 14.0], [211.0, 0.0, 0.48887312412261963, 15.0], [172.0, 0.0, 0.6903271079063416, 16.0], [219.0, 0.0, 0.19232189655303955, 17.0]]}
api/model/assets/data/dresscode/lower_body/label_maps/050855_4.png ADDED
api/model/assets/data/dresscode/lower_body/label_maps/050915_4.png ADDED
api/model/assets/data/dresscode/lower_body/test_pairs_paired.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ 050855_0.jpg 050855_1.jpg
2
+ 050915_0.jpg 050915_1.jpg
api/model/assets/data/dresscode/lower_body/test_pairs_unpaired.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ 050855_0.jpg 050908_1.jpg
2
+ 050915_0.jpg 051078_1.jpg
api/model/assets/data/dresscode/test_stitchmap/048462_0.png ADDED
api/model/assets/data/dresscode/test_stitchmap/048466_0.png ADDED
api/model/assets/data/dresscode/test_stitchmap/050855_0.png ADDED
api/model/assets/data/dresscode/test_stitchmap/050915_0.png ADDED
api/model/assets/data/dresscode/test_stitchmap/051994_0.png ADDED
api/model/assets/data/dresscode/test_stitchmap/052012_0.png ADDED
api/model/assets/data/dresscode/upper_body/im_sketch/048462_1.png ADDED
api/model/assets/data/dresscode/upper_body/im_sketch_unpaired/048462_0_049951_1.png ADDED
api/model/assets/data/dresscode/upper_body/im_sketch_unpaired/048466_0_049534_1.png ADDED
api/model/assets/data/dresscode/upper_body/keypoints/048462_2.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"keypoints": [[141.0, 0.0, 0.5669732689857483, 0.0], [138.0, 52.0, 0.9372020363807678, 1.0], [97.0, 51.0, 0.9566869735717773, 2.0], [91.0, 127.0, 0.9176412224769592, 3.0], [92.0, 196.0, 0.9124826192855835, 4.0], [175.0, 52.0, 0.9164174795150757, 5.0], [190.0, 126.0, 0.9348884224891663, 6.0], [200.0, 192.0, 0.9007474780082703, 7.0], [121.0, 186.0, 0.8528367280960083, 8.0], [131.0, 298.0, 0.9579567909240723, 9.0], [147.0, 408.0, 0.9156394600868225, 10.0], [171.0, 184.0, 0.8514549732208252, 11.0], [188.0, 299.0, 0.98090660572052, 12.0], [207.0, 421.0, 0.8863993287086487, 13.0], [133.0, 0.0, 0.38882675766944885, 14.0], [148.0, 0.0, 0.43583664298057556, 15.0], [120.0, 0.0, 0.44555413722991943, 16.0], [159.0, 0.0, 0.3003842532634735, 17.0]]}
api/model/assets/data/dresscode/upper_body/keypoints/048466_2.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"keypoints": [[200.0, 0.0, 0.688823401927948, 0.0], [201.0, 49.0, 0.9461612105369568, 1.0], [162.0, 46.0, 0.9666376709938049, 2.0], [151.0, 113.0, 0.938896894454956, 3.0], [146.0, 177.0, 0.9722222685813904, 4.0], [238.0, 52.0, 0.9425340890884399, 5.0], [247.0, 117.0, 0.9355710744857788, 6.0], [246.0, 180.0, 0.9147509932518005, 7.0], [170.0, 173.0, 0.8584168553352356, 8.0], [159.0, 281.0, 0.938974916934967, 9.0], [156.0, 372.0, 0.9198458790779114, 10.0], [221.0, 173.0, 0.8431934714317322, 11.0], [219.0, 280.0, 0.9141676425933838, 12.0], [214.0, 367.0, 0.944513201713562, 13.0], [192.0, 0.0, 0.4936670660972595, 14.0], [208.0, 0.0, 0.5329393148422241, 15.0], [182.0, 0.0, 0.4606328308582306, 16.0], [219.0, 0.0, 0.460784375667572, 17.0]]}
api/model/assets/data/dresscode/upper_body/label_maps/048462_4.png ADDED
api/model/assets/data/dresscode/upper_body/label_maps/048466_4.png ADDED
api/model/assets/data/dresscode/upper_body/test_pairs_paired.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 048462_0.jpg 048462_1.jpg
api/model/assets/data/dresscode/upper_body/test_pairs_unpaired.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 048462_0.jpg 049951_1.jpg
api/model/assets/data/vitonhd/captions.json ADDED
The diff for this file is too large to render. See raw diff
 
api/model/assets/data/vitonhd/test/im_sketch/03191_00.png ADDED
api/model/assets/data/vitonhd/test/im_sketch/12419_00.png ADDED
api/model/assets/data/vitonhd/test/im_sketch_unpaired/03191_00_00349_00.png ADDED
api/model/assets/data/vitonhd/test/im_sketch_unpaired/12419_00_01944_00.png ADDED
api/model/assets/data/vitonhd/test/image-parse-v3/03191_00.png ADDED
api/model/assets/data/vitonhd/test/image-parse-v3/12419_00.png ADDED