JianyuanWang commited on
Commit
8d7c42a
·
0 Parent(s):

Initial commit

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +40 -0
  2. .gitignore +144 -0
  3. .gradio/certificate.pem +31 -0
  4. CODE_OF_CONDUCT.md +80 -0
  5. CONTRIBUTING.md +31 -0
  6. LICENSE.txt +399 -0
  7. README.md +14 -0
  8. app.py +597 -0
  9. demo_gradio.py +593 -0
  10. demo_viser.py +506 -0
  11. examples/kitchen/images/00.png +3 -0
  12. examples/kitchen/images/01.png +3 -0
  13. examples/kitchen/images/02.png +3 -0
  14. examples/kitchen/images/03.png +3 -0
  15. examples/kitchen/images/04.png +3 -0
  16. examples/kitchen/images/05.png +3 -0
  17. examples/kitchen/images/06.png +3 -0
  18. examples/kitchen/images/07.png +3 -0
  19. examples/kitchen/images/08.png +3 -0
  20. examples/kitchen/images/09.png +3 -0
  21. examples/kitchen/images/10.png +3 -0
  22. examples/kitchen/images/11.png +3 -0
  23. examples/kitchen/images/12.png +3 -0
  24. examples/kitchen/images/13.png +3 -0
  25. examples/kitchen/images/14.png +3 -0
  26. examples/kitchen/images/15.png +3 -0
  27. examples/kitchen/images/16.png +3 -0
  28. examples/kitchen/images/17.png +3 -0
  29. examples/kitchen/images/18.png +3 -0
  30. examples/kitchen/images/19.png +3 -0
  31. examples/kitchen/images/20.png +3 -0
  32. examples/kitchen/images/21.png +3 -0
  33. examples/kitchen/images/22.png +3 -0
  34. examples/kitchen/images/23.png +3 -0
  35. examples/kitchen/images/24.png +3 -0
  36. examples/llff_fern/images/000.png +3 -0
  37. examples/llff_fern/images/001.png +3 -0
  38. examples/llff_fern/images/002.png +3 -0
  39. examples/llff_fern/images/003.png +3 -0
  40. examples/llff_fern/images/004.png +3 -0
  41. examples/llff_fern/images/005.png +3 -0
  42. examples/llff_fern/images/006.png +3 -0
  43. examples/llff_fern/images/007.png +3 -0
  44. examples/llff_fern/images/008.png +3 -0
  45. examples/llff_fern/images/009.png +3 -0
  46. examples/llff_fern/images/010.png +3 -0
  47. examples/llff_fern/images/011.png +3 -0
  48. examples/llff_fern/images/012.png +3 -0
  49. examples/llff_fern/images/013.png +3 -0
  50. examples/llff_fern/images/014.png +3 -0
.gitattributes ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ examples/** filter=lfs diff=lfs merge=lfs -text
37
+ examples/videos/room_video.mp4 filter=lfs diff=lfs merge=lfs -text
38
+ examples/room/images/IMG_1506.HEIC.JPG filter=lfs diff=lfs merge=lfs -text
39
+ skyseg.onnx filter=lfs diff=lfs merge=lfs -text
40
+ examples/ filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .hydra/
2
+ output/
3
+ ckpt/
4
+ dependency/
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ pip-wheel-metadata/
28
+ share/python-wheels/
29
+ *.egg-info/
30
+ .installed.cfg
31
+ *.egg
32
+ MANIFEST
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
+ cover/
58
+
59
+ # Translations
60
+ *.mo
61
+ *.pot
62
+
63
+ # Django stuff:
64
+ *.log
65
+ local_settings.py
66
+ db.sqlite3
67
+ db.sqlite3-journal
68
+
69
+ # Flask stuff:
70
+ instance/
71
+ .webassets-cache
72
+
73
+ # Scrapy stuff:
74
+ .scrapy
75
+
76
+ # Sphinx documentation
77
+ docs/_build/
78
+
79
+ # PyBuilder
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ .python-version
91
+
92
+ # pipenv
93
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
95
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
96
+ # install all needed dependencies.
97
+ #Pipfile.lock
98
+
99
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
100
+ __pypackages__/
101
+
102
+ # Celery stuff
103
+ celerybeat-schedule
104
+ celerybeat.pid
105
+
106
+ # SageMath parsed files
107
+ *.sage.py
108
+
109
+ # Environments
110
+ .env
111
+ .venv
112
+ env/
113
+ venv/
114
+ ENV/
115
+ env.bak/
116
+ venv.bak/
117
+
118
+ # Spyder project settings
119
+ .spyderproject
120
+ .spyproject
121
+
122
+ # Rope project settings
123
+ .ropeproject
124
+
125
+ # mkdocs documentation
126
+ /site
127
+
128
+ # mypy
129
+ .mypy_cache/
130
+ .dmypy.json
131
+ dmypy.json
132
+
133
+ # Pyre type checker
134
+ .pyre/
135
+
136
+ # pytype static type analyzer
137
+ .pytype/
138
+
139
+ # Profiling data
140
+ .prof
141
+
142
+ # Folder specific to your needs
143
+ **/tmp/
144
+ **/outputs/skyseg.onnx
.gradio/certificate.pem ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
3
+ TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
4
+ cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
5
+ WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
6
+ ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
7
+ MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
8
+ h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
9
+ 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
10
+ A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
11
+ T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
12
+ B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC
13
+ B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv
14
+ KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn
15
+ OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn
16
+ jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw
17
+ qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI
18
+ rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
19
+ HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq
20
+ hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
21
+ ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ
22
+ 3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK
23
+ NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5
24
+ ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur
25
+ TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC
26
+ jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc
27
+ oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
28
+ 4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
29
+ mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
30
+ emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
31
+ -----END CERTIFICATE-----
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to make participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies within all project spaces, and it also applies when
49
+ an individual is representing the project or its community in public spaces.
50
+ Examples of representing a project or community include using an official
51
+ project e-mail address, posting via an official social media account, or acting
52
+ as an appointed representative at an online or offline event. Representation of
53
+ a project may be further defined and clarified by project maintainers.
54
+
55
+ This Code of Conduct also applies outside the project spaces when there is a
56
+ reasonable belief that an individual's behavior may have a negative impact on
57
+ the project or its community.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported by contacting the project team at <[email protected]>. All
63
+ complaints will be reviewed and investigated and will result in a response that
64
+ is deemed necessary and appropriate to the circumstances. The project team is
65
+ obligated to maintain confidentiality with regard to the reporter of an incident.
66
+ Further details of specific enforcement policies may be posted separately.
67
+
68
+ Project maintainers who do not follow or enforce the Code of Conduct in good
69
+ faith may face temporary or permanent repercussions as determined by other
70
+ members of the project's leadership.
71
+
72
+ ## Attribution
73
+
74
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
75
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
76
+
77
+ [homepage]: https://www.contributor-covenant.org
78
+
79
+ For answers to common questions about this code of conduct, see
80
+ https://www.contributor-covenant.org/faq
CONTRIBUTING.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to vggt
2
+ We want to make contributing to this project as easy and transparent as
3
+ possible.
4
+
5
+ ## Pull Requests
6
+ We actively welcome your pull requests.
7
+
8
+ 1. Fork the repo and create your branch from `main`.
9
+ 2. If you've added code that should be tested, add tests.
10
+ 3. If you've changed APIs, update the documentation.
11
+ 4. Ensure the test suite passes.
12
+ 5. Make sure your code lints.
13
+ 6. If you haven't already, complete the Contributor License Agreement ("CLA").
14
+
15
+ ## Contributor License Agreement ("CLA")
16
+ In order to accept your pull request, we need you to submit a CLA. You only need
17
+ to do this once to work on any of Facebook's open source projects.
18
+
19
+ Complete your CLA here: <https://code.facebook.com/cla>
20
+
21
+ ## Issues
22
+ We use GitHub issues to track public bugs. Please ensure your description is
23
+ clear and has sufficient instructions to be able to reproduce the issue.
24
+
25
+ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
26
+ disclosure of security bugs. In those cases, please go through the process
27
+ outlined on that page and do not file a public issue.
28
+
29
+ ## License
30
+ By contributing to vggt, you agree that your contributions will be licensed
31
+ under the LICENSE file in the root directory of this source tree.
LICENSE.txt ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution-NonCommercial 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More_considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution-NonCommercial 4.0 International Public
58
+ License
59
+
60
+ By exercising the Licensed Rights (defined below), You accept and agree
61
+ to be bound by the terms and conditions of this Creative Commons
62
+ Attribution-NonCommercial 4.0 International Public License ("Public
63
+ License"). To the extent this Public License may be interpreted as a
64
+ contract, You are granted the Licensed Rights in consideration of Your
65
+ acceptance of these terms and conditions, and the Licensor grants You
66
+ such rights in consideration of benefits the Licensor receives from
67
+ making the Licensed Material available under these terms and
68
+ conditions.
69
+
70
+ Section 1 -- Definitions.
71
+
72
+ a. Adapted Material means material subject to Copyright and Similar
73
+ Rights that is derived from or based upon the Licensed Material
74
+ and in which the Licensed Material is translated, altered,
75
+ arranged, transformed, or otherwise modified in a manner requiring
76
+ permission under the Copyright and Similar Rights held by the
77
+ Licensor. For purposes of this Public License, where the Licensed
78
+ Material is a musical work, performance, or sound recording,
79
+ Adapted Material is always produced where the Licensed Material is
80
+ synched in timed relation with a moving image.
81
+
82
+ b. Adapter's License means the license You apply to Your Copyright
83
+ and Similar Rights in Your contributions to Adapted Material in
84
+ accordance with the terms and conditions of this Public License.
85
+
86
+ c. Copyright and Similar Rights means copyright and/or similar rights
87
+ closely related to copyright including, without limitation,
88
+ performance, broadcast, sound recording, and Sui Generis Database
89
+ Rights, without regard to how the rights are labeled or
90
+ categorized. For purposes of this Public License, the rights
91
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
92
+ Rights.
93
+ d. Effective Technological Measures means those measures that, in the
94
+ absence of proper authority, may not be circumvented under laws
95
+ fulfilling obligations under Article 11 of the WIPO Copyright
96
+ Treaty adopted on December 20, 1996, and/or similar international
97
+ agreements.
98
+
99
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
100
+ any other exception or limitation to Copyright and Similar Rights
101
+ that applies to Your use of the Licensed Material.
102
+
103
+ f. Licensed Material means the artistic or literary work, database,
104
+ or other material to which the Licensor applied this Public
105
+ License.
106
+
107
+ g. Licensed Rights means the rights granted to You subject to the
108
+ terms and conditions of this Public License, which are limited to
109
+ all Copyright and Similar Rights that apply to Your use of the
110
+ Licensed Material and that the Licensor has authority to license.
111
+
112
+ h. Licensor means the individual(s) or entity(ies) granting rights
113
+ under this Public License.
114
+
115
+ i. NonCommercial means not primarily intended for or directed towards
116
+ commercial advantage or monetary compensation. For purposes of
117
+ this Public License, the exchange of the Licensed Material for
118
+ other material subject to Copyright and Similar Rights by digital
119
+ file-sharing or similar means is NonCommercial provided there is
120
+ no payment of monetary compensation in connection with the
121
+ exchange.
122
+
123
+ j. Share means to provide material to the public by any means or
124
+ process that requires permission under the Licensed Rights, such
125
+ as reproduction, public display, public performance, distribution,
126
+ dissemination, communication, or importation, and to make material
127
+ available to the public including in ways that members of the
128
+ public may access the material from a place and at a time
129
+ individually chosen by them.
130
+
131
+ k. Sui Generis Database Rights means rights other than copyright
132
+ resulting from Directive 96/9/EC of the European Parliament and of
133
+ the Council of 11 March 1996 on the legal protection of databases,
134
+ as amended and/or succeeded, as well as other essentially
135
+ equivalent rights anywhere in the world.
136
+
137
+ l. You means the individual or entity exercising the Licensed Rights
138
+ under this Public License. Your has a corresponding meaning.
139
+
140
+ Section 2 -- Scope.
141
+
142
+ a. License grant.
143
+
144
+ 1. Subject to the terms and conditions of this Public License,
145
+ the Licensor hereby grants You a worldwide, royalty-free,
146
+ non-sublicensable, non-exclusive, irrevocable license to
147
+ exercise the Licensed Rights in the Licensed Material to:
148
+
149
+ a. reproduce and Share the Licensed Material, in whole or
150
+ in part, for NonCommercial purposes only; and
151
+
152
+ b. produce, reproduce, and Share Adapted Material for
153
+ NonCommercial purposes only.
154
+
155
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
156
+ Exceptions and Limitations apply to Your use, this Public
157
+ License does not apply, and You do not need to comply with
158
+ its terms and conditions.
159
+
160
+ 3. Term. The term of this Public License is specified in Section
161
+ 6(a).
162
+
163
+ 4. Media and formats; technical modifications allowed. The
164
+ Licensor authorizes You to exercise the Licensed Rights in
165
+ all media and formats whether now known or hereafter created,
166
+ and to make technical modifications necessary to do so. The
167
+ Licensor waives and/or agrees not to assert any right or
168
+ authority to forbid You from making technical modifications
169
+ necessary to exercise the Licensed Rights, including
170
+ technical modifications necessary to circumvent Effective
171
+ Technological Measures. For purposes of this Public License,
172
+ simply making modifications authorized by this Section 2(a)
173
+ (4) never produces Adapted Material.
174
+
175
+ 5. Downstream recipients.
176
+
177
+ a. Offer from the Licensor -- Licensed Material. Every
178
+ recipient of the Licensed Material automatically
179
+ receives an offer from the Licensor to exercise the
180
+ Licensed Rights under the terms and conditions of this
181
+ Public License.
182
+
183
+ b. No downstream restrictions. You may not offer or impose
184
+ any additional or different terms or conditions on, or
185
+ apply any Effective Technological Measures to, the
186
+ Licensed Material if doing so restricts exercise of the
187
+ Licensed Rights by any recipient of the Licensed
188
+ Material.
189
+
190
+ 6. No endorsement. Nothing in this Public License constitutes or
191
+ may be construed as permission to assert or imply that You
192
+ are, or that Your use of the Licensed Material is, connected
193
+ with, or sponsored, endorsed, or granted official status by,
194
+ the Licensor or others designated to receive attribution as
195
+ provided in Section 3(a)(1)(A)(i).
196
+
197
+ b. Other rights.
198
+
199
+ 1. Moral rights, such as the right of integrity, are not
200
+ licensed under this Public License, nor are publicity,
201
+ privacy, and/or other similar personality rights; however, to
202
+ the extent possible, the Licensor waives and/or agrees not to
203
+ assert any such rights held by the Licensor to the limited
204
+ extent necessary to allow You to exercise the Licensed
205
+ Rights, but not otherwise.
206
+
207
+ 2. Patent and trademark rights are not licensed under this
208
+ Public License.
209
+
210
+ 3. To the extent possible, the Licensor waives any right to
211
+ collect royalties from You for the exercise of the Licensed
212
+ Rights, whether directly or through a collecting society
213
+ under any voluntary or waivable statutory or compulsory
214
+ licensing scheme. In all other cases the Licensor expressly
215
+ reserves any right to collect such royalties, including when
216
+ the Licensed Material is used other than for NonCommercial
217
+ purposes.
218
+
219
+ Section 3 -- License Conditions.
220
+
221
+ Your exercise of the Licensed Rights is expressly made subject to the
222
+ following conditions.
223
+
224
+ a. Attribution.
225
+
226
+ 1. If You Share the Licensed Material (including in modified
227
+ form), You must:
228
+
229
+ a. retain the following if it is supplied by the Licensor
230
+ with the Licensed Material:
231
+
232
+ i. identification of the creator(s) of the Licensed
233
+ Material and any others designated to receive
234
+ attribution, in any reasonable manner requested by
235
+ the Licensor (including by pseudonym if
236
+ designated);
237
+
238
+ ii. a copyright notice;
239
+
240
+ iii. a notice that refers to this Public License;
241
+
242
+ iv. a notice that refers to the disclaimer of
243
+ warranties;
244
+
245
+ v. a URI or hyperlink to the Licensed Material to the
246
+ extent reasonably practicable;
247
+
248
+ b. indicate if You modified the Licensed Material and
249
+ retain an indication of any previous modifications; and
250
+
251
+ c. indicate the Licensed Material is licensed under this
252
+ Public License, and include the text of, or the URI or
253
+ hyperlink to, this Public License.
254
+
255
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
256
+ reasonable manner based on the medium, means, and context in
257
+ which You Share the Licensed Material. For example, it may be
258
+ reasonable to satisfy the conditions by providing a URI or
259
+ hyperlink to a resource that includes the required
260
+ information.
261
+
262
+ 3. If requested by the Licensor, You must remove any of the
263
+ information required by Section 3(a)(1)(A) to the extent
264
+ reasonably practicable.
265
+
266
+ 4. If You Share Adapted Material You produce, the Adapter's
267
+ License You apply must not prevent recipients of the Adapted
268
+ Material from complying with this Public License.
269
+
270
+ Section 4 -- Sui Generis Database Rights.
271
+
272
+ Where the Licensed Rights include Sui Generis Database Rights that
273
+ apply to Your use of the Licensed Material:
274
+
275
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
276
+ to extract, reuse, reproduce, and Share all or a substantial
277
+ portion of the contents of the database for NonCommercial purposes
278
+ only;
279
+
280
+ b. if You include all or a substantial portion of the database
281
+ contents in a database in which You have Sui Generis Database
282
+ Rights, then the database in which You have Sui Generis Database
283
+ Rights (but not its individual contents) is Adapted Material; and
284
+
285
+ c. You must comply with the conditions in Section 3(a) if You Share
286
+ all or a substantial portion of the contents of the database.
287
+
288
+ For the avoidance of doubt, this Section 4 supplements and does not
289
+ replace Your obligations under this Public License where the Licensed
290
+ Rights include other Copyright and Similar Rights.
291
+
292
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
293
+
294
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
295
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
296
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
297
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
298
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
299
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
300
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
301
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
302
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
303
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
304
+
305
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
306
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
307
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
308
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
309
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
310
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
311
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
312
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
313
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
314
+
315
+ c. The disclaimer of warranties and limitation of liability provided
316
+ above shall be interpreted in a manner that, to the extent
317
+ possible, most closely approximates an absolute disclaimer and
318
+ waiver of all liability.
319
+
320
+ Section 6 -- Term and Termination.
321
+
322
+ a. This Public License applies for the term of the Copyright and
323
+ Similar Rights licensed here. However, if You fail to comply with
324
+ this Public License, then Your rights under this Public License
325
+ terminate automatically.
326
+
327
+ b. Where Your right to use the Licensed Material has terminated under
328
+ Section 6(a), it reinstates:
329
+
330
+ 1. automatically as of the date the violation is cured, provided
331
+ it is cured within 30 days of Your discovery of the
332
+ violation; or
333
+
334
+ 2. upon express reinstatement by the Licensor.
335
+
336
+ For the avoidance of doubt, this Section 6(b) does not affect any
337
+ right the Licensor may have to seek remedies for Your violations
338
+ of this Public License.
339
+
340
+ c. For the avoidance of doubt, the Licensor may also offer the
341
+ Licensed Material under separate terms or conditions or stop
342
+ distributing the Licensed Material at any time; however, doing so
343
+ will not terminate this Public License.
344
+
345
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
346
+ License.
347
+
348
+ Section 7 -- Other Terms and Conditions.
349
+
350
+ a. The Licensor shall not be bound by any additional or different
351
+ terms or conditions communicated by You unless expressly agreed.
352
+
353
+ b. Any arrangements, understandings, or agreements regarding the
354
+ Licensed Material not stated herein are separate from and
355
+ independent of the terms and conditions of this Public License.
356
+
357
+ Section 8 -- Interpretation.
358
+
359
+ a. For the avoidance of doubt, this Public License does not, and
360
+ shall not be interpreted to, reduce, limit, restrict, or impose
361
+ conditions on any use of the Licensed Material that could lawfully
362
+ be made without permission under this Public License.
363
+
364
+ b. To the extent possible, if any provision of this Public License is
365
+ deemed unenforceable, it shall be automatically reformed to the
366
+ minimum extent necessary to make it enforceable. If the provision
367
+ cannot be reformed, it shall be severed from this Public License
368
+ without affecting the enforceability of the remaining terms and
369
+ conditions.
370
+
371
+ c. No term or condition of this Public License will be waived and no
372
+ failure to comply consented to unless expressly agreed to by the
373
+ Licensor.
374
+
375
+ d. Nothing in this Public License constitutes or may be interpreted
376
+ as a limitation upon, or waiver of, any privileges and immunities
377
+ that apply to the Licensor or You, including from the legal
378
+ processes of any jurisdiction or authority.
379
+
380
+ =======================================================================
381
+
382
+ Creative Commons is not a party to its public
383
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
384
+ its public licenses to material it publishes and in those instances
385
+ will be considered the “Licensor.” The text of the Creative Commons
386
+ public licenses is dedicated to the public domain under the CC0 Public
387
+ Domain Dedication. Except for the limited purpose of indicating that
388
+ material is shared under a Creative Commons public license or as
389
+ otherwise permitted by the Creative Commons policies published at
390
+ creativecommons.org/policies, Creative Commons does not authorize the
391
+ use of the trademark "Creative Commons" or any other trademark or logo
392
+ of Creative Commons without its prior written consent including,
393
+ without limitation, in connection with any unauthorized modifications
394
+ to any of its public licenses or any other arrangements,
395
+ understandings, or agreements concerning use of licensed material. For
396
+ the avoidance of doubt, this paragraph does not form part of the
397
+ public licenses.
398
+
399
+ Creative Commons may be contacted at creativecommons.org.
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: vggt
3
+ emoji: 🏆
4
+ colorFrom: indigo
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 5.17.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: cc-by-nc-4.0
11
+ short_description: vggt (alpha test)
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,597 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ import os
8
+ import cv2
9
+ import torch
10
+ import numpy as np
11
+ import gradio as gr
12
+ import sys
13
+ import shutil
14
+ from datetime import datetime
15
+ import glob
16
+ import gc
17
+ import time
18
+ import spaces
19
+
20
+
21
+ sys.path.append("vggt/")
22
+
23
+ from gradio_util import predictions_to_glb
24
+ from vggt.models.vggt import VGGT
25
+ from vggt.utils.load_fn import load_and_preprocess_images
26
+ from vggt.utils.pose_enc import pose_encoding_to_extri_intri
27
+ from vggt.utils.geometry import unproject_depth_map_to_point_map
28
+
29
+
30
+ print("Initializing and loading VGGT model...")
31
+ # model = VGGT.from_pretrained("facebook/VGGT-1B") # another way to load the model
32
+
33
+ # device = "cuda" if torch.cuda.is_available() else "cpu"
34
+ model = VGGT()
35
+ _URL = "https://huggingface.co/facebook/VGGT-1B/resolve/main/model.pt"
36
+ model.load_state_dict(torch.hub.load_state_dict_from_url(_URL))
37
+ model.eval()
38
+ # model = model.to(device)
39
+
40
+
41
+ # -------------------------------------------------------------------------
42
+ # 1) Core model inference
43
+ # -------------------------------------------------------------------------
44
+ @spaces.GPU(duration=120)
45
+ def run_model(target_dir, model) -> dict:
46
+ """
47
+ Run the VGGT model on images in the 'target_dir/images' folder and return predictions.
48
+ """
49
+ print(f"Processing images from {target_dir}")
50
+
51
+ # Device check
52
+ device = "cuda" if torch.cuda.is_available() else "cpu"
53
+ if not torch.cuda.is_available():
54
+ raise ValueError("CUDA is not available. Check your environment.")
55
+
56
+ # Move model to device
57
+ model = model.to(device)
58
+ model.eval()
59
+
60
+ # Load and preprocess images
61
+ image_names = glob.glob(os.path.join(target_dir, "images", "*"))
62
+ image_names = sorted(image_names)
63
+ print(f"Found {len(image_names)} images")
64
+ if len(image_names) == 0:
65
+ raise ValueError("No images found. Check your upload.")
66
+
67
+ images = load_and_preprocess_images(image_names).to(device)
68
+ print(f"Preprocessed images shape: {images.shape}")
69
+
70
+ # Run inference
71
+ print("Running inference...")
72
+ with torch.no_grad():
73
+ with torch.cuda.amp.autocast(dtype=torch.bfloat16):
74
+ predictions = model(images)
75
+
76
+ # Convert pose encoding to extrinsic and intrinsic matrices
77
+ print("Converting pose encoding to extrinsic and intrinsic matrices...")
78
+ extrinsic, intrinsic = pose_encoding_to_extri_intri(predictions["pose_enc"], images.shape[-2:])
79
+ predictions["extrinsic"] = extrinsic
80
+ predictions["intrinsic"] = intrinsic
81
+
82
+ # Convert tensors to numpy
83
+ for key in predictions.keys():
84
+ if isinstance(predictions[key], torch.Tensor):
85
+ predictions[key] = predictions[key].cpu().numpy().squeeze(0) # remove batch dimension
86
+
87
+ # Generate world points from depth map
88
+ print("Computing world points from depth map...")
89
+ depth_map = predictions["depth"] # (S, H, W, 1)
90
+ world_points = unproject_depth_map_to_point_map(depth_map, predictions["extrinsic"], predictions["intrinsic"])
91
+ predictions["world_points_from_depth"] = world_points
92
+
93
+ # Clean up
94
+ torch.cuda.empty_cache()
95
+ return predictions
96
+
97
+
98
+ # -------------------------------------------------------------------------
99
+ # 2) Handle uploaded video/images --> produce target_dir + images
100
+ # -------------------------------------------------------------------------
101
+ def handle_uploads(input_video, input_images):
102
+ """
103
+ Create a new 'target_dir' + 'images' subfolder, and place user-uploaded
104
+ images or extracted frames from video into it. Return (target_dir, image_paths).
105
+ """
106
+ start_time = time.time()
107
+ gc.collect()
108
+ torch.cuda.empty_cache()
109
+
110
+ # Create a unique folder name
111
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S_%f")
112
+ target_dir = f"input_images_{timestamp}"
113
+ target_dir_images = os.path.join(target_dir, "images")
114
+
115
+ # Clean up if somehow that folder already exists
116
+ if os.path.exists(target_dir):
117
+ shutil.rmtree(target_dir)
118
+ os.makedirs(target_dir)
119
+ os.makedirs(target_dir_images)
120
+
121
+ image_paths = []
122
+
123
+ # --- Handle images ---
124
+ if input_images is not None:
125
+ for file_data in input_images:
126
+ if isinstance(file_data, dict) and "name" in file_data:
127
+ file_path = file_data["name"]
128
+ else:
129
+ file_path = file_data
130
+ dst_path = os.path.join(target_dir_images, os.path.basename(file_path))
131
+ shutil.copy(file_path, dst_path)
132
+ image_paths.append(dst_path)
133
+
134
+ # --- Handle video ---
135
+ if input_video is not None:
136
+ if isinstance(input_video, dict) and "name" in input_video:
137
+ video_path = input_video["name"]
138
+ else:
139
+ video_path = input_video
140
+
141
+ vs = cv2.VideoCapture(video_path)
142
+ fps = vs.get(cv2.CAP_PROP_FPS)
143
+ frame_interval = int(fps * 1) # 1 frame/sec
144
+
145
+ count = 0
146
+ video_frame_num = 0
147
+ while True:
148
+ gotit, frame = vs.read()
149
+ if not gotit:
150
+ break
151
+ count += 1
152
+ if count % frame_interval == 0:
153
+ image_path = os.path.join(target_dir_images, f"{video_frame_num:06}.png")
154
+ cv2.imwrite(image_path, frame)
155
+ image_paths.append(image_path)
156
+ video_frame_num += 1
157
+
158
+ # Sort final images for gallery
159
+ image_paths = sorted(image_paths)
160
+
161
+ end_time = time.time()
162
+ print(f"Files copied to {target_dir_images}; took {end_time - start_time:.3f} seconds")
163
+ return target_dir, image_paths
164
+
165
+
166
+ # -------------------------------------------------------------------------
167
+ # 3) Update gallery on upload
168
+ # -------------------------------------------------------------------------
169
+ def update_gallery_on_upload(input_video, input_images):
170
+ """
171
+ Whenever user uploads or changes files, immediately handle them
172
+ and show in the gallery. Return (target_dir, image_paths).
173
+ If nothing is uploaded, returns "None" and empty list.
174
+ """
175
+ if not input_video and not input_images:
176
+ return None, None, None, None
177
+ target_dir, image_paths = handle_uploads(input_video, input_images)
178
+ return None, target_dir, image_paths, "Upload complete. Click 'Reconstruct' to begin 3D processing."
179
+
180
+
181
+ # -------------------------------------------------------------------------
182
+ # 4) Reconstruction: uses the target_dir plus any viz parameters
183
+ # -------------------------------------------------------------------------
184
+ @spaces.GPU(duration=120)
185
+ def gradio_demo(
186
+ target_dir,
187
+ conf_thres=3.0,
188
+ frame_filter="All",
189
+ mask_black_bg=False,
190
+ mask_white_bg=False,
191
+ show_cam=True,
192
+ mask_sky=False,
193
+ prediction_mode="Pointmap Regression",
194
+ ):
195
+ """
196
+ Perform reconstruction using the already-created target_dir/images.
197
+ """
198
+ if not os.path.isdir(target_dir) or target_dir == "None":
199
+ return None, "No valid target directory found. Please upload first.", None, None
200
+
201
+ start_time = time.time()
202
+ gc.collect()
203
+ torch.cuda.empty_cache()
204
+
205
+ # Prepare frame_filter dropdown
206
+ target_dir_images = os.path.join(target_dir, "images")
207
+ all_files = sorted(os.listdir(target_dir_images)) if os.path.isdir(target_dir_images) else []
208
+ all_files = [f"{i}: {filename}" for i, filename in enumerate(all_files)]
209
+ frame_filter_choices = ["All"] + all_files
210
+
211
+ print("Running run_model...")
212
+ with torch.no_grad():
213
+ predictions = run_model(target_dir, model)
214
+
215
+ # Save predictions
216
+ prediction_save_path = os.path.join(target_dir, "predictions.npz")
217
+ np.savez(prediction_save_path, **predictions)
218
+
219
+ # Build a GLB file name
220
+ glbfile = os.path.join(
221
+ target_dir,
222
+ f"glbscene_{conf_thres}_{frame_filter.replace('.', '_').replace(':', '').replace(' ', '_')}_maskb{mask_black_bg}_maskw{mask_white_bg}_cam{show_cam}_sky{mask_sky}_pred{prediction_mode.replace(' ', '_')}.glb",
223
+ )
224
+
225
+ # Convert predictions to GLB
226
+ glbscene = predictions_to_glb(
227
+ predictions,
228
+ conf_thres=conf_thres,
229
+ filter_by_frames=frame_filter,
230
+ mask_black_bg=mask_black_bg,
231
+ mask_white_bg=mask_white_bg,
232
+ show_cam=show_cam,
233
+ mask_sky=mask_sky,
234
+ target_dir=target_dir,
235
+ prediction_mode=prediction_mode,
236
+ )
237
+ glbscene.export(file_obj=glbfile)
238
+
239
+ # Cleanup
240
+ del predictions
241
+ gc.collect()
242
+ torch.cuda.empty_cache()
243
+
244
+ end_time = time.time()
245
+ print(f"Total time: {end_time - start_time:.2f} seconds")
246
+ log_msg = f"Reconstruction Success ({len(all_files)} frames). Waiting for visualization."
247
+
248
+ return glbfile, log_msg, gr.Dropdown(choices=frame_filter_choices, value=frame_filter, interactive=True)
249
+
250
+
251
+ # -------------------------------------------------------------------------
252
+ # 5) Helper functions for UI resets + re-visualization
253
+ # -------------------------------------------------------------------------
254
+ def clear_fields():
255
+ """
256
+ Clears the 3D viewer, the stored target_dir, and empties the gallery.
257
+ """
258
+ return None
259
+
260
+
261
+ def update_log():
262
+ """
263
+ Display a quick log message while waiting.
264
+ """
265
+ return "Loading and Reconstructing..."
266
+
267
+
268
+ def update_visualization(
269
+ target_dir, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example
270
+ ):
271
+ """
272
+ Reload saved predictions from npz, create (or reuse) the GLB for new parameters,
273
+ and return it for the 3D viewer. If is_example == "True", skip.
274
+ """
275
+
276
+ # If it's an example click, skip as requested
277
+ if is_example == "True":
278
+ return None, "No reconstruction available. Please click the Reconstruct button first."
279
+
280
+ if not target_dir or target_dir == "None" or not os.path.isdir(target_dir):
281
+ return None, "No reconstruction available. Please click the Reconstruct button first."
282
+
283
+ predictions_path = os.path.join(target_dir, "predictions.npz")
284
+ if not os.path.exists(predictions_path):
285
+ return None, f"No reconstruction available at {predictions_path}. Please run 'Reconstruct' first."
286
+
287
+ loaded = np.load(predictions_path, allow_pickle=True)
288
+ predictions = {key: loaded[key] for key in loaded.keys()}
289
+
290
+ glbfile = os.path.join(
291
+ target_dir,
292
+ f"glbscene_{conf_thres}_{frame_filter.replace('.', '_').replace(':', '').replace(' ', '_')}_maskb{mask_black_bg}_maskw{mask_white_bg}_cam{show_cam}_sky{mask_sky}_pred{prediction_mode.replace(' ', '_')}.glb",
293
+ )
294
+
295
+ if not os.path.exists(glbfile):
296
+ glbscene = predictions_to_glb(
297
+ predictions,
298
+ conf_thres=conf_thres,
299
+ filter_by_frames=frame_filter,
300
+ mask_black_bg=mask_black_bg,
301
+ mask_white_bg=mask_white_bg,
302
+ show_cam=show_cam,
303
+ mask_sky=mask_sky,
304
+ target_dir=target_dir,
305
+ prediction_mode=prediction_mode,
306
+ )
307
+ glbscene.export(file_obj=glbfile)
308
+
309
+ return glbfile, "Updating Visualization"
310
+
311
+
312
+ # -------------------------------------------------------------------------
313
+ # Example images
314
+ # -------------------------------------------------------------------------
315
+
316
+ canyon_video = "examples/videos/Studlagil_Canyon_East_Iceland.mp4"
317
+ great_wall_video = "examples/videos/great_wall.mp4"
318
+ colosseum_video = "examples/videos/Colosseum.mp4"
319
+ room_video = "examples/videos/room.mp4"
320
+ kitchen_video = "examples/videos/kitchen.mp4"
321
+ fern_video = "examples/videos/fern.mp4"
322
+ single_cartoon_video = "examples/videos/single_cartoon.mp4"
323
+ single_oil_painting_video = "examples/videos/single_oil_painting.mp4"
324
+ pyramid_video = "examples/videos/pyramid.mp4"
325
+
326
+
327
+ # -------------------------------------------------------------------------
328
+ # 6) Build Gradio UI
329
+ # -------------------------------------------------------------------------
330
+ theme = gr.themes.Ocean()
331
+ theme.set(
332
+ checkbox_label_background_fill_selected="*button_primary_background_fill",
333
+ checkbox_label_text_color_selected="*button_primary_text_color",
334
+ )
335
+
336
+ with gr.Blocks(
337
+ theme=theme,
338
+ css="""
339
+ .custom-log * {
340
+ font-style: italic;
341
+ font-size: 22px !important;
342
+ background-image: linear-gradient(120deg, #0ea5e9 0%, #6ee7b7 60%, #34d399 100%);
343
+ -webkit-background-clip: text;
344
+ background-clip: text;
345
+ font-weight: bold !important;
346
+ color: transparent !important;
347
+ text-align: center !important;
348
+ }
349
+
350
+ .example-log * {
351
+ font-style: italic;
352
+ font-size: 16px !important;
353
+ background-image: linear-gradient(120deg, #0ea5e9 0%, #6ee7b7 60%, #34d399 100%);
354
+ -webkit-background-clip: text;
355
+ background-clip: text;
356
+ color: transparent !important;
357
+ }
358
+
359
+ #my_radio .wrap {
360
+ display: flex;
361
+ flex-wrap: nowrap;
362
+ justify-content: center;
363
+ align-items: center;
364
+ }
365
+
366
+ #my_radio .wrap label {
367
+ display: flex;
368
+ width: 50%;
369
+ justify-content: center;
370
+ align-items: center;
371
+ margin: 0;
372
+ padding: 10px 0;
373
+ box-sizing: border-box;
374
+ }
375
+ """,
376
+ ) as demo:
377
+
378
+ # Instead of gr.State, we use a hidden Textbox:
379
+ is_example = gr.Textbox(label="is_example", visible=False, value="None")
380
+ num_images = gr.Textbox(label="num_images", visible=False, value="None")
381
+
382
+ gr.Markdown(
383
+ """
384
+ # 🏛️ VGGT: Visual Geometry Grounded Transformer
385
+
386
+ [🐙 GitHub Repository](https://github.com/facebookresearch/vggt) | [Project Page]()
387
+
388
+ <div style="font-size: 16px; line-height: 1.5;">
389
+ <p>Upload a video or a set of images to create a 3D reconstruction of a scene or object. VGGT takes these images and generates a 3D point cloud, along with estimated camera poses.</p>
390
+
391
+ <h3>Getting Started:</h3>
392
+ <ol>
393
+ <li><strong>Upload Your Data:</strong> Use the "Upload Video" or "Upload Images" buttons on the left to provide your input. Videos will be automatically split into individual frames (one frame per second).</li>
394
+ <li><strong>Preview:</strong> Your uploaded images will appear in the gallery on the left.</li>
395
+ <li><strong>Reconstruct:</strong> Click the "Reconstruct" button to start the 3D reconstruction process.</li>
396
+ <li><strong>Visualize:</strong> The 3D reconstruction will appear in the viewer on the right. You can rotate, pan, and zoom to explore the model, and download the GLB file. Note the visualization of 3D points may be slow for large number of input images. </li>
397
+ <li><strong>Adjust Visualization (Optional):</strong> After reconstruction, you can fine-tune the visualization using the options below:
398
+ <ul>
399
+ <li><em>Confidence Threshold:</em> Adjusts the filtering of points based on the model's confidence. Higher values show only the most confident points.</li>
400
+ <li><em>Show Points from Frame:</em> Select specific frames to display in the point cloud. Useful for isolating parts of a scene.</li>
401
+ <li><em>Show Camera:</em> Toggle the display of the estimated camera positions.</li>
402
+ <li><em>Filter Sky / Filter Black Background:</em> These options attempt to remove points corresponding to the sky or black backgrounds.</li>
403
+ <li><em>Select a Prediction Mode:</em> Choose between "Depthmap and Camera Branch" and "Pointmap Branch". They usually look similar, while "Depthmap and Camera Branch" give slightly better details.</li>
404
+ </ul>
405
+ </li>
406
+ </ol>
407
+ <p><strong>Please note:</strong> Our method usually only needs less than 1 second to reconstruct a scene, but the visualization of 3D points may take tens of seconds, especially when the number of images is large. Please be patient or, for faster visualization, use a local machine to run our demo from our <a href="https://github.com/facebookresearch/vggt">GitHub repository</a>.</p>
408
+ </div>
409
+ """
410
+ )
411
+
412
+ target_dir_output = gr.Textbox(label="Target Dir", visible=False, value="None")
413
+
414
+ with gr.Row():
415
+ with gr.Column(scale=2):
416
+ input_video = gr.Video(label="Upload Video", interactive=True)
417
+ input_images = gr.File(file_count="multiple", label="Upload Images", interactive=True)
418
+
419
+ image_gallery = gr.Gallery(
420
+ label="Preview",
421
+ columns=4,
422
+ height="300px",
423
+ show_download_button=True,
424
+ object_fit="contain",
425
+ preview=True,
426
+ )
427
+
428
+ with gr.Column(scale=4):
429
+ with gr.Column():
430
+ gr.Markdown("**3D Reconstruction (Point Cloud and Camera Poses)**")
431
+ log_output = gr.Markdown(
432
+ "Please upload a video or images, then click Reconstruct.", elem_classes=["custom-log"]
433
+ )
434
+ reconstruction_output = gr.Model3D(height=520, zoom_speed=0.5, pan_speed=0.5)
435
+
436
+ with gr.Row():
437
+ submit_btn = gr.Button("Reconstruct", scale=1, variant="primary")
438
+ clear_btn = gr.ClearButton(
439
+ [input_video, input_images, reconstruction_output, log_output, target_dir_output, image_gallery],
440
+ scale=1,
441
+ )
442
+
443
+ with gr.Row():
444
+ prediction_mode = gr.Radio(
445
+ ["Depthmap and Camera Branch", "Pointmap Branch"],
446
+ label="Select a Prediction Mode",
447
+ value="Depthmap and Camera Branch",
448
+ scale=1,
449
+ elem_id="my_radio",
450
+ )
451
+
452
+ with gr.Row():
453
+ conf_thres = gr.Slider(minimum=0, maximum=100, value=50, step=0.1, label="Confidence Threshold (%)")
454
+ frame_filter = gr.Dropdown(choices=["All"], value="All", label="Show Points from Frame")
455
+ with gr.Column():
456
+ show_cam = gr.Checkbox(label="Show Camera", value=True)
457
+ mask_sky = gr.Checkbox(label="Filter Sky", value=False)
458
+ mask_black_bg = gr.Checkbox(label="Filter Black Background", value=False)
459
+ mask_white_bg = gr.Checkbox(label="Filter White Background", value=False)
460
+
461
+ # ---------------------- Examples section ----------------------
462
+ examples = [
463
+ [colosseum_video, "22", None, 20.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
464
+ [pyramid_video, "30", None, 35.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
465
+ [single_cartoon_video, "1", None, 15.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
466
+ [single_oil_painting_video, "1", None, 20.0, False, True, True, True, "Depthmap and Camera Branch", "True"],
467
+ [canyon_video, "14", None, 40.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
468
+ [room_video, "8", None, 5.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
469
+ [kitchen_video, "25", None, 50.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
470
+ [fern_video, "20", None, 45.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
471
+ ]
472
+
473
+ def example_pipeline(
474
+ input_video,
475
+ num_images_str,
476
+ input_images,
477
+ conf_thres,
478
+ mask_black_bg,
479
+ mask_white_bg,
480
+ show_cam,
481
+ mask_sky,
482
+ prediction_mode,
483
+ is_example_str,
484
+ ):
485
+ """
486
+ 1) Copy example images to new target_dir
487
+ 2) Reconstruct
488
+ 3) Return model3D + logs + new_dir + updated dropdown + gallery
489
+ We do NOT return is_example. It's just an input.
490
+ """
491
+ target_dir, image_paths = handle_uploads(input_video, input_images)
492
+ # Always use "All" for frame_filter in examples
493
+ frame_filter = "All"
494
+ glbfile, log_msg, dropdown = gradio_demo(
495
+ target_dir, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode
496
+ )
497
+ return glbfile, log_msg, target_dir, dropdown, image_paths
498
+
499
+ gr.Markdown("Click any row to load an example.", elem_classes=["example-log"])
500
+
501
+ gr.Examples(
502
+ examples=examples,
503
+ inputs=[
504
+ input_video,
505
+ num_images,
506
+ input_images,
507
+ conf_thres,
508
+ mask_black_bg,
509
+ mask_white_bg,
510
+ show_cam,
511
+ mask_sky,
512
+ prediction_mode,
513
+ is_example,
514
+ ],
515
+ outputs=[
516
+ reconstruction_output,
517
+ log_output,
518
+ target_dir_output,
519
+ frame_filter,
520
+ image_gallery,
521
+ ],
522
+ fn=example_pipeline,
523
+ cache_examples=False,
524
+ examples_per_page=50,
525
+ )
526
+
527
+ # -------------------------------------------------------------------------
528
+ # "Reconstruct" button logic:
529
+ # - Clear fields
530
+ # - Update log
531
+ # - gradio_demo(...) with the existing target_dir
532
+ # - Then set is_example = "False"
533
+ # -------------------------------------------------------------------------
534
+ submit_btn.click(fn=clear_fields, inputs=[], outputs=[reconstruction_output]).then(
535
+ fn=update_log, inputs=[], outputs=[log_output]
536
+ ).then(
537
+ fn=gradio_demo,
538
+ inputs=[target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode],
539
+ outputs=[reconstruction_output, log_output, frame_filter],
540
+ ).then(
541
+ fn=lambda: "False", inputs=[], outputs=[is_example] # set is_example to "False"
542
+ )
543
+
544
+ # -------------------------------------------------------------------------
545
+ # Real-time Visualization Updates
546
+ # -------------------------------------------------------------------------
547
+ conf_thres.change(
548
+ update_visualization,
549
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
550
+ [reconstruction_output, log_output],
551
+ )
552
+ frame_filter.change(
553
+ update_visualization,
554
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
555
+ [reconstruction_output, log_output],
556
+ )
557
+ mask_black_bg.change(
558
+ update_visualization,
559
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
560
+ [reconstruction_output, log_output],
561
+ )
562
+ mask_white_bg.change(
563
+ update_visualization,
564
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
565
+ [reconstruction_output, log_output],
566
+ )
567
+ show_cam.change(
568
+ update_visualization,
569
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
570
+ [reconstruction_output, log_output],
571
+ )
572
+ mask_sky.change(
573
+ update_visualization,
574
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
575
+ [reconstruction_output, log_output],
576
+ )
577
+ prediction_mode.change(
578
+ update_visualization,
579
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
580
+ [reconstruction_output, log_output],
581
+ )
582
+
583
+ # -------------------------------------------------------------------------
584
+ # Auto-update gallery whenever user uploads or changes their files
585
+ # -------------------------------------------------------------------------
586
+ input_video.change(
587
+ fn=update_gallery_on_upload,
588
+ inputs=[input_video, input_images],
589
+ outputs=[reconstruction_output, target_dir_output, image_gallery, log_output],
590
+ )
591
+ input_images.change(
592
+ fn=update_gallery_on_upload,
593
+ inputs=[input_video, input_images],
594
+ outputs=[reconstruction_output, target_dir_output, image_gallery, log_output],
595
+ )
596
+
597
+ demo.queue(max_size=20).launch(show_error=True, share=True)
demo_gradio.py ADDED
@@ -0,0 +1,593 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ import os
8
+ import cv2
9
+ import torch
10
+ import numpy as np
11
+ import gradio as gr
12
+ import sys
13
+ import shutil
14
+ from datetime import datetime
15
+ import glob
16
+ import gc
17
+ import time
18
+
19
+ sys.path.append("vggt/")
20
+
21
+ from gradio_util import predictions_to_glb
22
+ from vggt.models.vggt import VGGT
23
+ from vggt.utils.load_fn import load_and_preprocess_images
24
+ from vggt.utils.pose_enc import pose_encoding_to_extri_intri
25
+ from vggt.utils.geometry import unproject_depth_map_to_point_map
26
+
27
+
28
+ print("Initializing and loading VGGT model...")
29
+ # model = VGGT.from_pretrained("facebook/VGGT-1B") # another way to load the model
30
+
31
+ device = "cuda" if torch.cuda.is_available() else "cpu"
32
+ model = VGGT()
33
+ _URL = "https://huggingface.co/facebook/VGGT-1B/resolve/main/model.pt"
34
+ model.load_state_dict(torch.hub.load_state_dict_from_url(_URL))
35
+ model.eval()
36
+ model = model.to(device)
37
+
38
+
39
+ # -------------------------------------------------------------------------
40
+ # 1) Core model inference
41
+ # -------------------------------------------------------------------------
42
+ def run_model(target_dir, model) -> dict:
43
+ """
44
+ Run the VGGT model on images in the 'target_dir/images' folder and return predictions.
45
+ """
46
+ print(f"Processing images from {target_dir}")
47
+
48
+ # Device check
49
+ device = "cuda" if torch.cuda.is_available() else "cpu"
50
+ if not torch.cuda.is_available():
51
+ raise ValueError("CUDA is not available. Check your environment.")
52
+
53
+ # Move model to device
54
+ model = model.to(device)
55
+ model.eval()
56
+
57
+ # Load and preprocess images
58
+ image_names = glob.glob(os.path.join(target_dir, "images", "*"))
59
+ image_names = sorted(image_names)
60
+ print(f"Found {len(image_names)} images")
61
+ if len(image_names) == 0:
62
+ raise ValueError("No images found. Check your upload.")
63
+
64
+ images = load_and_preprocess_images(image_names).to(device)
65
+ print(f"Preprocessed images shape: {images.shape}")
66
+
67
+ # Run inference
68
+ print("Running inference...")
69
+ with torch.no_grad():
70
+ with torch.cuda.amp.autocast(dtype=torch.bfloat16):
71
+ predictions = model(images)
72
+
73
+ # Convert pose encoding to extrinsic and intrinsic matrices
74
+ print("Converting pose encoding to extrinsic and intrinsic matrices...")
75
+ extrinsic, intrinsic = pose_encoding_to_extri_intri(predictions["pose_enc"], images.shape[-2:])
76
+ predictions["extrinsic"] = extrinsic
77
+ predictions["intrinsic"] = intrinsic
78
+
79
+ # Convert tensors to numpy
80
+ for key in predictions.keys():
81
+ if isinstance(predictions[key], torch.Tensor):
82
+ predictions[key] = predictions[key].cpu().numpy().squeeze(0) # remove batch dimension
83
+
84
+ # Generate world points from depth map
85
+ print("Computing world points from depth map...")
86
+ depth_map = predictions["depth"] # (S, H, W, 1)
87
+ world_points = unproject_depth_map_to_point_map(depth_map, predictions["extrinsic"], predictions["intrinsic"])
88
+ predictions["world_points_from_depth"] = world_points
89
+
90
+ # Clean up
91
+ torch.cuda.empty_cache()
92
+ return predictions
93
+
94
+
95
+ # -------------------------------------------------------------------------
96
+ # 2) Handle uploaded video/images --> produce target_dir + images
97
+ # -------------------------------------------------------------------------
98
+ def handle_uploads(input_video, input_images):
99
+ """
100
+ Create a new 'target_dir' + 'images' subfolder, and place user-uploaded
101
+ images or extracted frames from video into it. Return (target_dir, image_paths).
102
+ """
103
+ start_time = time.time()
104
+ gc.collect()
105
+ torch.cuda.empty_cache()
106
+
107
+ # Create a unique folder name
108
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S_%f")
109
+ target_dir = f"input_images_{timestamp}"
110
+ target_dir_images = os.path.join(target_dir, "images")
111
+
112
+ # Clean up if somehow that folder already exists
113
+ if os.path.exists(target_dir):
114
+ shutil.rmtree(target_dir)
115
+ os.makedirs(target_dir)
116
+ os.makedirs(target_dir_images)
117
+
118
+ image_paths = []
119
+
120
+ # --- Handle images ---
121
+ if input_images is not None:
122
+ for file_data in input_images:
123
+ if isinstance(file_data, dict) and "name" in file_data:
124
+ file_path = file_data["name"]
125
+ else:
126
+ file_path = file_data
127
+ dst_path = os.path.join(target_dir_images, os.path.basename(file_path))
128
+ shutil.copy(file_path, dst_path)
129
+ image_paths.append(dst_path)
130
+
131
+ # --- Handle video ---
132
+ if input_video is not None:
133
+ if isinstance(input_video, dict) and "name" in input_video:
134
+ video_path = input_video["name"]
135
+ else:
136
+ video_path = input_video
137
+
138
+ vs = cv2.VideoCapture(video_path)
139
+ fps = vs.get(cv2.CAP_PROP_FPS)
140
+ frame_interval = int(fps * 1) # 1 frame/sec
141
+
142
+ count = 0
143
+ video_frame_num = 0
144
+ while True:
145
+ gotit, frame = vs.read()
146
+ if not gotit:
147
+ break
148
+ count += 1
149
+ if count % frame_interval == 0:
150
+ image_path = os.path.join(target_dir_images, f"{video_frame_num:06}.png")
151
+ cv2.imwrite(image_path, frame)
152
+ image_paths.append(image_path)
153
+ video_frame_num += 1
154
+
155
+ # Sort final images for gallery
156
+ image_paths = sorted(image_paths)
157
+
158
+ end_time = time.time()
159
+ print(f"Files copied to {target_dir_images}; took {end_time - start_time:.3f} seconds")
160
+ return target_dir, image_paths
161
+
162
+
163
+ # -------------------------------------------------------------------------
164
+ # 3) Update gallery on upload
165
+ # -------------------------------------------------------------------------
166
+ def update_gallery_on_upload(input_video, input_images):
167
+ """
168
+ Whenever user uploads or changes files, immediately handle them
169
+ and show in the gallery. Return (target_dir, image_paths).
170
+ If nothing is uploaded, returns "None" and empty list.
171
+ """
172
+ if not input_video and not input_images:
173
+ return None, None, None, None
174
+ target_dir, image_paths = handle_uploads(input_video, input_images)
175
+ return None, target_dir, image_paths, "Upload complete. Click 'Reconstruct' to begin 3D processing."
176
+
177
+
178
+ # -------------------------------------------------------------------------
179
+ # 4) Reconstruction: uses the target_dir plus any viz parameters
180
+ # -------------------------------------------------------------------------
181
+ def gradio_demo(
182
+ target_dir,
183
+ conf_thres=3.0,
184
+ frame_filter="All",
185
+ mask_black_bg=False,
186
+ mask_white_bg=False,
187
+ show_cam=True,
188
+ mask_sky=False,
189
+ prediction_mode="Pointmap Regression",
190
+ ):
191
+ """
192
+ Perform reconstruction using the already-created target_dir/images.
193
+ """
194
+ if not os.path.isdir(target_dir) or target_dir == "None":
195
+ return None, "No valid target directory found. Please upload first.", None, None
196
+
197
+ start_time = time.time()
198
+ gc.collect()
199
+ torch.cuda.empty_cache()
200
+
201
+ # Prepare frame_filter dropdown
202
+ target_dir_images = os.path.join(target_dir, "images")
203
+ all_files = sorted(os.listdir(target_dir_images)) if os.path.isdir(target_dir_images) else []
204
+ all_files = [f"{i}: {filename}" for i, filename in enumerate(all_files)]
205
+ frame_filter_choices = ["All"] + all_files
206
+
207
+ print("Running run_model...")
208
+ with torch.no_grad():
209
+ predictions = run_model(target_dir, model)
210
+
211
+ # Save predictions
212
+ prediction_save_path = os.path.join(target_dir, "predictions.npz")
213
+ np.savez(prediction_save_path, **predictions)
214
+
215
+ # Build a GLB file name
216
+ glbfile = os.path.join(
217
+ target_dir,
218
+ f"glbscene_{conf_thres}_{frame_filter.replace('.', '_').replace(':', '').replace(' ', '_')}_maskb{mask_black_bg}_maskw{mask_white_bg}_cam{show_cam}_sky{mask_sky}_pred{prediction_mode.replace(' ', '_')}.glb",
219
+ )
220
+
221
+ # Convert predictions to GLB
222
+ glbscene = predictions_to_glb(
223
+ predictions,
224
+ conf_thres=conf_thres,
225
+ filter_by_frames=frame_filter,
226
+ mask_black_bg=mask_black_bg,
227
+ mask_white_bg=mask_white_bg,
228
+ show_cam=show_cam,
229
+ mask_sky=mask_sky,
230
+ target_dir=target_dir,
231
+ prediction_mode=prediction_mode,
232
+ )
233
+ glbscene.export(file_obj=glbfile)
234
+
235
+ # Cleanup
236
+ del predictions
237
+ gc.collect()
238
+ torch.cuda.empty_cache()
239
+
240
+ end_time = time.time()
241
+ print(f"Total time: {end_time - start_time:.2f} seconds")
242
+ log_msg = f"Reconstruction Success ({len(all_files)} frames). Waiting for visualization."
243
+
244
+ return glbfile, log_msg, gr.Dropdown(choices=frame_filter_choices, value=frame_filter, interactive=True)
245
+
246
+
247
+ # -------------------------------------------------------------------------
248
+ # 5) Helper functions for UI resets + re-visualization
249
+ # -------------------------------------------------------------------------
250
+ def clear_fields():
251
+ """
252
+ Clears the 3D viewer, the stored target_dir, and empties the gallery.
253
+ """
254
+ return None
255
+
256
+
257
+ def update_log():
258
+ """
259
+ Display a quick log message while waiting.
260
+ """
261
+ return "Loading and Reconstructing..."
262
+
263
+
264
+ def update_visualization(
265
+ target_dir, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example
266
+ ):
267
+ """
268
+ Reload saved predictions from npz, create (or reuse) the GLB for new parameters,
269
+ and return it for the 3D viewer. If is_example == "True", skip.
270
+ """
271
+
272
+ # If it's an example click, skip as requested
273
+ if is_example == "True":
274
+ return None, "No reconstruction available. Please click the Reconstruct button first."
275
+
276
+ if not target_dir or target_dir == "None" or not os.path.isdir(target_dir):
277
+ return None, "No reconstruction available. Please click the Reconstruct button first."
278
+
279
+ predictions_path = os.path.join(target_dir, "predictions.npz")
280
+ if not os.path.exists(predictions_path):
281
+ return None, f"No reconstruction available at {predictions_path}. Please run 'Reconstruct' first."
282
+
283
+ loaded = np.load(predictions_path, allow_pickle=True)
284
+ predictions = {key: loaded[key] for key in loaded.keys()}
285
+
286
+ glbfile = os.path.join(
287
+ target_dir,
288
+ f"glbscene_{conf_thres}_{frame_filter.replace('.', '_').replace(':', '').replace(' ', '_')}_maskb{mask_black_bg}_maskw{mask_white_bg}_cam{show_cam}_sky{mask_sky}_pred{prediction_mode.replace(' ', '_')}.glb",
289
+ )
290
+
291
+ if not os.path.exists(glbfile):
292
+ glbscene = predictions_to_glb(
293
+ predictions,
294
+ conf_thres=conf_thres,
295
+ filter_by_frames=frame_filter,
296
+ mask_black_bg=mask_black_bg,
297
+ mask_white_bg=mask_white_bg,
298
+ show_cam=show_cam,
299
+ mask_sky=mask_sky,
300
+ target_dir=target_dir,
301
+ prediction_mode=prediction_mode,
302
+ )
303
+ glbscene.export(file_obj=glbfile)
304
+
305
+ return glbfile, "Updating Visualization"
306
+
307
+
308
+ # -------------------------------------------------------------------------
309
+ # Example images
310
+ # -------------------------------------------------------------------------
311
+
312
+ canyon_video = "examples/videos/Studlagil_Canyon_East_Iceland.mp4"
313
+ great_wall_video = "examples/videos/great_wall.mp4"
314
+ colosseum_video = "examples/videos/Colosseum.mp4"
315
+ room_video = "examples/videos/room.mp4"
316
+ kitchen_video = "examples/videos/kitchen.mp4"
317
+ fern_video = "examples/videos/fern.mp4"
318
+ single_cartoon_video = "examples/videos/single_cartoon.mp4"
319
+ single_oil_painting_video = "examples/videos/single_oil_painting.mp4"
320
+ pyramid_video = "examples/videos/pyramid.mp4"
321
+
322
+
323
+ # -------------------------------------------------------------------------
324
+ # 6) Build Gradio UI
325
+ # -------------------------------------------------------------------------
326
+ theme = gr.themes.Ocean()
327
+ theme.set(
328
+ checkbox_label_background_fill_selected="*button_primary_background_fill",
329
+ checkbox_label_text_color_selected="*button_primary_text_color",
330
+ )
331
+
332
+ with gr.Blocks(
333
+ theme=theme,
334
+ css="""
335
+ .custom-log * {
336
+ font-style: italic;
337
+ font-size: 22px !important;
338
+ background-image: linear-gradient(120deg, #0ea5e9 0%, #6ee7b7 60%, #34d399 100%);
339
+ -webkit-background-clip: text;
340
+ background-clip: text;
341
+ font-weight: bold !important;
342
+ color: transparent !important;
343
+ text-align: center !important;
344
+ }
345
+
346
+ .example-log * {
347
+ font-style: italic;
348
+ font-size: 16px !important;
349
+ background-image: linear-gradient(120deg, #0ea5e9 0%, #6ee7b7 60%, #34d399 100%);
350
+ -webkit-background-clip: text;
351
+ background-clip: text;
352
+ color: transparent !important;
353
+ }
354
+
355
+ #my_radio .wrap {
356
+ display: flex;
357
+ flex-wrap: nowrap;
358
+ justify-content: center;
359
+ align-items: center;
360
+ }
361
+
362
+ #my_radio .wrap label {
363
+ display: flex;
364
+ width: 50%;
365
+ justify-content: center;
366
+ align-items: center;
367
+ margin: 0;
368
+ padding: 10px 0;
369
+ box-sizing: border-box;
370
+ }
371
+ """,
372
+ ) as demo:
373
+
374
+ # Instead of gr.State, we use a hidden Textbox:
375
+ is_example = gr.Textbox(label="is_example", visible=False, value="None")
376
+ num_images = gr.Textbox(label="num_images", visible=False, value="None")
377
+
378
+ gr.Markdown(
379
+ """
380
+ # 🏛️ VGGT: Visual Geometry Grounded Transformer
381
+
382
+ [🐙 GitHub Repository](https://github.com/facebookresearch/vggt) | [Project Page]()
383
+
384
+ <div style="font-size: 16px; line-height: 1.5;">
385
+ <p>Upload a video or a set of images to create a 3D reconstruction of a scene or object. VGGT takes these images and generates a 3D point cloud, along with estimated camera poses.</p>
386
+
387
+ <h3>Getting Started:</h3>
388
+ <ol>
389
+ <li><strong>Upload Your Data:</strong> Use the "Upload Video" or "Upload Images" buttons on the left to provide your input. Videos will be automatically split into individual frames (one frame per second).</li>
390
+ <li><strong>Preview:</strong> Your uploaded images will appear in the gallery on the left.</li>
391
+ <li><strong>Reconstruct:</strong> Click the "Reconstruct" button to start the 3D reconstruction process.</li>
392
+ <li><strong>Visualize:</strong> The 3D reconstruction will appear in the viewer on the right. You can rotate, pan, and zoom to explore the model, and download the GLB file. Note the visualization of 3D points may be slow for large number of input images. </li>
393
+ <li><strong>Adjust Visualization (Optional):</strong> After reconstruction, you can fine-tune the visualization using the options below:
394
+ <ul>
395
+ <li><em>Confidence Threshold:</em> Adjusts the filtering of points based on the model's confidence. Higher values show only the most confident points.</li>
396
+ <li><em>Show Points from Frame:</em> Select specific frames to display in the point cloud. Useful for isolating parts of a scene.</li>
397
+ <li><em>Show Camera:</em> Toggle the display of the estimated camera positions.</li>
398
+ <li><em>Filter Sky / Filter Black Background:</em> These options attempt to remove points corresponding to the sky or black backgrounds.</li>
399
+ <li><em>Select a Prediction Mode:</em> Choose between "Depthmap and Camera Branch" and "Pointmap Branch". They usually look similar, while "Depthmap and Camera Branch" give slightly better details.</li>
400
+ </ul>
401
+ </li>
402
+ </ol>
403
+ <p><strong>Please note:</strong> Our method usually only needs less than 1 second to reconstruct a scene, but the visualization of 3D points may take tens of seconds, especially when the number of images is large. Please be patient or, for faster visualization, use a local machine to run our demo from our <a href="https://github.com/facebookresearch/vggt">GitHub repository</a>.</p>
404
+ </div>
405
+ """
406
+ )
407
+
408
+ target_dir_output = gr.Textbox(label="Target Dir", visible=False, value="None")
409
+
410
+ with gr.Row():
411
+ with gr.Column(scale=2):
412
+ input_video = gr.Video(label="Upload Video", interactive=True)
413
+ input_images = gr.File(file_count="multiple", label="Upload Images", interactive=True)
414
+
415
+ image_gallery = gr.Gallery(
416
+ label="Preview",
417
+ columns=4,
418
+ height="300px",
419
+ show_download_button=True,
420
+ object_fit="contain",
421
+ preview=True,
422
+ )
423
+
424
+ with gr.Column(scale=4):
425
+ with gr.Column():
426
+ gr.Markdown("**3D Reconstruction (Point Cloud and Camera Poses)**")
427
+ log_output = gr.Markdown(
428
+ "Please upload a video or images, then click Reconstruct.", elem_classes=["custom-log"]
429
+ )
430
+ reconstruction_output = gr.Model3D(height=520, zoom_speed=0.5, pan_speed=0.5)
431
+
432
+ with gr.Row():
433
+ submit_btn = gr.Button("Reconstruct", scale=1, variant="primary")
434
+ clear_btn = gr.ClearButton(
435
+ [input_video, input_images, reconstruction_output, log_output, target_dir_output, image_gallery],
436
+ scale=1,
437
+ )
438
+
439
+ with gr.Row():
440
+ prediction_mode = gr.Radio(
441
+ ["Depthmap and Camera Branch", "Pointmap Branch"],
442
+ label="Select a Prediction Mode",
443
+ value="Depthmap and Camera Branch",
444
+ scale=1,
445
+ elem_id="my_radio",
446
+ )
447
+
448
+ with gr.Row():
449
+ conf_thres = gr.Slider(minimum=0, maximum=100, value=50, step=0.1, label="Confidence Threshold (%)")
450
+ frame_filter = gr.Dropdown(choices=["All"], value="All", label="Show Points from Frame")
451
+ with gr.Column():
452
+ show_cam = gr.Checkbox(label="Show Camera", value=True)
453
+ mask_sky = gr.Checkbox(label="Filter Sky", value=False)
454
+ mask_black_bg = gr.Checkbox(label="Filter Black Background", value=False)
455
+ mask_white_bg = gr.Checkbox(label="Filter White Background", value=False)
456
+
457
+ # ---------------------- Examples section ----------------------
458
+ examples = [
459
+ [colosseum_video, "22", None, 20.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
460
+ [pyramid_video, "30", None, 35.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
461
+ [single_cartoon_video, "1", None, 15.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
462
+ [single_oil_painting_video, "1", None, 20.0, False, True, True, True, "Depthmap and Camera Branch", "True"],
463
+ [canyon_video, "14", None, 40.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
464
+ [room_video, "8", None, 5.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
465
+ [kitchen_video, "25", None, 50.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
466
+ [fern_video, "20", None, 45.0, False, False, True, False, "Depthmap and Camera Branch", "True"],
467
+ ]
468
+
469
+ def example_pipeline(
470
+ input_video,
471
+ num_images_str,
472
+ input_images,
473
+ conf_thres,
474
+ mask_black_bg,
475
+ mask_white_bg,
476
+ show_cam,
477
+ mask_sky,
478
+ prediction_mode,
479
+ is_example_str,
480
+ ):
481
+ """
482
+ 1) Copy example images to new target_dir
483
+ 2) Reconstruct
484
+ 3) Return model3D + logs + new_dir + updated dropdown + gallery
485
+ We do NOT return is_example. It's just an input.
486
+ """
487
+ target_dir, image_paths = handle_uploads(input_video, input_images)
488
+ # Always use "All" for frame_filter in examples
489
+ frame_filter = "All"
490
+ glbfile, log_msg, dropdown = gradio_demo(
491
+ target_dir, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode
492
+ )
493
+ return glbfile, log_msg, target_dir, dropdown, image_paths
494
+
495
+ gr.Markdown("Click any row to load an example.", elem_classes=["example-log"])
496
+
497
+ gr.Examples(
498
+ examples=examples,
499
+ inputs=[
500
+ input_video,
501
+ num_images,
502
+ input_images,
503
+ conf_thres,
504
+ mask_black_bg,
505
+ mask_white_bg,
506
+ show_cam,
507
+ mask_sky,
508
+ prediction_mode,
509
+ is_example,
510
+ ],
511
+ outputs=[
512
+ reconstruction_output,
513
+ log_output,
514
+ target_dir_output,
515
+ frame_filter,
516
+ image_gallery,
517
+ ],
518
+ fn=example_pipeline,
519
+ cache_examples=False,
520
+ examples_per_page=50,
521
+ )
522
+
523
+ # -------------------------------------------------------------------------
524
+ # "Reconstruct" button logic:
525
+ # - Clear fields
526
+ # - Update log
527
+ # - gradio_demo(...) with the existing target_dir
528
+ # - Then set is_example = "False"
529
+ # -------------------------------------------------------------------------
530
+ submit_btn.click(fn=clear_fields, inputs=[], outputs=[reconstruction_output]).then(
531
+ fn=update_log, inputs=[], outputs=[log_output]
532
+ ).then(
533
+ fn=gradio_demo,
534
+ inputs=[target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode],
535
+ outputs=[reconstruction_output, log_output, frame_filter],
536
+ ).then(
537
+ fn=lambda: "False", inputs=[], outputs=[is_example] # set is_example to "False"
538
+ )
539
+
540
+ # -------------------------------------------------------------------------
541
+ # Real-time Visualization Updates
542
+ # -------------------------------------------------------------------------
543
+ conf_thres.change(
544
+ update_visualization,
545
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
546
+ [reconstruction_output, log_output],
547
+ )
548
+ frame_filter.change(
549
+ update_visualization,
550
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
551
+ [reconstruction_output, log_output],
552
+ )
553
+ mask_black_bg.change(
554
+ update_visualization,
555
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
556
+ [reconstruction_output, log_output],
557
+ )
558
+ mask_white_bg.change(
559
+ update_visualization,
560
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
561
+ [reconstruction_output, log_output],
562
+ )
563
+ show_cam.change(
564
+ update_visualization,
565
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
566
+ [reconstruction_output, log_output],
567
+ )
568
+ mask_sky.change(
569
+ update_visualization,
570
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
571
+ [reconstruction_output, log_output],
572
+ )
573
+ prediction_mode.change(
574
+ update_visualization,
575
+ [target_dir_output, conf_thres, frame_filter, mask_black_bg, mask_white_bg, show_cam, mask_sky, prediction_mode, is_example],
576
+ [reconstruction_output, log_output],
577
+ )
578
+
579
+ # -------------------------------------------------------------------------
580
+ # Auto-update gallery whenever user uploads or changes their files
581
+ # -------------------------------------------------------------------------
582
+ input_video.change(
583
+ fn=update_gallery_on_upload,
584
+ inputs=[input_video, input_images],
585
+ outputs=[reconstruction_output, target_dir_output, image_gallery, log_output],
586
+ )
587
+ input_images.change(
588
+ fn=update_gallery_on_upload,
589
+ inputs=[input_video, input_images],
590
+ outputs=[reconstruction_output, target_dir_output, image_gallery, log_output],
591
+ )
592
+
593
+ demo.queue(max_size=20).launch(show_error=True, share=True)
demo_viser.py ADDED
@@ -0,0 +1,506 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+ #
4
+ # This source code is licensed under the license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ import os
8
+ import glob
9
+ import time
10
+ import threading
11
+ import argparse
12
+ from typing import List, Optional
13
+ import copy
14
+
15
+ import numpy as np
16
+ import torch
17
+ from tqdm.auto import tqdm
18
+ import viser
19
+ import viser.transforms as viser_tf
20
+ import cv2
21
+ import requests
22
+ try:
23
+ import onnxruntime
24
+ except ImportError:
25
+ print("onnxruntime not found. Sky segmentation may not work.")
26
+
27
+ from vggt.models.vggt import VGGT
28
+ from vggt.utils.load_fn import load_and_preprocess_images
29
+ from vggt.utils.geometry import closed_form_inverse_se3, unproject_depth_map_to_point_map
30
+ from vggt.utils.pose_enc import pose_encoding_to_extri_intri
31
+
32
+ def viser_wrapper(
33
+ pred_dict: dict,
34
+ port: int = 8080,
35
+ init_conf_threshold: float = 50.0, # represents percentage (e.g., 50 means filter lowest 50%)
36
+ use_point_map: bool = False,
37
+ background_mode: bool = False,
38
+ mask_sky: bool = False,
39
+ image_folder: str = None,
40
+ ):
41
+ """
42
+ Visualize predicted 3D points and camera poses with viser.
43
+
44
+ Args:
45
+ pred_dict (dict):
46
+ {
47
+ "images": (S, 3, H, W) - Input images,
48
+ "world_points": (S, H, W, 3),
49
+ "world_points_conf": (S, H, W),
50
+ "depth": (S, H, W, 1),
51
+ "depth_conf": (S, H, W),
52
+ "extrinsic": (S, 3, 4),
53
+ "intrinsic": (S, 3, 3),
54
+ }
55
+ port (int): Port number for the viser server.
56
+ init_conf_threshold (float): Initial percentage of low-confidence points to filter out.
57
+ use_point_map (bool): Whether to visualize world_points or use depth-based points.
58
+ background_mode (bool): Whether to run the server in background thread.
59
+ mask_sky (bool): Whether to apply sky segmentation to filter out sky points.
60
+ image_folder (str): Path to the folder containing input images.
61
+ """
62
+ print(f"Starting viser server on port {port}")
63
+
64
+ server = viser.ViserServer(host="0.0.0.0", port=port)
65
+ server.gui.configure_theme(titlebar_content=None, control_layout="collapsible")
66
+
67
+ # Unpack prediction dict
68
+ images = pred_dict["images"] # (S, 3, H, W)
69
+ world_points_map = pred_dict["world_points"] # (S, H, W, 3)
70
+ conf_map = pred_dict["world_points_conf"] # (S, H, W)
71
+
72
+ depth_map = pred_dict["depth"] # (S, H, W, 1)
73
+ depth_conf = pred_dict["depth_conf"] # (S, H, W)
74
+
75
+ extrinsics_cam = pred_dict["extrinsic"] # (S, 3, 4)
76
+ intrinsics_cam = pred_dict["intrinsic"] # (S, 3, 3)
77
+
78
+ # Compute world points from depth if not using the precomputed point map
79
+ if not use_point_map:
80
+ world_points = unproject_depth_map_to_point_map(depth_map, extrinsics_cam, intrinsics_cam)
81
+ conf = depth_conf
82
+ else:
83
+ world_points = world_points_map
84
+ conf = conf_map
85
+
86
+ # Apply sky segmentation if enabled
87
+ if mask_sky and image_folder is not None:
88
+ conf = apply_sky_segmentation(conf, image_folder)
89
+
90
+ # Convert images from (S, 3, H, W) to (S, H, W, 3)
91
+ # Then flatten everything for the point cloud
92
+ colors = images.transpose(0, 2, 3, 1) # now (S, H, W, 3)
93
+ S, H, W, _ = world_points.shape
94
+
95
+ # Flatten
96
+ points = world_points.reshape(-1, 3)
97
+ colors_flat = (colors.reshape(-1, 3) * 255).astype(np.uint8)
98
+ conf = conf.reshape(-1)
99
+
100
+ cam_to_world_mat = closed_form_inverse_se3(extrinsics_cam) # shape (S, 4, 4) typically
101
+ # For convenience, we store only (3,4) portion
102
+ cam_to_world = cam_to_world_mat[:, :3, :]
103
+
104
+ # Compute scene center and recenter
105
+ scene_center = np.mean(points, axis=0)
106
+ points_centered = points - scene_center
107
+ cam_to_world[..., -1] -= scene_center
108
+
109
+ # Store frame indices so we can filter by frame
110
+ frame_indices = np.repeat(np.arange(S), H * W)
111
+
112
+ # Build the viser GUI
113
+ gui_show_frames = server.gui.add_checkbox(
114
+ "Show Cameras",
115
+ initial_value=True,
116
+ )
117
+
118
+ # Now the slider represents percentage of points to filter out
119
+ gui_points_conf = server.gui.add_slider(
120
+ "Confidence Percent",
121
+ min=0,
122
+ max=100,
123
+ step=0.1,
124
+ initial_value=init_conf_threshold,
125
+ )
126
+
127
+ gui_frame_selector = server.gui.add_dropdown(
128
+ "Show Points from Frames",
129
+ options=["All"] + [str(i) for i in range(S)],
130
+ initial_value="All",
131
+ )
132
+
133
+ # Create the main point cloud handle
134
+ # Compute the threshold value as the given percentile
135
+ init_threshold_val = np.percentile(conf, init_conf_threshold)
136
+ init_conf_mask = conf > init_threshold_val
137
+ point_cloud = server.scene.add_point_cloud(
138
+ name="viser_pcd",
139
+ points=points_centered[init_conf_mask],
140
+ colors=colors_flat[init_conf_mask],
141
+ # point_size=0.0001,
142
+ point_size=0.001,
143
+ point_shape="circle",
144
+ )
145
+
146
+ # We will store references to frames & frustums so we can toggle visibility
147
+ frames: List[viser.FrameHandle] = []
148
+ frustums: List[viser.CameraFrustumHandle] = []
149
+
150
+ def visualize_frames(extrinsics: np.ndarray, images_: np.ndarray) -> None:
151
+ """
152
+ Add camera frames and frustums to the scene.
153
+ extrinsics: (S, 3, 4)
154
+ images_: (S, 3, H, W)
155
+ """
156
+ # Clear any existing frames or frustums
157
+ for f in frames:
158
+ f.remove()
159
+ frames.clear()
160
+ for fr in frustums:
161
+ fr.remove()
162
+ frustums.clear()
163
+
164
+ # Optionally attach a callback that sets the viewpoint to the chosen camera
165
+ def attach_callback(frustum: viser.CameraFrustumHandle, frame: viser.FrameHandle) -> None:
166
+ @frustum.on_click
167
+ def _(_) -> None:
168
+ for client in server.get_clients().values():
169
+ client.camera.wxyz = frame.wxyz
170
+ client.camera.position = frame.position
171
+
172
+ img_ids = range(S)
173
+ for img_id in tqdm(img_ids):
174
+ cam2world_3x4 = extrinsics[img_id]
175
+ T_world_camera = viser_tf.SE3.from_matrix(cam2world_3x4)
176
+
177
+ # Add a small frame axis
178
+ frame_axis = server.scene.add_frame(
179
+ f"frame_{img_id}",
180
+ wxyz=T_world_camera.rotation().wxyz,
181
+ position=T_world_camera.translation(),
182
+ axes_length=0.05,
183
+ axes_radius=0.002,
184
+ origin_radius=0.002,
185
+ )
186
+ frames.append(frame_axis)
187
+
188
+ # Convert the image for the frustum
189
+ img = images_[img_id] # shape (3, H, W)
190
+ img = (img.transpose(1, 2, 0) * 255).astype(np.uint8)
191
+ h, w = img.shape[:2]
192
+
193
+ # If you want correct FOV from intrinsics, do something like:
194
+ # fx = intrinsics_cam[img_id, 0, 0]
195
+ # fov = 2 * np.arctan2(h/2, fx)
196
+ # For demonstration, we pick a simple approximate FOV:
197
+ fy = 1.1 * h
198
+ fov = 2 * np.arctan2(h / 2, fy)
199
+
200
+ # Add the frustum
201
+ frustum_cam = server.scene.add_camera_frustum(
202
+ f"frame_{img_id}/frustum",
203
+ fov=fov,
204
+ aspect=w / h,
205
+ scale=0.05,
206
+ image=img,
207
+ line_width=1.0,
208
+ )
209
+ frustums.append(frustum_cam)
210
+ attach_callback(frustum_cam, frame_axis)
211
+
212
+ def update_point_cloud() -> None:
213
+ """Update the point cloud based on current GUI selections."""
214
+ # Here we compute the threshold value based on the current percentage
215
+ current_percentage = gui_points_conf.value
216
+ threshold_val = np.percentile(conf, current_percentage)
217
+ conf_mask = conf > threshold_val
218
+
219
+ if gui_frame_selector.value == "All":
220
+ frame_mask = np.ones_like(conf_mask, dtype=bool)
221
+ else:
222
+ selected_idx = int(gui_frame_selector.value)
223
+ frame_mask = frame_indices == selected_idx
224
+
225
+ combined_mask = conf_mask & frame_mask
226
+ point_cloud.points = points_centered[combined_mask]
227
+ point_cloud.colors = colors_flat[combined_mask]
228
+
229
+ @gui_points_conf.on_update
230
+ def _(_) -> None:
231
+ update_point_cloud()
232
+
233
+ @gui_frame_selector.on_update
234
+ def _(_) -> None:
235
+ update_point_cloud()
236
+
237
+ @gui_show_frames.on_update
238
+ def _(_) -> None:
239
+ """Toggle visibility of camera frames and frustums."""
240
+ for f in frames:
241
+ f.visible = gui_show_frames.value
242
+ for fr in frustums:
243
+ fr.visible = gui_show_frames.value
244
+
245
+ # Add the camera frames to the scene
246
+ visualize_frames(cam_to_world, images)
247
+
248
+ print("Starting viser server...")
249
+ # If background_mode is True, spawn a daemon thread so the main thread can continue.
250
+ if background_mode:
251
+
252
+ def server_loop():
253
+ while True:
254
+ time.sleep(0.001)
255
+
256
+ thread = threading.Thread(target=server_loop, daemon=True)
257
+ thread.start()
258
+ else:
259
+ while True:
260
+ time.sleep(0.01)
261
+
262
+ return server
263
+
264
+
265
+ # Helper functions for sky segmentation
266
+
267
+ def download_file_from_url(url, filename):
268
+ """Downloads a file from a Hugging Face model repo, handling redirects."""
269
+ try:
270
+ # Get the redirect URL
271
+ response = requests.get(url, allow_redirects=False)
272
+ response.raise_for_status() # Raise HTTPError for bad requests (4xx or 5xx)
273
+
274
+ if response.status_code == 302: # Expecting a redirect
275
+ redirect_url = response.headers["Location"]
276
+ response = requests.get(redirect_url, stream=True)
277
+ response.raise_for_status()
278
+ else:
279
+ print(f"Unexpected status code: {response.status_code}")
280
+ return
281
+
282
+ with open(filename, "wb") as f:
283
+ for chunk in response.iter_content(chunk_size=8192):
284
+ f.write(chunk)
285
+ print(f"Downloaded {filename} successfully.")
286
+
287
+ except requests.exceptions.RequestException as e:
288
+ print(f"Error downloading file: {e}")
289
+
290
+
291
+
292
+ def apply_sky_segmentation(conf: np.ndarray, image_folder: str) -> np.ndarray:
293
+ """
294
+ Apply sky segmentation to confidence scores.
295
+
296
+ Args:
297
+ conf (np.ndarray): Confidence scores with shape (S, H, W)
298
+ image_folder (str): Path to the folder containing input images
299
+
300
+ Returns:
301
+ np.ndarray: Updated confidence scores with sky regions masked out
302
+ """
303
+ S, H, W = conf.shape
304
+ sky_masks_dir = image_folder.rstrip('/') + "_sky_masks"
305
+ os.makedirs(sky_masks_dir, exist_ok=True)
306
+
307
+ # Download skyseg.onnx if it doesn't exist
308
+ if not os.path.exists("skyseg.onnx"):
309
+ print("Downloading skyseg.onnx...")
310
+ download_file_from_url(
311
+ "https://huggingface.co/JianyuanWang/skyseg/resolve/main/skyseg.onnx", "skyseg.onnx"
312
+ )
313
+
314
+ skyseg_session = onnxruntime.InferenceSession("skyseg.onnx")
315
+ image_files = sorted(glob.glob(os.path.join(image_folder, "*")))
316
+ sky_mask_list = []
317
+
318
+ print("Generating sky masks...")
319
+ for i, image_path in enumerate(tqdm(image_files[:S])): # Limit to the number of images in the batch
320
+ image_name = os.path.basename(image_path)
321
+ mask_filepath = os.path.join(sky_masks_dir, image_name)
322
+
323
+ if os.path.exists(mask_filepath):
324
+ sky_mask = cv2.imread(mask_filepath, cv2.IMREAD_GRAYSCALE)
325
+ else:
326
+ sky_mask = segment_sky(image_path, skyseg_session, mask_filepath)
327
+
328
+ # Resize mask to match H×W if needed
329
+ if sky_mask.shape[0] != H or sky_mask.shape[1] != W:
330
+ sky_mask = cv2.resize(sky_mask, (W, H))
331
+
332
+ sky_mask_list.append(sky_mask)
333
+
334
+
335
+ # Convert list to numpy array with shape S×H×W
336
+ sky_mask_array = np.array(sky_mask_list)
337
+ # Apply sky mask to confidence scores
338
+ sky_mask_binary = (sky_mask_array > 0.01).astype(np.float32)
339
+ conf = conf * sky_mask_binary
340
+
341
+ print("Sky segmentation applied successfully")
342
+ return conf
343
+
344
+
345
+
346
+ def segment_sky(image_path, onnx_session, mask_filename=None):
347
+ """
348
+ Segments sky from an image using an ONNX model.
349
+
350
+ Args:
351
+ image_path: Path to input image
352
+ onnx_session: ONNX runtime session with loaded model
353
+ mask_filename: Path to save the output mask
354
+
355
+ Returns:
356
+ np.ndarray: Binary mask where 255 indicates non-sky regions
357
+ """
358
+ assert mask_filename is not None
359
+ image = cv2.imread(image_path)
360
+
361
+ result_map = run_skyseg(onnx_session, [320, 320], image)
362
+ # resize the result_map to the original image size
363
+ result_map_original = cv2.resize(result_map, (image.shape[1], image.shape[0]))
364
+
365
+ output_mask = np.zeros_like(result_map_original)
366
+ output_mask[result_map_original < 1] = 1
367
+ output_mask = output_mask.astype(np.uint8) * 255
368
+ os.makedirs(os.path.dirname(mask_filename), exist_ok=True)
369
+ cv2.imwrite(mask_filename, output_mask)
370
+ return output_mask
371
+
372
+
373
+ def run_skyseg(onnx_session, input_size, image):
374
+ """
375
+ Runs sky segmentation inference using ONNX model.
376
+
377
+ Args:
378
+ onnx_session: ONNX runtime session
379
+ input_size: Target size for model input (width, height)
380
+ image: Input image in BGR format
381
+
382
+ Returns:
383
+ np.ndarray: Segmentation mask
384
+ """
385
+ # Pre process:Resize, BGR->RGB, Transpose, PyTorch standardization, float32 cast
386
+ temp_image = copy.deepcopy(image)
387
+ resize_image = cv2.resize(temp_image, dsize=(input_size[0], input_size[1]))
388
+ x = cv2.cvtColor(resize_image, cv2.COLOR_BGR2RGB)
389
+ x = np.array(x, dtype=np.float32)
390
+ mean = [0.485, 0.456, 0.406]
391
+ std = [0.229, 0.224, 0.225]
392
+ x = (x / 255 - mean) / std
393
+ x = x.transpose(2, 0, 1)
394
+ x = x.reshape(-1, 3, input_size[0], input_size[1]).astype("float32")
395
+
396
+ # Inference
397
+ input_name = onnx_session.get_inputs()[0].name
398
+ output_name = onnx_session.get_outputs()[0].name
399
+ onnx_result = onnx_session.run([output_name], {input_name: x})
400
+
401
+ # Post process
402
+ onnx_result = np.array(onnx_result).squeeze()
403
+ min_value = np.min(onnx_result)
404
+ max_value = np.max(onnx_result)
405
+ onnx_result = (onnx_result - min_value) / (max_value - min_value)
406
+ onnx_result *= 255
407
+ onnx_result = onnx_result.astype("uint8")
408
+
409
+ return onnx_result
410
+
411
+
412
+
413
+
414
+
415
+
416
+ parser = argparse.ArgumentParser(description="VGGT demo with viser for 3D visualization")
417
+ parser.add_argument(
418
+ "--image_folder", type=str, default="examples/kitchen/images/", help="Path to folder containing images"
419
+ )
420
+ parser.add_argument("--use_point_map", action="store_true", help="Use point map instead of depth-based points")
421
+ parser.add_argument("--background_mode", action="store_true", help="Run the viser server in background mode")
422
+ parser.add_argument("--port", type=int, default=8080, help="Port number for the viser server")
423
+ parser.add_argument(
424
+ "--conf_threshold", type=float, default=25.0, help="Initial percentage of low-confidence points to filter out"
425
+ )
426
+ parser.add_argument("--mask_sky", action="store_true", help="Apply sky segmentation to filter out sky points")
427
+
428
+
429
+ def main():
430
+ """
431
+ Main function for the VGGT demo with viser for 3D visualization.
432
+
433
+ This function:
434
+ 1. Loads the VGGT model
435
+ 2. Processes input images from the specified folder
436
+ 3. Runs inference to generate 3D points and camera poses
437
+ 4. Optionally applies sky segmentation to filter out sky points
438
+ 5. Visualizes the results using viser
439
+
440
+ Command-line arguments:
441
+ --image_folder: Path to folder containing input images
442
+ --use_point_map: Use point map instead of depth-based points
443
+ --background_mode: Run the viser server in background mode
444
+ --port: Port number for the viser server
445
+ --conf_threshold: Initial percentage of low-confidence points to filter out
446
+ --mask_sky: Apply sky segmentation to filter out sky points
447
+ """
448
+ args = parser.parse_args()
449
+ device = "cuda" if torch.cuda.is_available() else "cpu"
450
+ print(f"Using device: {device}")
451
+
452
+ print("Initializing and loading VGGT model...")
453
+ model = VGGT()
454
+ _URL = "https://huggingface.co/facebook/VGGT-1B/resolve/main/model.pt"
455
+ model.load_state_dict(torch.hub.load_state_dict_from_url(_URL))
456
+
457
+ model.eval()
458
+ model = model.to(device)
459
+
460
+ # Use the provided image folder path
461
+ print(f"Loading images from {args.image_folder}...")
462
+ image_names = glob.glob(os.path.join(args.image_folder, "*"))
463
+ print(f"Found {len(image_names)} images")
464
+
465
+ images = load_and_preprocess_images(image_names).to(device)
466
+ print(f"Preprocessed images shape: {images.shape}")
467
+
468
+ print("Running inference...")
469
+ with torch.no_grad():
470
+ with torch.cuda.amp.autocast(dtype=torch.bfloat16):
471
+ predictions = model(images)
472
+
473
+ print("Converting pose encoding to extrinsic and intrinsic matrices...")
474
+ extrinsic, intrinsic = pose_encoding_to_extri_intri(predictions["pose_enc"], images.shape[-2:])
475
+ predictions["extrinsic"] = extrinsic
476
+ predictions["intrinsic"] = intrinsic
477
+
478
+ print("Processing model outputs...")
479
+ for key in predictions.keys():
480
+ if isinstance(predictions[key], torch.Tensor):
481
+ predictions[key] = predictions[key].cpu().numpy().squeeze(0) # remove batch dimension and convert to numpy
482
+
483
+ if args.use_point_map:
484
+ print("Visualizing 3D points from point map")
485
+ else:
486
+ print("Visualizing 3D points by unprojecting depth map by cameras")
487
+
488
+ if args.mask_sky:
489
+ print("Sky segmentation enabled - will filter out sky points")
490
+
491
+ print("Starting viser visualization...")
492
+
493
+ viser_server = viser_wrapper(
494
+ predictions,
495
+ port=args.port,
496
+ init_conf_threshold=args.conf_threshold,
497
+ use_point_map=args.use_point_map,
498
+ background_mode=args.background_mode,
499
+ mask_sky=args.mask_sky,
500
+ image_folder=args.image_folder,
501
+ )
502
+ print("Visualization complete")
503
+
504
+
505
+ if __name__ == "__main__":
506
+ main()
examples/kitchen/images/00.png ADDED

Git LFS Details

  • SHA256: 54527a575988094058cdc1975b421c48e0f446726473d0ac21ea55ecb24e96a7
  • Pointer size: 131 Bytes
  • Size of remote file: 691 kB
examples/kitchen/images/01.png ADDED

Git LFS Details

  • SHA256: 0ad4c6d74c16661ed427f8100124aaf53e7fd0577b32c362f13559dfad7027a7
  • Pointer size: 131 Bytes
  • Size of remote file: 726 kB
examples/kitchen/images/02.png ADDED

Git LFS Details

  • SHA256: 596bd54d26f889fc80cedee81d95dda709fa134d86ac199b6509337e413246d5
  • Pointer size: 131 Bytes
  • Size of remote file: 789 kB
examples/kitchen/images/03.png ADDED

Git LFS Details

  • SHA256: 78193756310d9abaf81fa28902cf0b284260a0a916b085a7c08a4723eead1dd6
  • Pointer size: 131 Bytes
  • Size of remote file: 828 kB
examples/kitchen/images/04.png ADDED

Git LFS Details

  • SHA256: ca551254002a318228e19e46982813f3e489828796e98547ff632043f3002f9d
  • Pointer size: 131 Bytes
  • Size of remote file: 724 kB
examples/kitchen/images/05.png ADDED

Git LFS Details

  • SHA256: a8dcd116d782d32b404d7e4aa69f462abbd048a0d8727440ec37f18cc4548ee4
  • Pointer size: 131 Bytes
  • Size of remote file: 759 kB
examples/kitchen/images/06.png ADDED

Git LFS Details

  • SHA256: 2fcc2b871c6fef6f3a3e0f06a3ffc1f0eee3e40afa2461f7c7c665057decb3e6
  • Pointer size: 131 Bytes
  • Size of remote file: 674 kB
examples/kitchen/images/07.png ADDED

Git LFS Details

  • SHA256: 28d21898de0e6370790839a40f7f45d84fbb3e6ff5809f0a0e14bd01bdef730e
  • Pointer size: 131 Bytes
  • Size of remote file: 856 kB
examples/kitchen/images/08.png ADDED

Git LFS Details

  • SHA256: 0137a2bb3eb3e691d8d8b1f8884a9c8f99748888b1db770091d7acdf35fe8efa
  • Pointer size: 131 Bytes
  • Size of remote file: 677 kB
examples/kitchen/images/09.png ADDED

Git LFS Details

  • SHA256: 1ab59c1ef85d8169b404463f01b7ae4d287da12677126b68a3dce407ca2b9077
  • Pointer size: 131 Bytes
  • Size of remote file: 797 kB
examples/kitchen/images/10.png ADDED

Git LFS Details

  • SHA256: f180cbf110bc65b89ad616328ad7d076dc3901a18def4b1337a134cdf65233a0
  • Pointer size: 131 Bytes
  • Size of remote file: 730 kB
examples/kitchen/images/11.png ADDED

Git LFS Details

  • SHA256: 781196eadae8d907928e877e073289c0998e2b9e513d4f7580e147d15d1ae571
  • Pointer size: 131 Bytes
  • Size of remote file: 799 kB
examples/kitchen/images/12.png ADDED

Git LFS Details

  • SHA256: dd59b24dc8962ba0fc7fbb37b53a6d76fec9730c74e7e3235a06902b250e7d44
  • Pointer size: 131 Bytes
  • Size of remote file: 707 kB
examples/kitchen/images/13.png ADDED

Git LFS Details

  • SHA256: b4cd39f22c766477bad741ff37a1ee5f71aecde8bb6762d869b4c9dca1ceacfb
  • Pointer size: 131 Bytes
  • Size of remote file: 755 kB
examples/kitchen/images/14.png ADDED

Git LFS Details

  • SHA256: 5df1f398efc144271e342d7b65447e022a100b93b3850a755fbc66aff5fca0f2
  • Pointer size: 131 Bytes
  • Size of remote file: 642 kB
examples/kitchen/images/15.png ADDED

Git LFS Details

  • SHA256: 325262829ddb11d1c7df1a8f1fef79a297332dad51870ab0d40a73f1dd6869b1
  • Pointer size: 131 Bytes
  • Size of remote file: 639 kB
examples/kitchen/images/16.png ADDED

Git LFS Details

  • SHA256: 9779a78d72fc25f2118a270f060afeacbcef149a4f012119ff041effa8727cbf
  • Pointer size: 131 Bytes
  • Size of remote file: 754 kB
examples/kitchen/images/17.png ADDED

Git LFS Details

  • SHA256: 2549f4f505ea021eebe0bf579b969b6c162d2dee18b0c8e9d7a3c043d200e45b
  • Pointer size: 131 Bytes
  • Size of remote file: 774 kB
examples/kitchen/images/18.png ADDED

Git LFS Details

  • SHA256: e1c21131c4732756d5774dd732af86c1d39dea96fd2d613afd570633b3a76ef6
  • Pointer size: 131 Bytes
  • Size of remote file: 829 kB
examples/kitchen/images/19.png ADDED

Git LFS Details

  • SHA256: d17680e77c6cb326eb4604e29f9e532db34769ca20b938e944ab53e8bd3798e2
  • Pointer size: 131 Bytes
  • Size of remote file: 678 kB
examples/kitchen/images/20.png ADDED

Git LFS Details

  • SHA256: 5e9c835a0e0c1bc162a8bff6b93677c58cb53afaadca260b0ca2a388565b4cc2
  • Pointer size: 131 Bytes
  • Size of remote file: 718 kB
examples/kitchen/images/21.png ADDED

Git LFS Details

  • SHA256: 0747b2d1b44ef538a9aa40a067881ef9d3ed5cacbf954c926a2bdf5f29c114e6
  • Pointer size: 131 Bytes
  • Size of remote file: 787 kB
examples/kitchen/images/22.png ADDED

Git LFS Details

  • SHA256: 77a0014d7c7d5802ce23cda4e102759274fd8f4c150271a3b61cbb2fe33b69b6
  • Pointer size: 131 Bytes
  • Size of remote file: 675 kB
examples/kitchen/images/23.png ADDED

Git LFS Details

  • SHA256: 1a9415e9b8f08ff298829ffac779bb1e8dedccb3bf36060d59a7da2a35c4f790
  • Pointer size: 131 Bytes
  • Size of remote file: 652 kB
examples/kitchen/images/24.png ADDED

Git LFS Details

  • SHA256: 5199003307466bf4706a0898f139bf3590946f255d08c6b11d5aa9eede54c83a
  • Pointer size: 131 Bytes
  • Size of remote file: 800 kB
examples/llff_fern/images/000.png ADDED

Git LFS Details

  • SHA256: 47f447d31a84d53494045087cbb8a40b877a68a76f549af14f6bb6f490a5b05d
  • Pointer size: 131 Bytes
  • Size of remote file: 671 kB
examples/llff_fern/images/001.png ADDED

Git LFS Details

  • SHA256: 05402df1d7247e794768461571c188737dcae5fcb34400990f5751244a3e41c0
  • Pointer size: 131 Bytes
  • Size of remote file: 666 kB
examples/llff_fern/images/002.png ADDED

Git LFS Details

  • SHA256: e17135aa9b506fac24a9529ee56c37ef5a52c55498998d3de64cf3e46210dccc
  • Pointer size: 131 Bytes
  • Size of remote file: 652 kB
examples/llff_fern/images/003.png ADDED

Git LFS Details

  • SHA256: 3285c7cc6b4b75703a68f510072c5eca81cff9b983044426cbe2ca27d4e526c5
  • Pointer size: 131 Bytes
  • Size of remote file: 653 kB
examples/llff_fern/images/004.png ADDED

Git LFS Details

  • SHA256: 9976282206f9aff0fc3eaa3daa182ba93e0c6734c69bdf31f40989641b4f8fea
  • Pointer size: 131 Bytes
  • Size of remote file: 609 kB
examples/llff_fern/images/005.png ADDED

Git LFS Details

  • SHA256: e7ce2bcabcd2b2972c505e2649eb0f5b9efb30adcd455d93f5014370d53f2653
  • Pointer size: 131 Bytes
  • Size of remote file: 633 kB
examples/llff_fern/images/006.png ADDED

Git LFS Details

  • SHA256: 57dfa176d28662655adda9c0c04d6949424ddb3c702f533ddb332543dd1dcbdb
  • Pointer size: 131 Bytes
  • Size of remote file: 634 kB
examples/llff_fern/images/007.png ADDED

Git LFS Details

  • SHA256: da42e3dd198bc0951591b2a5e41bb15fbff18c2aef194d17a6acbf128487749e
  • Pointer size: 131 Bytes
  • Size of remote file: 632 kB
examples/llff_fern/images/008.png ADDED

Git LFS Details

  • SHA256: a8b8ac9860697b9cb1bfe41b358b03aef7a97ecb2fa9af61bc6e11210d99e8be
  • Pointer size: 131 Bytes
  • Size of remote file: 633 kB
examples/llff_fern/images/009.png ADDED

Git LFS Details

  • SHA256: beb825c8fee0b21801bca59ddddf65e560bd87fdc6823ec733cb8e6be05002c9
  • Pointer size: 131 Bytes
  • Size of remote file: 640 kB
examples/llff_fern/images/010.png ADDED

Git LFS Details

  • SHA256: 390054ae2969ce5ed0e8ed9b9c0501c527028b565e18807e0acd5d62a4627dae
  • Pointer size: 131 Bytes
  • Size of remote file: 637 kB
examples/llff_fern/images/011.png ADDED

Git LFS Details

  • SHA256: a3875f648038011549183d4c6a273be3d75e868e7f4971b474089121acbf8d52
  • Pointer size: 131 Bytes
  • Size of remote file: 618 kB
examples/llff_fern/images/012.png ADDED

Git LFS Details

  • SHA256: e003aa530890edaf01a34701e0a83f21d90d41e36e80b91dc5aba9a055a72063
  • Pointer size: 131 Bytes
  • Size of remote file: 647 kB
examples/llff_fern/images/013.png ADDED

Git LFS Details

  • SHA256: c4c393c28985d237c9152b7e053dbd06257904f6415696a8d710c038d9c45885
  • Pointer size: 131 Bytes
  • Size of remote file: 650 kB
examples/llff_fern/images/014.png ADDED

Git LFS Details

  • SHA256: d8e538e8b96199689a92a718d23890f4bd726ceb15e4e649298545c5b038cdbf
  • Pointer size: 131 Bytes
  • Size of remote file: 640 kB