sinashish commited on
Commit
23dbbbb
·
1 Parent(s): 797693a

Upload 450 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 +6 -0
  2. DermSynth3D/.circleci/config.yml +75 -0
  3. DermSynth3D/.devcontainer/devcontainer.json +33 -0
  4. DermSynth3D/.gitattributes +5 -0
  5. DermSynth3D/.gitignore +133 -0
  6. DermSynth3D/.gitmodules +3 -0
  7. DermSynth3D/Dockerfile +73 -0
  8. DermSynth3D/LICENSE +661 -0
  9. DermSynth3D/README.md +559 -0
  10. DermSynth3D/app.py +533 -0
  11. DermSynth3D/configs/blend.yaml +72 -0
  12. DermSynth3D/configs/default.yaml +6 -0
  13. DermSynth3D/configs/multitask.yaml +36 -0
  14. DermSynth3D/configs/renderer.yaml +33 -0
  15. DermSynth3D/configs/train_mix.yaml +42 -0
  16. DermSynth3D/data/3dbodytex-1.1-highres/006-f-run/model_highres_0_normalized.mtl +8 -0
  17. DermSynth3D/data/3dbodytex-1.1-highres/006-f-run/model_highres_0_normalized.obj +3 -0
  18. DermSynth3D/data/3dbodytex-1.1-highres/006-f-run/model_highres_0_normalized.png +3 -0
  19. DermSynth3D/data/3dbodytex-1.1-highres/221-m-u/model_highres_0_normalized.mtl +8 -0
  20. DermSynth3D/data/3dbodytex-1.1-highres/221-m-u/model_highres_0_normalized.obj +3 -0
  21. DermSynth3D/data/3dbodytex-1.1-highres/221-m-u/model_highres_0_normalized.png +3 -0
  22. DermSynth3D/data/annotations/annotator1/00f1b7bb9581e91250a2bb224c3321b8/image.jpg +0 -0
  23. DermSynth3D/data/annotations/annotator1/00f1b7bb9581e91250a2bb224c3321b8/lesions.png +0 -0
  24. DermSynth3D/data/annotations/annotator1/00f1b7bb9581e91250a2bb224c3321b8/nonskin.png +0 -0
  25. DermSynth3D/data/annotations/annotator1/00f1b7bb9581e91250a2bb224c3321b8/selected_lesion.png +0 -0
  26. DermSynth3D/data/annotations/annotator1/01d4e1319fa2defaf41f8a82d6b0992c/01d4e1319fa2defaf41f8a82d6b0992c.jpg +0 -0
  27. DermSynth3D/data/annotations/annotator1/01d4e1319fa2defaf41f8a82d6b0992c/lesions.png +0 -0
  28. DermSynth3D/data/annotations/annotator1/01d4e1319fa2defaf41f8a82d6b0992c/nonskin.png +0 -0
  29. DermSynth3D/data/annotations/annotator1/01d4e1319fa2defaf41f8a82d6b0992c/selected_lesion.png +0 -0
  30. DermSynth3D/data/annotations/annotator1/02cf3ed8e245eb520cce87fefbf5d574/02cf3ed8e245eb520cce87fefbf5d574.png +0 -0
  31. DermSynth3D/data/annotations/annotator1/02cf3ed8e245eb520cce87fefbf5d574/lesions.png +0 -0
  32. DermSynth3D/data/annotations/annotator1/02cf3ed8e245eb520cce87fefbf5d574/nonskin.png +0 -0
  33. DermSynth3D/data/annotations/annotator1/02cf3ed8e245eb520cce87fefbf5d574/selected_lesion.png +0 -0
  34. DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/02dfbc0e14a4655ca9190705fe1b7d56.png +3 -0
  35. DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/lesions.png +0 -0
  36. DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/nonskin.png +0 -0
  37. DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/selected_lesion.png +0 -0
  38. DermSynth3D/data/annotations/annotator1/0a102c96d763d98ab7eec9efd5a38d79/0a102c96d763d98ab7eec9efd5a38d79.jpg +0 -0
  39. DermSynth3D/data/annotations/annotator1/0a102c96d763d98ab7eec9efd5a38d79/lesions.png +0 -0
  40. DermSynth3D/data/annotations/annotator1/0a102c96d763d98ab7eec9efd5a38d79/nonskin.png +0 -0
  41. DermSynth3D/data/annotations/annotator1/0a102c96d763d98ab7eec9efd5a38d79/selected_lesion.png +0 -0
  42. DermSynth3D/data/annotations/annotator1/0a55e2e0b4d0241785ba9787829c6dfc/0a55e2e0b4d0241785ba9787829c6dfc.jpg +0 -0
  43. DermSynth3D/data/annotations/annotator1/0a55e2e0b4d0241785ba9787829c6dfc/lesions.png +0 -0
  44. DermSynth3D/data/annotations/annotator1/0a55e2e0b4d0241785ba9787829c6dfc/nonskin.png +0 -0
  45. DermSynth3D/data/annotations/annotator1/0a55e2e0b4d0241785ba9787829c6dfc/selected_lesion.png +0 -0
  46. DermSynth3D/data/annotations/annotator1/0a8d57f06114ff087d106c7137520927/lesions.png +0 -0
  47. DermSynth3D/data/annotations/annotator1/0a8d57f06114ff087d106c7137520927/nonskin.png +0 -0
  48. DermSynth3D/data/annotations/annotator1/0a8d57f06114ff087d106c7137520927/selected_lesion.png +0 -0
  49. DermSynth3D/data/annotations/annotator1/0abb64cc8b25d8272ec1df73300600b3/0abb64cc8b25d8272ec1df73300600b3.jpg +0 -0
  50. DermSynth3D/data/annotations/annotator1/0abb64cc8b25d8272ec1df73300600b3/lesions.png +0 -0
.gitattributes CHANGED
@@ -77,3 +77,9 @@ hf_demo/lesions/221-m-u/model_highres_0_normalized_pasted_lesion_15.png filter=l
77
  hf_demo/lesions/221-m-u/model_highres_0_normalized_pasted_lesion_2.png filter=lfs diff=lfs merge=lfs -text
78
  hf_demo/lesions/221-m-u/model_highres_0_normalized_pasted_lesion_30.png filter=lfs diff=lfs merge=lfs -text
79
  hf_demo/lesions/221-m-u/model_highres_0_normalized_pasted_lesion_5.png filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
77
  hf_demo/lesions/221-m-u/model_highres_0_normalized_pasted_lesion_2.png filter=lfs diff=lfs merge=lfs -text
78
  hf_demo/lesions/221-m-u/model_highres_0_normalized_pasted_lesion_30.png filter=lfs diff=lfs merge=lfs -text
79
  hf_demo/lesions/221-m-u/model_highres_0_normalized_pasted_lesion_5.png filter=lfs diff=lfs merge=lfs -text
80
+ DermSynth3D/data/3dbodytex-1.1-highres/006-f-run/model_highres_0_normalized.obj filter=lfs diff=lfs merge=lfs -text
81
+ DermSynth3D/data/3dbodytex-1.1-highres/006-f-run/model_highres_0_normalized.png filter=lfs diff=lfs merge=lfs -text
82
+ DermSynth3D/data/3dbodytex-1.1-highres/221-m-u/model_highres_0_normalized.obj filter=lfs diff=lfs merge=lfs -text
83
+ DermSynth3D/data/3dbodytex-1.1-highres/221-m-u/model_highres_0_normalized.png filter=lfs diff=lfs merge=lfs -text
84
+ DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/02dfbc0e14a4655ca9190705fe1b7d56.png filter=lfs diff=lfs merge=lfs -text
85
+ DermSynth3D/docs/preprint.pdf filter=lfs diff=lfs merge=lfs -text
DermSynth3D/.circleci/config.yml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: 2.1
2
+ orbs:
3
+ docker: circleci/docker@2.2.0
4
+ jobs:
5
+ build:
6
+ docker:
7
+ - image: cimg/base:stable
8
+ auth:
9
+ username: ${DOCKER_USERNAME}
10
+ password: ${DOCKER_PASSWORD}
11
+ environment:
12
+ - DOCKER_USER = ${DOCKER_USERNAME}
13
+ - DOCKER_PASS = ${DOCKER_PASSWORD}
14
+ # - UID = 301455
15
+ # - GID = 8088
16
+ # - USER = "sfu-mial"
17
+ steps:
18
+ - checkout
19
+ - setup_remote_docker:
20
+ version: 20.10.11
21
+ docker_layer_caching: true
22
+ # command: echo "Remote Docker Setup"
23
+ - run:
24
+ name: check correct path
25
+ command: |
26
+ printenv | grep "DOCKER\|UID\|GID"
27
+ pwd
28
+ ls -lkht
29
+ echo
30
+ - run:
31
+ name: docker build
32
+ command: |
33
+ docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) -t dermsynth3d:${CIRCLE_SHA1} -f Dockerfile .
34
+ - run:
35
+ name: Login to Docker Hub
36
+ command: |
37
+ echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
38
+ - run:
39
+ name: Push Docker image to Docker Hub
40
+ command: |
41
+ docker tag dermsynth3d:${CIRCLE_SHA1} "${DOCKER_USERNAME}/dermsynth3d"
42
+ docker push "${DOCKER_USERNAME}/dermsynth3d"
43
+
44
+ # version: 2.1
45
+ # orbs:
46
+ # docker: circleci/docker@2.2.0
47
+ # jobs:
48
+ # build-and-push:
49
+ # executor: docker/docker
50
+ # docker:
51
+ # - image: cimg/base:stable
52
+ # name: docker login
53
+ # auth:
54
+ # username: $DOCKER_USERNAME
55
+ # password: $DOCKER_PASSWORD
56
+ # steps:
57
+ # - setup_remote_docker
58
+ # - checkout
59
+ # - docker/check
60
+ # - docker/build:
61
+ # # image: dermsynth3d/v1
62
+ # image: sinashish/dermsynth3d
63
+ # - docker/push:
64
+ # digest-path: /tmp/digest.txt
65
+ # image: sinashish/dermsynth3d
66
+ # # - docker/publish:
67
+ # # deploy: true
68
+ # # image: dermsynth3d/v1
69
+ # - run:
70
+ # command: |
71
+ # echo "Digest is: $(</tmp/digest.txt)"
72
+ # workflows:
73
+ # commit:
74
+ # jobs:
75
+ # - build-and-push
DermSynth3D/.devcontainer/devcontainer.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "Python 3",
3
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
4
+ "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
5
+ "customizations": {
6
+ "codespaces": {
7
+ "openFiles": [
8
+ "README.md",
9
+ "app.py"
10
+ ]
11
+ },
12
+ "vscode": {
13
+ "settings": {},
14
+ "extensions": [
15
+ "ms-python.python",
16
+ "ms-python.vscode-pylance"
17
+ ]
18
+ }
19
+ },
20
+ "updateContentCommand": "[ -f packages.txt ] && sudo apt update && sudo apt upgrade -y && sudo xargs apt install -y <packages.txt; [ -f requirements.txt ] && pip3 install --user -r requirements.txt; pip3 install --user streamlit; echo '✅ Packages installed and Requirements met'",
21
+ "postAttachCommand": {
22
+ "server": "streamlit run app.py --server.enableCORS false --server.enableXsrfProtection false"
23
+ },
24
+ "portsAttributes": {
25
+ "8501": {
26
+ "label": "Application",
27
+ "onAutoForward": "openPreview"
28
+ }
29
+ },
30
+ "forwardPorts": [
31
+ 8501
32
+ ]
33
+ }
DermSynth3D/.gitattributes ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ data/3dbodytex-1.1-highres filter=lfs diff=lfs merge=lfs -text
2
+ data/annotations filter=lfs diff=lfs merge=lfs -text
3
+ data/ filter=lfs diff=lfs merge=lfs -text
4
+ data/fitzpatrick17k filter=lfs diff=lfs merge=lfs -text
5
+ data/processed_textures filter=lfs diff=lfs merge=lfs -text
DermSynth3D/.gitignore ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ **/__pycache__/
4
+ .dockerignore
5
+ .github/ISSUE_TEMPLATE/
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
+ pip-wheel-metadata/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+ .vscode/
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .nox/
48
+ .coverage
49
+ .coverage.*
50
+ .cache
51
+ nosetests.xml
52
+ coverage.xml
53
+ *.cover
54
+ *.py,cover
55
+ .hypothesis/
56
+ .pytest_cache/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
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
+ .python-version
90
+
91
+ # pipenv
92
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
93
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
94
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
95
+ # install all needed dependencies.
96
+ #Pipfile.lock
97
+
98
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
99
+ __pypackages__/
100
+
101
+ # Celery stuff
102
+ celerybeat-schedule
103
+ celerybeat.pid
104
+
105
+ # SageMath parsed files
106
+ *.sage.py
107
+
108
+ # Environments
109
+ .env
110
+ .venv
111
+ env/
112
+ venv/
113
+ ENV/
114
+ env.bak/
115
+ venv.bak/
116
+
117
+ # Spyder project settings
118
+ .spyderproject
119
+ .spyproject
120
+
121
+ # Rope project settings
122
+ .ropeproject
123
+
124
+ # mkdocs documentation
125
+ /site
126
+
127
+ # mypy
128
+ .mypy_cache/
129
+ .dmypy.json
130
+ dmypy.json
131
+
132
+ # Pyre type checker
133
+ .pyre/
DermSynth3D/.gitmodules ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [submodule "skin3d"]
2
+ path = skin3d
3
+ url = https://github.com/jeremykawahara/skin3d.git
DermSynth3D/Dockerfile ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nvidia/cuda:11.3.1-cudnn8-runtime-ubuntu20.04
2
+
3
+ # FROM pytorch/pytorch:1.12.1-cuda11.3-cudnn8-devel
4
+
5
+
6
+ RUN echo $CUDA_HOME
7
+ # ENV LD_LIBRARY_PATH /usr/local/cuda/lib64/stubs/:$LD_LIBRARY_PATH
8
+ # ENV CUDA_HOME /usr/local/cuda
9
+ # ENV LD_LIBRARY_PATH /usr/local/cuda/lib64/:$LD_LIBRARY_PATH
10
+ # ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
11
+ # ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64
12
+ # ENV PATH=/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
13
+ # ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64
14
+ #
15
+ ENV DEBIAN_FRONTEND=noninteractive
16
+ ARG UID=1000
17
+ ARG GID=1000
18
+ ARG USER=developer
19
+ ARG GROUP=$USER
20
+
21
+ ENV FORCE_CUDA=1
22
+ RUN echo $(nvcc --version)
23
+
24
+
25
+
26
+ # Install necessary packages
27
+ RUN --mount=type=cache,target=/var/cache/apt apt update && apt install -y --no-install-recommends \
28
+ sudo \
29
+ git \
30
+ wget \
31
+ bzip2 \
32
+ ca-certificates \
33
+ libx11-6 \
34
+ python3-opencv \
35
+ vim \
36
+ && rm -rf /var/lib/apt/lists/*
37
+
38
+ ## Create a non-root user and group
39
+ RUN addgroup --gid $GID $GROUP
40
+ RUN adduser --disabled-password --gecos '' --uid $UID --gid $GID $USER && \
41
+ adduser $USER sudo && \
42
+ echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
43
+ # RUN useradd -D -mU ${USER} --uid=${UID}
44
+ # Run as this user from now on
45
+ USER $USER:$GID
46
+
47
+ # Install Miniconda
48
+ WORKDIR /home/$USER
49
+ RUN wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh \
50
+ && /bin/bash ~/miniconda.sh -b -p ~/miniconda \
51
+ && rm ~/miniconda.sh
52
+ ENV PATH=/home/$USER/miniconda/bin:$PATH
53
+
54
+ # Set up conda environment
55
+ COPY dermsynth3d.yml .
56
+ RUN conda env create -f dermsynth3d.yml && conda clean -afy
57
+ ENV CONDA_DEFAULT_ENV=dermsynth3d
58
+ ENV CONDA_PREFIX=/home/$USER/miniconda/envs/$CONDA_DEFAULT_ENV
59
+ ENV PATH=$CONDA_PREFIX/bin:$PATH
60
+
61
+
62
+ RUN echo "source activate $(head -1 dermsynth3d.yml | cut -d' ' -f2)" > ~/.bashrc
63
+ ENV PATH /home/$USER/miniconda/envs/$(head -1 dermsynth3d.yml | cut -d' ' -f2)/bin:$PATH
64
+
65
+ # Copy code
66
+ COPY data /demo_data
67
+ # COPY . /home/$USER/DermSynth3D
68
+
69
+
70
+ # Test imports
71
+ # RUN git clone --recurse-submodules https://github.com/sfu-mial/DermSynth3D.git
72
+ #, "python", "scripts/gen_data.py"]
73
+ WORKDIR /home/$USER/DermSynth3D
DermSynth3D/LICENSE ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 0. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) <year> <name of author>
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published
637
+ by the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
DermSynth3D/README.md ADDED
@@ -0,0 +1,559 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DermSynth3D
2
+ [![CircleCI](https://dl.circleci.com/status-badge/img/gh/sfu-mial/DermSynth3D/tree/main.svg?style=svg&circle-token=176de57353747d240e619bdf9aacf9f716e7d04f)](https://dl.circleci.com/status-badge/redirect/gh/sfu-mial/DermSynth3D/tree/main)
3
+ ![GPLv3](https://img.shields.io/static/v1.svg?label=📃%20License&message=GPL%20v3.0&color=critical&style=flat-square)
4
+ [![arXiv](https://img.shields.io/static/v1.svg?label=📄%20arXiv&message=2305.12621&color=important&style=flat-square)](https://arxiv.org/abs/2305.12621)
5
+ [![DOI](https://img.shields.io/static/v1.svg?label=📄%20DOI&message=DOI&color=informational&style=flat-square)](https://doi.org/10.48550/arXiv.2305.12621)
6
+ [![request dataset](https://img.shields.io/static/v1.svg?label=Dataset&message=Request%20Dataset&style=flat-square&color=blueviolet)](https://cvi2.uni.lu/3dbodytexdermsynth/)
7
+ [![Video](https://img.shields.io/badge/Video-Youtube-ff69b4?style=flat-square)](https://www.youtube.com/watch?v=x3gDBJCI_3k)
8
+
9
+ :scroll: This is the official code repository for **DermSynth3D**.
10
+
11
+ <a href="docs/preprint.pdf">
12
+ <img src="assets/thumbnail1.png" alt="PDF thumbnail" height=auto width="100%">
13
+ </a>
14
+
15
+
16
+ :tv: Check out the video abstract for this work:
17
+ [![Video Thumbnail](assets/DERMSYNTH_YOUTUBE_THUMB.png)](http://www.youtube.com/watch?v=x3gDBJCI_3k)
18
+
19
+ ## TL;DR
20
+
21
+ A data generation pipeline for creating photorealistic _in-the-wild_ synthetic dermatological data with rich annotations such as semantic segmentation masks, depth maps, and bounding boxes for various skin analysis tasks.
22
+
23
+ ![main pipeline](assets/pipeline.png)
24
+ >_The figure shows the DermSynth3D computational pipeline where 2D segmented skin conditions are blended into the texture image of a 3D mesh on locations outside of the hair and clothing regions. After blending, 2D views of the mesh are rendered with a variety of camera viewpoints and lighting conditions and combined with background images to create a synthetic dermatology dataset._
25
+
26
+ ## Motivation
27
+
28
+ In recent years, deep learning (DL) has shown great potential in the field of dermatological image analysis.
29
+ However, existing datasets in this domain have significant limitations, including a small number of image samples, limited disease conditions, insufficient annotations, and non-standardized image acquisitions.
30
+ To address these shortcomings, we propose a novel framework called ${DermSynth3D}$.
31
+
32
+ ${DermSynth3D}$ blends skin disease patterns onto 3D textured meshes of human subjects using a differentiable renderer and generates 2D images from various camera viewpoints under chosen lighting conditions in diverse background scenes.
33
+ Our method adheres to top-down rules that constrain the blending and rendering process to create 2D images with skin conditions that mimic *in-the-wild* acquisitions, resulting in more meaningful results.
34
+ The framework generates photo-realistic 2D dermoscopy images and the corresponding dense annotations for semantic segmentation of the skin, skin conditions, body parts, bounding boxes around lesions, depth maps, and other 3D scene parameters, such as camera position and lighting conditions.
35
+ ${DermSynth3D}$ allows for the creation of custom datasets for various dermatology tasks.
36
+
37
+
38
+ ## Repository layout
39
+
40
+ ```bash
41
+ DermSynth3D/
42
+ ┣ assets/ # assets for the README
43
+ ┣ configs/ # YAML config files to run the pipeline
44
+ ┣ logs/ # experiment logs are saved here (auto created)
45
+ ┣ out/ # the checkpoints are saved here (auto created)
46
+ ┣ data/ # directory to store the data
47
+ ┃ ┣ ... # detailed instructions in the dataset.md
48
+ ┣ dermsynth3d/ #
49
+ ┃ ┣ datasets/ # class definitions for the datasets
50
+ ┃ ┣ deepblend/ # code for deep blending
51
+ ┃ ┣ losses/ # loss functions
52
+ ┃ ┣ models/ # model definitions
53
+ ┃ ┣ tools/ # wrappers for synthetic data generation
54
+ ┃ ┗ utils/ # helper functions
55
+ ┣ notebooks/ # demo notebooks for the pipeline
56
+ ┣ scripts/ # scripts for traning and evaluation
57
+ ┗ skin3d/ # external module
58
+ ```
59
+
60
+ ## Table of Contents
61
+ - [DermSynth3D](#dermsynth3d)
62
+ - [TL;DR](#tldr)
63
+ - [Motivation](#motivation)
64
+ - [Repository layout](#repository-layout)
65
+ - [Table of Contents](#table-of-contents)
66
+ - [Installation](#installation)
67
+ - [using conda](#using-conda)
68
+ - [using Docker](#using-docker)
69
+ - [Datasets](#datasets)
70
+ - [The folder structure of data directory should be as follows:](#the-folder-structure-of-data-directory-should-be-as-follows)
71
+ - [Data for Blending](#data-for-blending)
72
+ - [Download 3DBodyTex.v1 meshes](#download-3dbodytexv1-meshes)
73
+ - [Download the 3DBodyTex.v1 annotations](#download-the-3dbodytexv1-annotations)
74
+ - [Download the Fitzpatrick17k dataset](#download-the-fitzpatrick17k-dataset)
75
+ - [Download the Background Scenes](#download-the-background-scenes)
76
+ - [Data For Training](#data-for-training)
77
+ - [Download the FUSeg dataset](#download-the-fuseg-dataset)
78
+ - [Download the Pratheepan dataset](#download-the-pratheepan-dataset)
79
+ - [Download the PH2 dataset](#download-the-ph2-dataset)
80
+ - [Download the DermoFit dataset](#download-the-dermofit-dataset)
81
+ - [Creating the Synthetic dataset](#creating-the-synthetic-dataset)
82
+ - [How to Use DermSynth3D](#how-to-use-dermsynth3d)
83
+ - [Generating Synthetic Dataset](#generating-synthetic-dataset)
84
+ - [Post-Process Renderings with Unity](#post-process-renderings-with-unity)
85
+ - [Click to see the a visual comparison of the renderings obtained from Pytorch3D and Unity.](#click-to-see-the-a-visual-comparison-of-the-renderings-obtained-from-pytorch3d-and-unity)
86
+ - [Preparing Dataset for Experiments](#preparing-dataset-for-experiments)
87
+ - [Cite](#cite)
88
+ - [Demo Notebooks for Dermatology Tasks](#demo-notebooks-for-dermatology-tasks)
89
+ - [Lesion Segmentation](#lesion-segmentation)
90
+ - [Multi-Task Prediction](#multi-task-prediction)
91
+ - [Lesion Detection](#lesion-detection)
92
+ - [Acknowledgements](#acknowledgements)
93
+
94
+ <a name="installation"></a>
95
+
96
+ ### Installation
97
+
98
+ <a name="conda"></a>
99
+
100
+ #### using conda
101
+
102
+ ```bash
103
+ git clone --recurse-submodules https://github.com/sfu-mial/DermSynth3D.git
104
+ cd DermSynth3D
105
+ conda env create -f dermsynth3d.yml
106
+ conda activate dermsynth3d
107
+ ```
108
+
109
+ <a name="docker"></a>
110
+
111
+ #### using Docker
112
+
113
+ ```bash
114
+ # Build the container in the root dir
115
+ docker build -t dermsynth3d --build-arg USER=$USER --build-arg UID=$(id -u) --build-arg GID=$(id -g) -f Dockerfile .
116
+ # Run the container in interactive mode for using DermSynth3D
117
+ # See 3. How to use DermSynth3D
118
+ docker run --gpus all --user=root --runtime=nvidia -it --rm -v /path/to/downloaded/data:/data dermsynth3d
119
+ ```
120
+ We provide some [pre-built docker images](https://hub.docker.com/r/sinashish/dermsynth3d), which can be be used as well to:
121
+ ```bash
122
+ # pull this latest docker image with the latest code
123
+ # you need to prepare the data following the instructions below
124
+ docker pull sinashish/dermsynth3d:latest
125
+
126
+ # pull this image for trying out the code with demo data i.e. lesions and meshes
127
+ docker pull sinashish/dermsynth3d:demo_w_code
128
+
129
+ # Run the container in interactive GPU mode for generating data and training models
130
+ # mount the data directory to the container
131
+ docker run --gpus all -it --user=root --runtime=nvidia --rm -v /path/to/downloaded/data:/data dermsynth3d:<tag name>
132
+ ```
133
+
134
+ <span style="color: red">**NOTE**:</span> The code has been tested on Ubuntu 20.04 with CUDA 11.1, python 3.8, pytorch 1.10.0, and pytorch3d 0.7.2, and we don't know if it will work on CPU.
135
+
136
+ If you face any issues installing pytorch3d, please refer to their [installation guide](https://github.com/facebookresearch/pytorch3d/blob/main/INSTALL.md) or this issue [link](https://github.com/facebookresearch/pytorch3d/issues/1076).
137
+
138
+
139
+ <a name="data"></a>
140
+
141
+ ## Datasets
142
+
143
+ Follow the instructions below to download the datasets for generating the synthetic data and training models for various tasks.
144
+ All the datasets should be downloaded and placed in the `data` directory.
145
+
146
+ <a name="tree"></a>
147
+
148
+ <!-- #### The folder structure of data directory should be as follows: -->
149
+ <details>
150
+
151
+ <a name="data_tree"></a>
152
+ <summary>
153
+
154
+ ### The folder structure of data directory should be as follows:
155
+
156
+ </summary>
157
+
158
+ ```bash
159
+ DermSynth3D/
160
+ ┣ ... # other source code
161
+ ┣ data/ # directory to store the data
162
+ ┃ ┣ 3dbodytex-1.1-highres # data for 3DBodyTex.v1 3d models and texture maps
163
+ ┃ ┣ fitzpatrick17k/
164
+ ┃ ┃ ┣ data/ # Fitzpatrick17k images
165
+ ┃ ┃ ┗ annotations/ # annotations for Fitzpatrick17k lesions
166
+ ┃ ┣ ph2/
167
+ ┃ ┃ ┣ images/ # PH2 images
168
+ ┃ ┃ ┗ labels/ # PH2 annotations
169
+ ┃ ┣ dermofit/ # Dermofit dataset
170
+ ┃ ┃ ┣ images/ # Dermofit images
171
+ ┃ ┃ ┗ targets/ # Dermofit annotations
172
+ ┃ ┣ FUSeg/
173
+ ┃ ┃ ┣ train/ # training set with images/labels for FUSeg
174
+ ┃ ┃ ┣ validation/ # val set with images/labels for FUSeg
175
+ ┃ ┃ ┗ test/ # test set with images/labels for FUSeg
176
+ ┃ ┣ Pratheepan_Dataset/
177
+ ┃ ┃ ┣ FacePhoto/ # images from Pratheepan dataset
178
+ ┃ ┃ ┗ GroundT_FacePhoto/ # annotations
179
+ ┃ ┣ lesions/ # keep the non-skin masks for 3DBodyTex.v1 meshes here
180
+ ┃ ┣ annotations/ # segmentation masks for Annotated Fitzpatrick17k lesions
181
+ ┃ ┣ bodytex_anatomy_labels/ # per-vertex labels for anatomy of 3DBodyTex.v1 meshes
182
+ ┃ ┣ background/ # keep the background scenes for rendering here
183
+ ┃ ┗ synth_data/ # the generated synthetic data will be stored here
184
+ ┣ train/ # training set with images/labels for training on synthetic data
185
+ ┣ <val/test>/ # val and test set with images/labels for training on synthetic data
186
+ ```
187
+ </details>
188
+
189
+ The datasets used in this work can be broadly categorized into data required for blending and data necessary for evaluation.
190
+
191
+ <details>
192
+
193
+ <a name="blend_data"></a>
194
+ <summary>
195
+
196
+ ### Data for Blending
197
+
198
+ </summary> <blockquote>
199
+ <!-- list of blending datasets -->
200
+ <details>
201
+ <a name="mesh_data"></a>
202
+ <summary>
203
+
204
+ ### Download 3DBodyTex.v1 meshes
205
+
206
+ </summary>
207
+
208
+ ![3dbodytex sample](assets/scans_blurred.png)
209
+ > _A few examples of raw 3D scans in sports-clothing from the 3DBodyTex.v1 dataset showing a wide range of body shapes, pose, skin-tone, and gender._
210
+ <!-- <img align="right" src = "assets/scans_blurred.png" width="224px" height="224px" ></img> -->
211
+
212
+
213
+ The `3DBodyTex.v1` dataset can be downloaded from [here](https://cvi2.uni.lu/3dbodytexv1/).
214
+
215
+ `3DBodyTex.v1` contains the meshes and texture images used in this work and can be downloaded from the external site linked above (after accepting a license agreement).
216
+
217
+ **NOTE**: These textured meshes are needed to run the code to generate the data.
218
+
219
+ We provide the non-skin texture maps annotations for 2 meshes: `006-f-run` and `221-m-u`.
220
+ Hence, to generate the data, make sure to get the `.obj` files for these two meshes and place them in `data/3dbodytex-1.1-highres` before excecuting `scripts/gen_data.py`.
221
+
222
+ After accepting the licence, download and unzip the data in `./data/`.
223
+
224
+ </details>
225
+
226
+ <details>
227
+ <a name="mesh_annot_data"></a>
228
+ <summary>
229
+
230
+ ### Download the 3DBodyTex.v1 annotations
231
+
232
+
233
+ </summary>
234
+
235
+ | _Non-skin texture maps_ | _Anatomy labels_ |
236
+ |:-:|:-:|
237
+ |<p align=left> We provide the non-skin texture map ($T_{nonskin}$) annotations for 215 meshes from the `3DBodyTex.v1` dataset [here](https://cvi2.uni.lu/3dbodytexdermsynth/). </p> | <p align=left> We provide the per-vertex labels for anatomical parts of the 3DBodyTex.v1 meshes obtained by fitting SCAPE template body model [here](https://cvi2.uni.lu/3dbodytexdermsynth/). </p>|
238
+ |<img src="./assets/final.png" width="320" height="240" align=center><p>_A sample texture image showing the annotations for non-skin regions._ </p>|<img src="./assets/body_part_annotation_consistent_cmap_multi.png" width="320" height="240" align=center> <p>_A few examples of the scans showing the 7 anatomy labels._ </p>|
239
+
240
+ The folders are organised with the same IDs as the meshes in `3DBodyTex.v1` dataset.
241
+
242
+ **NOTE**: To download the the 3DBodyTex.v1 annotations with the links referred above, you would need to request access to the 3DBodyTex.DermSynth dataset by following the instructions on this [link](https://cvi2.uni.lu/3dbodytexdermsynth/).
243
+
244
+ </details>
245
+
246
+ <details>
247
+ <a name="fitz17k_data"></a>
248
+ <summary>
249
+
250
+ ### Download the Fitzpatrick17k dataset
251
+
252
+ </summary>
253
+
254
+ ![fitz_annot_fig](./assets/readme_fitz.png)<br>
255
+ _An illustration showing lesions from the Fitzpatrick17k dataset in the top row, and it's corresponding manually segmented lesion annotation in the bottom row._
256
+ <!-- , and c) The lesion mask selected for blending._ -->
257
+ <!-- | _Fitzpatrick17k Images_| _Fitzpatrick17k annotations_|
258
+ |:-:|:-:|
259
+ |![image](./assets/juvenile-xanthogranuloma63.jpg) _A sample image from the `fitz17k` dataset._ | ![mask.](./data/fitzpatrick17k/annotations/test/01ed6482ab261012f398c19db7dfcc6c/lesions.png) _The manually segmented corresponding annotation showing 3 lesions._ | -->
260
+ <!-- |<p align=left> We used the skin conditions from [Fitzpatrick17k](https://github.com/mattgroh/fitzpatrick17k). See their instructions to get access to the Fitzpatrick17k images. <br>We provide the raw images for the Fitzpatrick17k dataset [here](https://vault.sfu.ca/index.php/s/cMuxZNzk6UUHNmX).<br>After downloading the dataset, unzip the dataset:<br>```unzip fitzpatrick17k.zip -d data/fitzpatrick17k/```</p>| <p align=left> We provide the densely annotated lesion masks from the Fitzpatrick17k dataset are given within this repository under the `data` directory. More of such annotations can be downloaded from [here](https://vault.sfu.ca/index.php/s/gemdbCeoZXoCqlS).</p>| <p align=left>We provide the densely annotated lesion masks from the Fitzpatrick17k dataset are given within this repository under the `data` directory. More of such annotations can be downloaded from [here](https://vault.sfu.ca/index.php/s/gemdbCeoZXoCqlS). </p>| -->
261
+ We used the skin conditions from [Fitzpatrick17k](https://github.com/mattgroh/fitzpatrick17k).
262
+ See their instructions to get access to the Fitzpatrick17k images.
263
+ We provide the raw images for the Fitzpatrick17k dataset [here](https://vault.sfu.ca/index.php/s/cMuxZNzk6UUHNmX).
264
+
265
+ After downloading the dataset, unzip the dataset:
266
+ ```bash
267
+ unzip fitzpatrick17k.zip -d data/fitzpatrick17k/
268
+ ```
269
+
270
+ We provide a few samples of the densely annotated lesion masks from the Fitzpatrick17k dataset within this repository under the `data` directory.
271
+
272
+ More of such annotations can be downloaded from [here](https://vault.sfu.ca/index.php/s/gemdbCeoZXoCqlS).
273
+
274
+ </details>
275
+
276
+ <details>
277
+ <a name="bg_data"></a>
278
+ <summary>
279
+
280
+ ### Download the Background Scenes
281
+
282
+ </summary>
283
+
284
+ ![bg_scenes](./assets/readme_bg.png)
285
+ >_A few examples of the background scenes used for rendering the synthetic data._
286
+ <!--
287
+ |||
288
+ |:-:|:-:|
289
+ |![scene1](./assets/50.jpg)|![scene2](./assets/700.jpg)| -->
290
+
291
+ Although you can use any scenes as background for generating the random views of the lesioned-meshes, we used [SceneNet RGB-D](https://robotvault.bitbucket.io/scenenet-rgbd.html) for the background IndoorScenes. Specifically, we used [this split](https://www.doc.ic.ac.uk/~bjm113/scenenet_data/train_split/train_0.tar.gz), and sampled 3000 images from it.
292
+
293
+ For convenience, the background scenes we used to generate the ssynthetic dataset can be downloaded from [here](https://vault.sfu.ca/index.php/s/r7nc1QHKwgW2FDk).
294
+
295
+ </details>
296
+ </blockquote>
297
+ </details>
298
+ <details>
299
+ <a name="train_data"></a>
300
+ <summary>
301
+
302
+ ### Data For Training
303
+
304
+ </summary> <blockquote>
305
+ <details>
306
+ <a name="fu_data"></a>
307
+ <summary>
308
+
309
+ ### Download the FUSeg dataset
310
+
311
+ </summary>
312
+
313
+ ![fu_seg](./assets/fuseg.png)
314
+ >_A few examples from the FUSeg dataset showing the images in the top row and, it's corresponding segmentation mask in the bottom row._
315
+ <!-- |||
316
+ |:-:|:-:|
317
+ |![scene1](./assets/0011.png)|![scene2](./assets/0011_m.png)| -->
318
+
319
+ The Foot Ulcer Segmentation Challenge (FUSeg) dataset is available to download from [their official repository](https://github.com/uwm-bigdata/wound-segmentation/tree/master/data/Foot%20Ulcer%20Segmentation%20Challenge).
320
+ Download and unpack the dataset at `data/FUSeg/`, maintaining the Folder Structure shown above.
321
+
322
+ For simplicity, we mirror the FUSeg dataset [here](https://vault.sfu.ca/index.php/s/2mb8kZg8wOltptT).
323
+
324
+ </details>
325
+
326
+ <details>
327
+ <a name="prath_data"></a>
328
+ <summary>
329
+
330
+ ### Download the Pratheepan dataset
331
+
332
+ </summary>
333
+
334
+ ![prath](./assets/readme_prath.png)
335
+ >_A few examples from the Pratheepan dataset showing the images and it's corresponding segmentation mask, in the top and bottom row respectively._
336
+
337
+ The Pratheepan dataset is available to download from [their official website](https://web.fsktm.um.edu.my/~cschan/downloads_skin_dataset.html).
338
+ The images and the corresponding ground truth masks are available in a ZIP file hosted on Google Drive. Download and unpack the dataset at `data/Pratheepan_Dataset/`.
339
+
340
+ </details>
341
+
342
+ <details>
343
+ <a name="ph2_data"></a>
344
+ <summary>
345
+
346
+ ### Download the PH2 dataset
347
+
348
+ </summary>
349
+
350
+ ![ph2](./assets/readme_ph2.png)
351
+ >_A few examples from the PH2 dataset showing a lesion and it's corresponding segmentation mask, in the top and bottom row respectively._
352
+
353
+ The PH2 dataset can be downloaded from [the official ADDI Project website](https://www.fc.up.pt/addi/ph2%20database.html).
354
+ Download and unpack the dataset at `data/ph2/`, maintaining the Folder Structure shown below.
355
+
356
+ </details>
357
+
358
+ <details>
359
+ <a name="dermfit_data"></a>
360
+ <summary>
361
+
362
+ ### Download the DermoFit dataset
363
+
364
+ </summary>
365
+
366
+ ![dermo](./assets/readme_df.png)
367
+ >_An illustration of a few samples from the DermoFit dataset showing the skin lesions and it's corresponding binary mask, in the top and bottom row respectively._
368
+
369
+ The DermoFit dataset is available through a paid perpetual academic license from the University of Edinburgh. Please access the dataset following the instructions for [the DermoFit Image Library](https://licensing.edinburgh-innovations.ed.ac.uk/product/dermofit-image-library) and unpack it at `data/dermofit/`, maintaining the Folder Structure shown above.
370
+
371
+ </details>
372
+
373
+ <details>
374
+ <a name="syn_data"></a>
375
+ <summary>
376
+
377
+ ### Creating the Synthetic dataset
378
+
379
+ </summary>
380
+
381
+ ![synthetic data](./assets/fig_1-min.png)
382
+ >_Generated synthetic images of multiple subjects across a range of skin tones in various skin conditions, background scene, lighting, and viewpoints._
383
+
384
+ <!-- ![annots](./assets/AnnotationOverview.png)
385
+ > _A few examples of annotated data synthesized using DermSynth3D. The rows from top to bottom show respectively: the rendered images with blended skin conditions, bounding boxes around the lesions, GT semantic segmentation masks, grouped anatomical labels, and the monocular depth maps produced by the renderer._ -->
386
+ For convenience, we provide the generated synthetic data we used in this work for various downstream tasks [here](https://cvi2.uni.lu/3dbodytexdermsynth/).
387
+
388
+ If you want to train your models on a different split of the synthetic data, you can download a dataset generated by blending lesions on 26 3DBodyTex scans from [here](https://cvi2.uni.lu/3dbodytexdermsynth/).
389
+ To prepare the synthetic dataset for training. Sample the `images`, and `targets` from the path where you saved this dataset and then organise them into `train/val`.
390
+
391
+ **NOTE**: To download the synthetic 3DBodyTex.DermSynth dataset referred in the links above, you would need to request access by following the instructions on this [link](https://cvi2.uni.lu/3dbodytexdermsynth/).
392
+
393
+ Alternatively, you can use the provided script `scripts/prep_data.py` to create it.
394
+
395
+ Even better, you can generate your own dataset, by following the instructions [here](./README.md#generating-synthetic-dataset).
396
+
397
+
398
+
399
+ </details>
400
+ </blockquote>
401
+ </details>
402
+
403
+ <a name="usage"></a>
404
+
405
+ ## How to Use DermSynth3D
406
+
407
+ <a name='gen'></a>
408
+
409
+ ### Generating Synthetic Dataset
410
+
411
+ ![annots](./assets/AnnotationOverview.png)
412
+ > _A few examples of annotated data synthesized using DermSynth3D. The rows from top to bottom show respectively: the rendered images with blended skin conditions, bounding boxes around the lesions, GT semantic segmentation masks, grouped anatomical labels, and the monocular depth maps produced by the renderer._
413
+
414
+ Before running any code to synthesize a densely annotated data as shown above, make sure that you have downloaded the data necessary for blending as mentioned in [datasets](#data-for-blending) and folder structure is as described above.
415
+ If your folder structure is different from ours, then update the paths, such as `bodytex_dir`, `annot_dir`, etc., accordingly in `configs/blend.yaml`.
416
+
417
+ <!-- ```yml
418
+ bodytex_dir: './data/3dbodytex-1.1-highres/' # Name of the mesh to blend
419
+ mesh_name: '006-f-run' # Path to FitzPatrick17k lesions
420
+ fitz_dir: './data/fitzpatrick17k/data/finalfitz17k/' # Path to annotated Fitz17k lesions with masks
421
+ annot_dir: './data/annotations/' # Path to save the new texture maps
422
+ tex_dir: './data/lesions/'
423
+ ``` -->
424
+
425
+ Now, to *generate* the synthetic data with the default parameters, simply run the following command to generate 2000 views for a specified mesh:
426
+
427
+ ```bash
428
+ python -u scripts/gen_data.py
429
+ ```
430
+
431
+ To change the blending or synthesis parameters only, run using:
432
+ ```bash
433
+ # Use python scripts/gen_data.py -h for full list of arguments
434
+ python -u scripts/gen_data.py --lr <learning rate> \
435
+ -m <mesh_name> \
436
+ -s <path to save the views> \
437
+ -ps <skin threshold> \
438
+ -i <blending iterations> \
439
+ -v <number of views> \
440
+ -n <number of lesions per mesh>
441
+ ```
442
+
443
+ Feel free to play around with other `random` parameter in `configs/blend.yaml` to control lighting, material and view points.
444
+
445
+ <a name="post_proc_data"></a>
446
+
447
+ ### Post-Process Renderings with Unity
448
+
449
+ We use Pytorch3D as our choice of differential renderer to generate synthetic data.
450
+ However, Pytorch3D is not a Physically Based Renderer (PBR) and hence, the renderings are not photorealistic or may not look photorealistic.
451
+ To achieve photorealistic renderings, we use Unity to post-process the renderings obtained from Pytorch3D.
452
+
453
+ <details>
454
+ <summary>
455
+
456
+ ###### Click to see the a visual comparison of the renderings obtained from Pytorch3D and Unity.
457
+
458
+ </summary>
459
+
460
+ ![renderer_comp](./assets/media_rendComp.png)
461
+ > _A visual comparison of the renderings obtained from Pytorch3D and Unity (Point Lights and Mixed Lighting)._
462
+ </details>
463
+
464
+ <span style="color:red">NOTE</span>: This is an optional step. If you are not interested in creating photorealistic renderings, you can skip this step and use the renderings obtained from Pytorch3D directly. We didn't observe a **significant** difference in the performance of the models trained on the renderings obtained from Pytorch3D and Unity.
465
+
466
+ <!-- We provide detailed instructions to post-process the renderings obtained in the previous step to achieve _photorealistic_ renderings using Unity. -->
467
+
468
+ <!-- ![synthetic data](./assets/fig_1-min.png) -->
469
+ Follow the detailed instructions outlined [here](./docs/unity.md) to create photorealistic renderings using Unity. Alternatively, download the renders that we created using Unity [here](https://cvi2.uni.lu/3dbodytexdermsynth/).
470
+
471
+ <a name='train_prep'></a>
472
+
473
+ ## Preparing Dataset for Experiments
474
+ <!--
475
+ ![synthetic data](./assets/fig_1-min.png)
476
+ >_Generated synthetic images of multiple subjects across a range of skin tones in various skin conditions, background scene, lighting, and viewpoints._ -->
477
+
478
+ After creating the syntheic dataset in the previous step, it is now the time to evaluate the utility of the dataset on some real-world tasks.
479
+
480
+ Before, you start with any experiments, ideally you would want to organize the generated data into `train/val/test` sets.
481
+ We provide a utility script to do the same:
482
+ ```bash
483
+ python scripts/prep_data.py
484
+ ```
485
+
486
+ You can look at `scripts/prep_data.py` for more details.
487
+
488
+ <a name="cite"></a>
489
+
490
+ ## Cite
491
+ If you find this work useful or use any part of the code in this repo, please cite our paper:
492
+ ```bibtext
493
+ @misc{sinha2023dermsynth3d,
494
+ title={DermSynth3D: Synthesis of in-the-wild Annotated Dermatology Images},
495
+ author={Ashish Sinha and Jeremy Kawahara and Arezou Pakzad and Kumar Abhishek and Matthieu Ruthven and Enjie Ghorbel and Anis Kacem and Djamila Aouada and Ghassan Hamarneh},
496
+ year={2023},
497
+ eprint={2305.12621},
498
+ archivePrefix={arXiv},
499
+ primaryClass={eess.IV}
500
+ }
501
+ ```
502
+
503
+ <a name="repro"></a>
504
+
505
+ ## Demo Notebooks for Dermatology Tasks
506
+
507
+ ![Qualitative Results](./assets/results.png)
508
+ >_Qualitative results for (a) foot ulcer bounding box detection on FUSeg dataset, (b) multi-class segmentation (lesions,skin, and background) and in-the-wild body part prediction, \(c\) skin segmentation and body part prediction on Pratheepan dataset, and (d) multi-class segmentation (lesions, skin, and background) on dermoscopy images from PH2 dataset._
509
+
510
+ <a name='seg'></a>
511
+ <a name='train'></a>
512
+
513
+ ### Lesion Segmentation
514
+ **Note**: Update the paths to relevant datasets in `configs/train_mix.yaml`.
515
+
516
+ To train a lesion segmentation model with default parameters, on a combination of Synthetic and Real Data, simply run:
517
+
518
+ ```bash
519
+ python -u scripts/train_mix_seg.py
520
+ ```
521
+
522
+ Play around with the following parameters for a combinatorial mix of datasets.
523
+ ```yaml
524
+ real_ratio: 0.5 # fraction of real images to be used from real dataset
525
+ real_batch_ratio: 0.5 # fraction of real samples in each batch
526
+ pretrain: True # use pretrained DeepLabV3 weights
527
+ mode: 1.0 # Fraction of the number of synthetic images to be used for training
528
+ ```
529
+
530
+ You can also look at [this notebook](./notebooks/train_segmentation.ipynb) for a quick overview for training lesion segmention model.
531
+
532
+ For inference of pre-trained models/checkpoints, look at [this notebook](./notebooks/inference_segmentation.ipynb).
533
+
534
+ <a name='multi'></a>
535
+
536
+ ### Multi-Task Prediction
537
+
538
+ We also train a multi-task model for predicting lesion, anatomy and depth, and evaluate it on multiple datasets.
539
+
540
+ For a quick overview of multi-task prediction task, checkout [this notebook](./notebooks/inference_multitask.ipynb).
541
+
542
+ For performing inference on your trained models for this task. First update the paths in `configs/multitask.yaml`. Then run:
543
+ ```bash
544
+ python -u scripts/infer_multi_task.py
545
+ ```
546
+
547
+ <a name='det'></a>
548
+
549
+ ### Lesion Detection
550
+
551
+ For a quick overview for training lesion detection models, please have a look at [this notebook](./notebooks/train_detection.ipynb).
552
+
553
+ For doing a quick inference using the pre-trained detection models/ checkpoints, have a look at [this notebook](./notebooks/inference_detection.ipynb).
554
+
555
+ <a name="ack"></a>
556
+
557
+ ## Acknowledgements
558
+
559
+ We are thankful to the authors of [Skin3D](https://github.com/jeremykawahara/skin3d) for making their code and data public for the task of lesion detection on 3DBodyTex.v1 dataset.
DermSynth3D/app.py ADDED
@@ -0,0 +1,533 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.set_page_config(
4
+ page_title="DermSynth3D",
5
+ page_icon="🧊",
6
+ layout="centered",
7
+ initial_sidebar_state="auto",
8
+ menu_items={
9
+ "Get Help": "https://github.com/sfu-mial/DermSynth3D",
10
+ "Report a bug": "https://github.com/sfu-mial/DermSynth3D/issues",
11
+ "About": "This is the demo app to try out the pipeline proposed in the paper DermSynth3D: A Dermatological Image Synthesis Framework for 3D Skin Lesions",
12
+ },
13
+ )
14
+ # from stpyvista import stpyvista
15
+ import pandas as pd
16
+ import numpy as np
17
+ from glob import glob
18
+ import os, sys
19
+ from PIL import Image
20
+ import torch
21
+ import torch.nn as nn
22
+ import trimesh
23
+ import plotly.graph_objects as go
24
+ from plotly.subplots import make_subplots
25
+ from pytorch3d.renderer import (
26
+ look_at_view_transform,
27
+ FoVPerspectiveCameras,
28
+ PointLights,
29
+ DirectionalLights,
30
+ Materials,
31
+ RasterizationSettings,
32
+ MeshRenderer,
33
+ MeshRasterizer,
34
+ SoftPhongShader,
35
+ TexturesUV,
36
+ TexturesVertex,
37
+ )
38
+ import math
39
+ from trimesh import transformations as tf
40
+ import os
41
+
42
+ import streamlit.components.v1 as components
43
+ from math import pi
44
+ from IPython.display import display
45
+ import matplotlib.pyplot as plt
46
+
47
+ import matplotlib.pyplot as plt
48
+ from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
49
+ import plotly
50
+
51
+ import plotly.graph_objects as go
52
+ from skimage import io
53
+ from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
54
+
55
+ init_notebook_mode(connected=True)
56
+
57
+ view_width = 400
58
+ view_height = 400
59
+
60
+ import mediapy as mpy
61
+
62
+ sys.path.append("./dermsynth3d")
63
+ sys.path.append("./skin3d/")
64
+ from pytorch3d.io import load_objs_as_meshes
65
+ from pytorch3d.structures import Meshes
66
+
67
+ st.title("DermSynth3D - Dermatological Image Synthesis Framework")
68
+ # st.write('A dermatological image synthesis framework for 3D skin lesions')
69
+
70
+
71
+ def setup_paths():
72
+ # get the meshes
73
+ mesh_paths = glob("./data/3dbodytex-1.1-highres/*/*.obj")
74
+ mesh_names = [os.path.basename(os.path.dirname(x)) for x in mesh_paths]
75
+
76
+ # get the textures
77
+ all_textures = glob("./data/3dbodytex-1.1-highres/*/*.png")
78
+
79
+ get_no_lesion_path = lambda x, y: os.path.join(
80
+ "./data/3dbodytex-1.1-highres", x, "model_highres_0_normalized.png"
81
+ )
82
+ get_mesh_path = lambda x: os.path.join(
83
+ "./data/3dbodytex-1.1-highres", x, "model_highres_0_normalized.obj"
84
+ )
85
+ # get the textures with the lesions
86
+ get_mask_path = lambda x, y: os.path.join(
87
+ "./data/processed_textures/", x, "model_highres_0_normalized.png"
88
+ )
89
+ get_dilated_lesion_path = lambda x, y: os.path.join(
90
+ "./data/processed_textures/",
91
+ x,
92
+ f"model_highres_0_normalized_dilated_lesion_{y}.png",
93
+ )
94
+ get_blended_lesion_path = lambda x, y: os.path.join(
95
+ "./data/processed_textures/",
96
+ x,
97
+ f"model_highres_0_normalized_blended_lesion_{y}.png",
98
+ )
99
+ get_pasted_lesion_path = lambda x, y: os.path.join(
100
+ "./data/processed_textures/",
101
+ x,
102
+ f"model_highres_0_normalized_pasted_lesion_{y}.png",
103
+ )
104
+ get_texture_module = lambda x: getattr(
105
+ sys.modules[__name__],
106
+ f"get_{x.lower().replace(' ', '_')}_path",
107
+ )
108
+ # Update the global namespace with the functions
109
+ global_namespace = globals()
110
+ global_namespace.update(
111
+ {
112
+ "mesh_paths": mesh_paths,
113
+ "mesh_names": mesh_names,
114
+ "all_textures": all_textures,
115
+ "get_no_lesion_path": get_no_lesion_path,
116
+ "get_mesh_path": get_mesh_path,
117
+ "get_mask_path": get_mask_path,
118
+ "get_dilated_lesion_path": get_dilated_lesion_path,
119
+ "get_blended_lesion_path": get_blended_lesion_path,
120
+ "get_pasted_lesion_path": get_pasted_lesion_path,
121
+ "get_texture_module": get_texture_module,
122
+ }
123
+ )
124
+
125
+
126
+ @st.cache_data
127
+ def set_texture_map_py3d(mesh_name, texture_name, num_lesion=1, device="cpu"):
128
+ mesh_path = get_mesh_path(mesh_name)
129
+ texture_path = get_texture_module(texture_name)(mesh_name)
130
+ mesh = load_objs_as_meshes([mesh_path], device=device)
131
+ texture_img = Image.open(texture_path).convert("RGB")
132
+ texture_tensor = torch.from_numpy(np.array(texture_img))
133
+
134
+ tmap = TexturesUV(
135
+ maps=texture_tensor.float().to(device=mesh.device).unsqueeze(0),
136
+ verts_uvs=mesh.textures.verts_uvs_padded(),
137
+ faces_uvs=mesh.textures.faces_uvs_padded(),
138
+ )
139
+ new_mesh = Meshes(
140
+ verts=mesh.verts_padded(), faces=mesh.faces_padded(), textures=tmap
141
+ )
142
+ return new_mesh, texture_img
143
+
144
+
145
+ import tempfile
146
+
147
+
148
+ def render_images(mesh_name, texture_name, num_lesion=1, device="cuda"):
149
+ raise NotImplementedError
150
+
151
+
152
+ @st.cache_data
153
+ def get_trimesh_attrs(mesh_name):
154
+ mesh_path = get_mesh_path(mesh_name)
155
+ tri_mesh = trimesh.load(mesh_path)
156
+ angle = -math.pi / 2
157
+ direction = [0, 1, 0]
158
+ center = [0, 0, 0]
159
+ rot_matrix = tf.rotation_matrix(angle, direction, center)
160
+ tri_mesh = tri_mesh.apply_transform(rot_matrix)
161
+ tri_mesh.apply_transform(tf.rotation_matrix(math.pi, [0, 0, 1], [-1, -1, -1]))
162
+
163
+ verts, faces = tri_mesh.vertices, tri_mesh.faces
164
+ uvs = tri_mesh.visual.uv
165
+ colors = tri_mesh.visual.to_color()
166
+ vc = colors.vertex_colors # / 255.0
167
+ timg = tri_mesh.visual.material.image
168
+
169
+ return verts, faces, vc, mesh_name
170
+
171
+
172
+ @st.cache_data
173
+ def plotly_image(image):
174
+ fig = go.Figure()
175
+ fig.add_trace(go.Image(z=image))
176
+ fig.update_layout(
177
+ width=view_width,
178
+ height=view_height,
179
+ margin=dict(l=0, r=0, b=0, t=0, pad=0),
180
+ paper_bgcolor="rgba(0,0,0,0)",
181
+ plot_bgcolor="rgba(0,0,0,0)",
182
+ )
183
+ fig.update_xaxes(showticklabels=False)
184
+ fig.update_yaxes(showticklabels=False)
185
+ return fig
186
+
187
+
188
+ @st.cache_data
189
+ def plotly_mesh(verts, faces, vc, mesh_name):
190
+ fig = go.Figure(
191
+ data=[
192
+ go.Mesh3d(
193
+ x=verts[:, 0],
194
+ y=verts[:, 1],
195
+ z=verts[:, 2],
196
+ i=faces[:, 0],
197
+ j=faces[:, 1],
198
+ k=faces[:, 2],
199
+ vertexcolor=vc,
200
+ )
201
+ ]
202
+ )
203
+ fig.update_layout(scene_aspectmode="manual", scene_aspectratio=dict(x=1, y=1, z=1))
204
+ fig.update_layout(scene=dict(xaxis=dict(visible=False), yaxis=dict(visible=False)))
205
+ fig.update_layout(scene=dict(zaxis=dict(visible=False)))
206
+ fig.update_layout(scene=dict(camera=dict(up=dict(x=1, y=0, z=1))))
207
+ fig.update_layout(scene=dict(camera=dict(eye=dict(x=-2, y=-2, z=-1))))
208
+ # fig.update_layout(scene=dict(camera=dict(center=dict(x=0, y=0, z=0))))
209
+
210
+ return fig
211
+
212
+
213
+ @st.cache_data
214
+ def load_mesh_and_texture(mesh_name, texture_name, num_lesion=1, device="cuda"):
215
+ mesh_path = get_mesh_path(mesh_name)
216
+ texture_path = get_texture_module(texture_name)(mesh_name, num_lesion)
217
+ # glb_mesh = convert_to_glb(mesh_path)
218
+ mesh = load_objs_as_meshes([mesh_path], device=device)
219
+ verts = mesh.verts_packed().detach().cpu().numpy()
220
+ faces = mesh.faces_packed().detach().cpu().numpy()
221
+ normals = mesh.verts_normals_packed().detach().cpu().numpy()
222
+ # tri_mesh = trimesh.load(mesh_path)
223
+
224
+ texture_img = Image.open(texture_path).convert("RGB")
225
+ texture_tensor = torch.from_numpy(np.array(texture_img))
226
+
227
+ tmap = TexturesUV(
228
+ maps=texture_tensor.float().to(device=mesh.device).unsqueeze(0),
229
+ verts_uvs=mesh.textures.verts_uvs_padded(),
230
+ faces_uvs=mesh.textures.faces_uvs_padded(),
231
+ )
232
+ new_mesh = Meshes(
233
+ verts=mesh.verts_padded(), faces=mesh.faces_padded(), textures=tmap
234
+ )
235
+ pl_mesh = plotly_mesh(*get_trimesh_attrs(mesh_name))
236
+ # print(tri_mesh, new_mesh, texture_img.resize((256, 256)))
237
+ return pl_mesh, new_mesh, texture_img # .resize((256, 256))
238
+
239
+
240
+ @st.cache_resource
241
+ def display_mesh(mesh_name, texture_name, num_lesion=1, device="cuda"):
242
+ tri_mesh, render_mesh, texture_img = load_mesh_and_texture(
243
+ mesh_name, texture_name, num_lesion, device
244
+ )
245
+
246
+ plotter = pv.Plotter(border=True, window_size=[view_width, view_width])
247
+ pv_mesh = pv.wrap(tri_mesh)
248
+ plotter.add_mesh(pv_mesh)
249
+ plotter.background_color = "white"
250
+ plotter.view_isometric()
251
+ return plotter, render_mesh, texture_img
252
+
253
+
254
+ @st.cache_data
255
+ def setup_cameras(dist, elev, azim, device="cuda"):
256
+ R, T = look_at_view_transform(dist, elev, azim, degrees=True)
257
+ cameras = FoVPerspectiveCameras(device=device, R=R, T=T)
258
+ return cameras
259
+
260
+
261
+ @st.cache_data
262
+ def setup_lights(
263
+ light_pos, ambient_color, diffuse_color, specular_color, device="cuda"
264
+ ):
265
+ lights = PointLights(
266
+ device=device,
267
+ location=[[light_pos, light_pos, light_pos]],
268
+ ambient_color=[[ambient_color, ambient_color, ambient_color]],
269
+ diffuse_color=[[diffuse_color, diffuse_color, diffuse_color]],
270
+ specular_color=[[specular_color, specular_color, specular_color]],
271
+ )
272
+ return lights
273
+
274
+
275
+ @st.cache_data
276
+ def setup_materials(shininess, specularity, device="cuda"):
277
+ materials = Materials(
278
+ device=device,
279
+ specular_color=[[specularity, specularity, specularity]],
280
+ shininess=[shininess],
281
+ )
282
+ return materials
283
+
284
+
285
+ # @st.cache_data
286
+ def setup_renderer(cameras, lights, materials, device="cuda"):
287
+ raster_settings = RasterizationSettings(
288
+ image_size=256,
289
+ blur_radius=0.0,
290
+ faces_per_pixel=10,
291
+ # max_faces_per_bin=100,
292
+ bin_size=0,
293
+ perspective_correct=True,
294
+ )
295
+ renderer = MeshRenderer(
296
+ rasterizer=MeshRasterizer(cameras=cameras, raster_settings=raster_settings),
297
+ shader=SoftPhongShader(
298
+ device=device, cameras=cameras, lights=lights, materials=materials
299
+ ),
300
+ )
301
+ return renderer
302
+
303
+
304
+ # @st.cache_resource
305
+ def render_images(renderer, mesh, lights, cameras, materials, nviews, device="cuda"):
306
+ images = renderer(mesh, lights=lights, cameras=cameras, materials=materials)
307
+ return images
308
+
309
+
310
+ def main():
311
+ st.sidebar.title("Mesh")
312
+ selected_mesh = st.sidebar.selectbox(
313
+ "Select the mesh to be used for the synthesis", mesh_names
314
+ )
315
+
316
+ # set the texture
317
+ st.sidebar.title("Texture Map")
318
+ selected_texture = st.sidebar.selectbox(
319
+ "Select the texture map to view",
320
+ ["No Lesion", "Pasted Lesion", "Blended Lesion", "Dilated Lesion"],
321
+ )
322
+
323
+ st.sidebar.title("Lesion Count")
324
+ num_lesion = st.sidebar.slider(
325
+ "Set the number of lesions to be added to the mesh",
326
+ min_value=0,
327
+ max_value=30,
328
+ value=1,
329
+ step=1,
330
+ )
331
+ if num_lesion not in [0, 1, 2, 5, 10]:
332
+ st.sidebar.error("The number of lesions is not in the default list!")
333
+ st.sidebar.warning("We currently only support 1, 5, 15, 30.")
334
+ num_lesion = 1
335
+
336
+ # load the texture
337
+ texture_img = Image.open(
338
+ get_texture_module(selected_texture)(selected_mesh, num_lesion)
339
+ )
340
+
341
+ # display the mesh and texture
342
+ # based on the selected parameters
343
+ with st.spinner(text="Loading Mesh with texture..."):
344
+ mesh_place, texture_place = st.columns(2)
345
+ tmesh, render_mesh, texture_img = load_mesh_and_texture(
346
+ selected_mesh, selected_texture, num_lesion
347
+ )
348
+ with mesh_place and st.spinner("Loading Mesh..."):
349
+ # mesh_place.info("click on reset camera, if unable to see the whole mesh!")
350
+ mesh_place.plotly_chart(tmesh, use_container_width=True, theme=None)
351
+ # mesh_place.info("The mesh will be displayed here. Please wait...")
352
+ # st.sidebar.success("Mesh with texture loaded!")
353
+ # stpyvista(tmesh, key="mesh")
354
+ with texture_place and st.spinner("Loading texture..."):
355
+ pl_img = plotly_image(texture_img.resize((512, 512)))
356
+ texture_place.plotly_chart(pl_img, use_container_width=True, theme=None)
357
+ # texture_place.info("The texture will be displayed here. Please wait...")
358
+ # texture_place.image(
359
+ # texture_img,
360
+ # caption=f"Texture map with {selected_texture} for {selected_mesh}",
361
+ # use_column_width="auto",
362
+ # # width=view_width,
363
+ # clamp=True,
364
+ # channels="RGB",
365
+ # )
366
+ st.sidebar.success("Mesh with texture loaded!", icon="👏")
367
+ finished_loading = True
368
+ # randomize the rendering parameters
369
+ st.sidebar.title("Randomize View Parameters")
370
+ activated = st.sidebar.toggle("Randomize?", value=False)
371
+ # default = False
372
+ st.session_state["randomized"] = False
373
+ if activated and finished_loading:
374
+ with st.spinner("Randomizing..."):
375
+ # set the camera parameters
376
+ dist = np.random.uniform(0.0, 1.0)
377
+ elev = np.random.uniform(0.0, 1.0)
378
+ azim = np.random.uniform(0.0, 1.0)
379
+ # set the lighting parameters
380
+ light_pos = np.random.uniform(0.0, 1.0)
381
+ ambient_color = np.random.uniform(0.0, 1.0)
382
+ diffuse_color = np.random.uniform(0.0, 1.0)
383
+ specular_color = np.random.uniform(0.0, 1.0)
384
+ # set the material parameters
385
+ shininess = np.random.uniform(0.0, 1.0)
386
+ specularity = np.random.uniform(0.0, 1.0)
387
+ camera_values = setup_cameras(dist, elev, azim)
388
+ light_values = setup_lights(
389
+ light_pos, ambient_color, diffuse_color, specular_color
390
+ )
391
+ material_values = setup_materials(shininess, specularity)
392
+ renderer = setup_renderer(camera_values, light_values, material_values)
393
+ st.session_state["camera_values"] = camera_values
394
+ st.session_state["light_values"] = light_values
395
+ st.session_state["material_values"] = material_values
396
+ st.session_state["renderer"] = renderer
397
+ st.session_state["randomized"] = True
398
+ if (
399
+ "camera_values" in st.session_state
400
+ and "light_values" in st.session_state
401
+ and "material_values" in st.session_state
402
+ and "renderer" in st.session_state
403
+ ):
404
+ st.sidebar.success("Randomization done!", icon="👏")
405
+ else:
406
+ if not st.session_state["randomized"]:
407
+ st.sidebar.warning(
408
+ "Randomization is disabled!\nDefine the rendering parameters!"
409
+ )
410
+ with st.spinner("Set View Parameters"):
411
+ # with st.sidebar.expander("Set View Parameters", expanded=True) as view_cont:
412
+ # camera parameters
413
+ # st.sidebar.header("View Parameters")
414
+ cam = st.sidebar.form("Change camera parameters")
415
+ cam.subheader("Camera Parameters") # , expanded=False)
416
+ dist = cam.slider(
417
+ "Distance", min_value=0.0, max_value=10.0, value=0.5, step=0.5
418
+ )
419
+ elev = cam.slider(
420
+ "Elevation", min_value=-90, max_value=90, value=0, step=10
421
+ )
422
+ azim = cam.slider("Azimuth", min_value=-90, max_value=90, value=90, step=10)
423
+ # camera_values = cam.form_submit_button(
424
+ # "Update Camera Parameters",
425
+ # on_click=setup_cameras,
426
+ # args=(dist, elev, azim),
427
+ # )
428
+ # cam.form_submit_button("Update Camera Parameters")
429
+ # camera_values = setup_cameras(dist, elev, azim)
430
+
431
+ # print(camera_values)
432
+ # cam.warning(
433
+ # "*Note:* The camera parameters are set to the default values used in the paper"
434
+ # )
435
+
436
+ # lighting parameters
437
+ # st.sidebar.subheader("Lighting Parameters")
438
+ # light = st.sidebar.expander("Change lighting parameters", expanded=False)
439
+ # light = st.sidebar.form("Change lighting parameters") # , expanded=False)
440
+ # light_pos = light.slider(
441
+ # "Light Position", min_value=0.0, max_value=1.0, value=0.5, step=0.1
442
+ # )
443
+ # light_ac = light.slider(
444
+ # "Ambient Color", min_value=0.0, max_value=1.0, value=0.5, step=0.1
445
+ # )
446
+ # light_dc = light.slider(
447
+ # "Diffuse Color", min_value=0.0, max_value=1.0, value=0.5, step=0.1
448
+ # )
449
+ # light_sc = light.slider(
450
+ # "Specular Color", min_value=0.0, max_value=1.0, value=0.5, step=0.1
451
+ # )
452
+ cam.subheader("Lighting Parameters") # , expanded=False)
453
+ light_pos = cam.slider(
454
+ "Light Position", min_value=0.0, max_value=1.0, value=0.5, step=0.1
455
+ )
456
+ light_ac = cam.slider(
457
+ "Ambient Color", min_value=0.0, max_value=1.0, value=0.5, step=0.1
458
+ )
459
+ light_dc = cam.slider(
460
+ "Diffuse Color", min_value=0.0, max_value=1.0, value=0.5, step=0.1
461
+ )
462
+ light_sc = cam.slider(
463
+ "Specular Color", min_value=0.0, max_value=1.0, value=0.5, step=0.1
464
+ )
465
+ # light.form_submit_button("Update Lighting Parameters")
466
+ # light_values = setup_lights(light_pos, light_ac, light_dc, light_sc)
467
+ # light.warning(
468
+ # "*Note:* The lighting parameters are set to the default values used in the paper"
469
+ # )
470
+ # print(light_values)
471
+ # material parameters
472
+ # st.sidebar.write("Material Parameters")
473
+ # mat = st.sidebar.expander("Change material parameters", expanded=False)
474
+ # mat = st.sidebar.form("Change material parameters") # , expanded=False)
475
+
476
+ # mat_sh = mat.slider(
477
+ # "Shininess", min_value=0, max_value=100, value=50, step=10
478
+ # )
479
+ # mat_sc = mat.slider(
480
+ # "Specularity", min_value=0.0, max_value=1.0, value=0.5, step=0.1
481
+ # )
482
+ cam.subheader("Material Parameters") # , expanded=False)
483
+ mat_sh = cam.slider(
484
+ "Shininess", min_value=0, max_value=100, value=50, step=10
485
+ )
486
+ mat_sc = cam.slider(
487
+ "Specularity", min_value=0.0, max_value=1.0, value=0.5, step=0.1
488
+ )
489
+ # mat.form_submit_button("Update Material Parameters")
490
+ # material_values = setup_materials(mat_sh, mat_sc)
491
+ # mat.warning(
492
+ # "*Note:* The material parameters are set to the default values used in the paper"
493
+ # )
494
+ # update_button = st.form_submit_button("Update Parameters")
495
+ cam.form_submit_button("Update View Parameters")
496
+ camera_values = setup_cameras(dist, elev, azim)
497
+ light_values = setup_lights(light_pos, light_ac, light_dc, light_sc)
498
+ material_values = setup_materials(mat_sh, mat_sc)
499
+ renderer = setup_renderer(camera_values, light_values, material_values)
500
+
501
+ st.session_state["selected_camera_values"] = camera_values
502
+ st.session_state["selected_light_values"] = light_values
503
+ st.session_state["updated_renderer"] = renderer
504
+ st.session_state["selected_material_values"] = material_values
505
+ # Rendered Views
506
+ st.header("Rendered Views")
507
+ st.info("The rendered views will be displayed here. Click on the button to render!")
508
+ with st.form("Render Views"):
509
+ number_of_views = st.slider(
510
+ "Number of views to be rendered", 2, 16, 4, 2
511
+ ) # , key="num_views")
512
+ render_button = st.form_submit_button("Render Views")
513
+ st.session_state["number_of_views"] = number_of_views
514
+ st.session_state["render_button"] = render_button
515
+ if st.session_state["render_button"]:
516
+ with st.spinner("Rendering..."):
517
+ images = render_images(
518
+ renderer,
519
+ render_mesh,
520
+ light_values,
521
+ camera_values,
522
+ material_values,
523
+ number_of_views,
524
+ )
525
+ images = images.detach().cpu().numpy()
526
+ rendered_img = plotly_image(images[0][..., :3])
527
+ silhouette_img = plotly_image(images[0][..., 3:])
528
+ st.plotly_chart(rendered_img, use_container_width=True, theme=None)
529
+
530
+
531
+ if __name__ == "__main__":
532
+ setup_paths()
533
+ main()
DermSynth3D/configs/blend.yaml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: DermSynth3d
2
+
3
+ # Settings for pasting and blending lesions
4
+
5
+ blending:
6
+ # Path to 3DBodyTex v1
7
+ # bodytex_dir: "/local-scratch2/asa409/data/dermSynth/3dbodytex-1.1-highres"
8
+ bodytex_dir: './data/3dbodytex-1.1-highres/'
9
+ # Name of the mesh to blend
10
+ mesh_name: '006-f-run'
11
+ # Path to FitzPatrick17k lesions
12
+ # fitz_dir: "/local-scratch2/asa409/data/dermSynth/data/finalfitz17k"
13
+ fitz_dir: './data/fitzpatrick17k/data/finalfitz17k/'
14
+ # Path to annotated Fitz17k lesions with masks
15
+ annot_dir: './data/annotations/'
16
+ # annot_dir: "/local-scratch2/asa409/data/dermSynth/annotations"
17
+ # Path to save the new texture maps
18
+ tex_dir: './data/lesions/'
19
+ # Name of extension to add to new texture maps
20
+ ext: 'latest'
21
+ # Number of lesions to paste/blend on each mesh
22
+ num_paste: 50
23
+ # Number of iterations for blending the lesion
24
+ num_iter: 400
25
+ # Learning rate for optimization
26
+ lr: 0.005
27
+ # Image size to render
28
+ img_w: 64
29
+ img_h: 64
30
+ view_size: (64, 64)
31
+
32
+ # Settings for generating 2D views from blended texture maps
33
+ generate:
34
+ # Number of images to render per mesh
35
+ num_views: 2000
36
+ # Name of the mesh to blend
37
+ mesh_name: '006-f-run'
38
+ # Path to save the rendering and ground truth annotations
39
+ save_dir: './out/blended_lesions/'
40
+ # Path to anatomy labels for 3DBodyTex v1.
41
+ anatomy_dir: './data/bodytex_anatomy_labels/'
42
+ # Path to the background scenes
43
+ # background_dir: "/local-scratch2/asa409/data/dermSynth/IndoorScene"
44
+ background_dir: './data/background/IndoorScene/'
45
+
46
+ # Whether to paste lesions for cheap blending
47
+ paste: False
48
+ # Image size to render
49
+ img_w: 64
50
+ img_h: 64
51
+ view_size: (64, 64)
52
+ # Threshold amount of lesion to be present to generate a view
53
+ percent_skin: 0.1
54
+ # Paths to skin3d repo
55
+ skin3d: './skin3d/data/3dbodytex-1.1-highres/bodytex.csv'
56
+ # Paths to skin3d nevi annotations
57
+ skin3d_annot: './skin3d/data/3dbodytex-1.1-highres/annotations/'
58
+
59
+ random:
60
+ surface_offset_bounds: (0.1, 1.3)
61
+ ambient_bounds: (0.3, 0.99)
62
+ specular_bounds: (0, 0.1)
63
+ diffuse_bounds : (0.3, 0.99)
64
+ mat_diffuse_bounds : (0.3, 0.99)
65
+ mat_specular_bounds : (0., 0.05)
66
+ znear: 0.01
67
+ light_pos: None
68
+ shininess: (30, 60)
69
+ sphere_pos: False
70
+ elev_bounds : (0, 180)
71
+ azim_bounds : (-90, 90)
72
+ background_blur_radius_bounds : (0, 3)
DermSynth3D/configs/default.yaml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ device: 'cuda'
2
+ img_w: 64
3
+ img_h: 64
4
+ extension:
5
+ image_extension: '.jpg'
6
+ target_extension: '.png'
DermSynth3D/configs/multitask.yaml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Infer MultiTask'
2
+
3
+ infer:
4
+ multi_head: False
5
+ backbone: False
6
+ model_path: '/path/to/trained/model/'
7
+
8
+ img_size: (320, 320)
9
+
10
+ # ImageNet
11
+ mean: (0.485, 0.456, 0.406)
12
+ std: (0.229, 0.224, 0.225)
13
+
14
+ # Test Type
15
+ mode: 1 # Choose to test on Fitz17k/ Ph2/ DermoFit
16
+
17
+ # Data paths
18
+ fitz_imgs: './data/fitzpatrick17k/data/finalfitz17k/'
19
+ fitz_annot: './data/fitzpatrick17k/annotations/annotations/'
20
+ fitz_test_skin: './data/fitzpatrick17k/annotations/test/skin/'
21
+ fitz_test_anatomy: './data/fitzpatrick17k/annotations/test/anatomy/'
22
+ fitz_test_imgs: './data/fitzpatrick17k/annotations/test/images/'
23
+
24
+ ph2_imgs: './data/ph2/images'
25
+ ph2_test_skin: './data/ph2/preds/skin/'
26
+ ph2_test_images: './data/ph2/preds/images/'
27
+ ph2_test_targets: './data/ph2/preds/targets/'
28
+
29
+ derm_imgs: './data/dermofit/images/'
30
+ derm_targets: './data/dermofit/targets/'
31
+ derm_preds: './data/dermofit/predictions/'
32
+
33
+ prath_imgs: './data/Pratheepan_Dataset/FacePhoto/'
34
+ prath_tgts: './data/Pratheepan_Dataset/GroundT_FacePhoto/'
35
+ prath_preds_skin: './data/Pratheepan_Dataset/predictions/skin/'
36
+ prath_preds_anatomy: './data/Pratheepan_Dataset/predictions/anatomy/'
DermSynth3D/configs/renderer.yaml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Renderer params
2
+
3
+ fov: 30
4
+ faces_per_pixel: 1
5
+
6
+ # Specific Light Source properties
7
+ light:
8
+ ambient_color: (0.5, 0.5, 0.5)
9
+ specular_color: (0.025, 0.025, 0.025)
10
+ diffuse_color: (0.5, 0.5, 0.5)
11
+ light_location: None
12
+
13
+ # Specific Material Properties
14
+ material:
15
+ ambient_color: (0.5, 0.5, 0.5)
16
+ specular_color: (0.025, 0.025, 0.025)
17
+ diffuse_color: (0.5, 0.5, 0.5)
18
+ shininess: 50.
19
+
20
+ # Range for randomizing views/light/material
21
+ random:
22
+ dists: (0.3, 3) # Distance of subject from camera
23
+ elevs: (90, 270) # Elevation
24
+ azims: (0,270) # Azimuth
25
+ ats: (0.25, 1.75) # camera position
26
+ ambients: (0.2, 0.99) # Ambient light
27
+ speculars: (0, 0.1) # Specularity
28
+ diffuses: (0.2, 0.99) # Diffusivity
29
+ shininess: (30., 70.) # Shininess of the material
30
+ surface_offset_weight: (0.1, 1.2) # offset camera by a dsitance
31
+ znear: 1
32
+
33
+
DermSynth3D/configs/train_mix.yaml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Mixed Training
2
+
3
+ # Path to generated data
4
+ root: './data/synth_data/'
5
+ # Path to real data
6
+ real: './data/FUSeg/'
7
+ # Name of folder to save the models
8
+ save_name: 'run1' # checkpoints are saved in '../data/exp/'
9
+ save_dir: './out'
10
+
11
+ train:
12
+ batch_size: 16 # batch size
13
+ lr: 0.00005 # learning rate
14
+ epochs: 200 # number of epochs
15
+ weight_decay: 0.00005
16
+ num_classes: 1 # number of output classes
17
+ real_ratio: 0.5 # fraction of real images to be used from real dataset
18
+ real_batch_ratio: 0.5 # fraction of real samples in each batch
19
+ pretrain: True # use pretrained DeepLabV3 weights
20
+ mode: 1.0 # Fraction of the number of synthetic images to be used for training
21
+ resume: False # resume training from last saved model
22
+ root: './data/synth_data/'
23
+ # Path to real data
24
+ real: './data/FUSeg/'
25
+
26
+ # ImageNet
27
+ mean: (0.485, 0.456, 0.406)
28
+ std: (0.229, 0.224, 0.225)
29
+ # Augmentations
30
+ min_v: 0.8
31
+ max_v: 1.2
32
+ img_size: (256, 256)
33
+ save_every: 5
34
+
35
+ val:
36
+ batch_size: 1
37
+ log_every: 100
38
+ val_every: 500 # Validate every N iterations
39
+
40
+ test:
41
+ batch_size: 1
42
+ test_every: 500 # Test every N iterations
DermSynth3D/data/3dbodytex-1.1-highres/006-f-run/model_highres_0_normalized.mtl ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ newmtl texture
2
+ Ka 0.200000 0.200000 0.200000
3
+ Kd 1.000000 1.000000 1.000000
4
+ Ks 1.000000 1.000000 1.000000
5
+ Tr 0.000000
6
+ illum 2
7
+ Ns 0.000000
8
+ map_Kd model_highres_0_normalized.png
DermSynth3D/data/3dbodytex-1.1-highres/006-f-run/model_highres_0_normalized.obj ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6143380968215e1e181f7bf54ea119f04c3b2eebe01bbd1fdc83f5867ba9194
3
+ size 56175506
DermSynth3D/data/3dbodytex-1.1-highres/006-f-run/model_highres_0_normalized.png ADDED

Git LFS Details

  • SHA256: 2947d8e2c1a0e6f78da52a96c065ae1909416906679e57173c9560a658630701
  • Pointer size: 132 Bytes
  • Size of remote file: 9.33 MB
DermSynth3D/data/3dbodytex-1.1-highres/221-m-u/model_highres_0_normalized.mtl ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ newmtl texture
2
+ Ka 0.200000 0.200000 0.200000
3
+ Kd 1.000000 1.000000 1.000000
4
+ Ks 1.000000 1.000000 1.000000
5
+ Tr 0.000000
6
+ illum 2
7
+ Ns 0.000000
8
+ map_Kd model_highres_0_normalized.png
DermSynth3D/data/3dbodytex-1.1-highres/221-m-u/model_highres_0_normalized.obj ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9329f432380d269cf6b8b8c2a54128f0c8842e613349bdd27e45dc010f606dbe
3
+ size 56024466
DermSynth3D/data/3dbodytex-1.1-highres/221-m-u/model_highres_0_normalized.png ADDED

Git LFS Details

  • SHA256: 4a66ac124624c562bd97ea8ba30d05f66d6af32831ac3b9bcf9d5c00d8b41274
  • Pointer size: 132 Bytes
  • Size of remote file: 7.14 MB
DermSynth3D/data/annotations/annotator1/00f1b7bb9581e91250a2bb224c3321b8/image.jpg ADDED
DermSynth3D/data/annotations/annotator1/00f1b7bb9581e91250a2bb224c3321b8/lesions.png ADDED
DermSynth3D/data/annotations/annotator1/00f1b7bb9581e91250a2bb224c3321b8/nonskin.png ADDED
DermSynth3D/data/annotations/annotator1/00f1b7bb9581e91250a2bb224c3321b8/selected_lesion.png ADDED
DermSynth3D/data/annotations/annotator1/01d4e1319fa2defaf41f8a82d6b0992c/01d4e1319fa2defaf41f8a82d6b0992c.jpg ADDED
DermSynth3D/data/annotations/annotator1/01d4e1319fa2defaf41f8a82d6b0992c/lesions.png ADDED
DermSynth3D/data/annotations/annotator1/01d4e1319fa2defaf41f8a82d6b0992c/nonskin.png ADDED
DermSynth3D/data/annotations/annotator1/01d4e1319fa2defaf41f8a82d6b0992c/selected_lesion.png ADDED
DermSynth3D/data/annotations/annotator1/02cf3ed8e245eb520cce87fefbf5d574/02cf3ed8e245eb520cce87fefbf5d574.png ADDED
DermSynth3D/data/annotations/annotator1/02cf3ed8e245eb520cce87fefbf5d574/lesions.png ADDED
DermSynth3D/data/annotations/annotator1/02cf3ed8e245eb520cce87fefbf5d574/nonskin.png ADDED
DermSynth3D/data/annotations/annotator1/02cf3ed8e245eb520cce87fefbf5d574/selected_lesion.png ADDED
DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/02dfbc0e14a4655ca9190705fe1b7d56.png ADDED

Git LFS Details

  • SHA256: d8938490b7eb3aa6df84b79058930dbbda5c3fa00ef472fb874d253427e1ff6f
  • Pointer size: 132 Bytes
  • Size of remote file: 4.07 MB
DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/lesions.png ADDED
DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/nonskin.png ADDED
DermSynth3D/data/annotations/annotator1/02dfbc0e14a4655ca9190705fe1b7d56/selected_lesion.png ADDED
DermSynth3D/data/annotations/annotator1/0a102c96d763d98ab7eec9efd5a38d79/0a102c96d763d98ab7eec9efd5a38d79.jpg ADDED
DermSynth3D/data/annotations/annotator1/0a102c96d763d98ab7eec9efd5a38d79/lesions.png ADDED
DermSynth3D/data/annotations/annotator1/0a102c96d763d98ab7eec9efd5a38d79/nonskin.png ADDED
DermSynth3D/data/annotations/annotator1/0a102c96d763d98ab7eec9efd5a38d79/selected_lesion.png ADDED
DermSynth3D/data/annotations/annotator1/0a55e2e0b4d0241785ba9787829c6dfc/0a55e2e0b4d0241785ba9787829c6dfc.jpg ADDED
DermSynth3D/data/annotations/annotator1/0a55e2e0b4d0241785ba9787829c6dfc/lesions.png ADDED
DermSynth3D/data/annotations/annotator1/0a55e2e0b4d0241785ba9787829c6dfc/nonskin.png ADDED
DermSynth3D/data/annotations/annotator1/0a55e2e0b4d0241785ba9787829c6dfc/selected_lesion.png ADDED
DermSynth3D/data/annotations/annotator1/0a8d57f06114ff087d106c7137520927/lesions.png ADDED
DermSynth3D/data/annotations/annotator1/0a8d57f06114ff087d106c7137520927/nonskin.png ADDED
DermSynth3D/data/annotations/annotator1/0a8d57f06114ff087d106c7137520927/selected_lesion.png ADDED
DermSynth3D/data/annotations/annotator1/0abb64cc8b25d8272ec1df73300600b3/0abb64cc8b25d8272ec1df73300600b3.jpg ADDED
DermSynth3D/data/annotations/annotator1/0abb64cc8b25d8272ec1df73300600b3/lesions.png ADDED