├── .gitignore
├── LICENSE
├── README.md
├── notebooks
├── README.md
├── imgs
│ ├── cover.png
│ ├── gradio_app.png
│ ├── infer-results.png
│ ├── neb.jpg
│ ├── neb_x_gradio.png
│ ├── output-stable-diffusion.png
│ ├── sd-benchmarks.png
│ ├── sd-cover.png
│ ├── speedster-results.png
│ ├── speedsterdoc.png
│ ├── stab1.jpg
│ ├── stab2.jpg
│ ├── thanos.png
│ ├── tome-arch.png
│ ├── tome-impl.png
│ ├── tome-results.png
│ ├── tome.png
│ ├── tomeintro.png
│ └── total-results.png
└── notebooks
│ ├── stable-diffusion.ipynb
│ └── token-merging.ipynb
└── notes
├── README.md
└── files
└── MIT6.S965
└── Lecture_02.pdf
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | 
3 |
30 |
31 | ## Hey there and welcome! 🌈
32 | This repository is a collection of learning resources, which includes two folders: the [`notes`](https://github.com/nebuly-ai/learning-hub/tree/main/notes) folder consisting of handwritten notes from courses or reading papers, and the [`notebooks`](https://github.com/mfumanelli/learning-hub/tree/main/notebooks) folder providing notebooks to experiment with the latest techniques or utilize Nebuly tools.
33 |
34 | This is still a work in progress, and we welcome any contributions. Let's keep learning!
35 |
--------------------------------------------------------------------------------
/notebooks/README.md:
--------------------------------------------------------------------------------
1 |
2 | 
3 |
4 |
32 |
33 | ## 🚀 Hi!
34 | In this repository we collect notebooks with examples, analysis, and use cases focused on artificial intelligence optimization. The repository is still under construction 👷♀️
35 |
36 | ### Use Cases
37 |
38 | | **notebook** | **open in colab or kaggle** | **supplementary materials** | **references** |
39 | |:------------:|:------------------------------------:|:----------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------:|
40 | | [Accelerate Stable Diffusion Model Using Speedster + New TensorRT 8.6 Release and Gradio App Creation](https://github.com/nebuly-ai/learning-hub/blob/main/notebooks/notebooks/stable-diffusion.ipynb) | [](https://colab.research.google.com/drive/1ihtoUeJ3fLpEuh4_njfohw7hs0lXXaMV?usp=sharing) | | |
41 | | [Token Merging (ToMe) - Meta AI's New Optimization Technique to Make ViT Faster by 2x. But Can ViT be Even Faster?](https://github.com/nebuly-ai/learning-hub/blob/main/notebooks/notebooks/token-merging.ipynb) | [](https://colab.research.google.com/drive/1dd8JENS8HudfPz_cA-Mc5oN90nYJUBND?usp=sharing) [](https://www.kaggle.com/code/serquet/token-merging-your-vit-but-faster) |[Blog post](https://www.nebuly.com/blog/token-merging-tome-meta-ais-new-optimization-technique-to-make-vit-faster)| [](https://github.com/facebookresearch/ToMe) |
42 |
43 | ### Speedster Quickstarts
44 | | **notebook** | **description** | **open in colab** |
45 | |:------------:|:------------:|:------------:|
46 | |[Accelerate Diffusers Stable Diffusion](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/diffusers/Accelerate_Stable_Diffusion_with_Speedster.ipynb)|Show how to optimize with Speedster the Stable Diffusion models from Diffusers.| [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/diffusers/Accelerate_Stable_Diffusion_with_Speedster.ipynb) |
47 | | [Accelerate Hugging Face PyTorch GPT2](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_PyTorch_GPT2_with_Speedster.ipynb) | Show how to optimize with Speedster the GPT2 model from Hugging Face with PyTorch backend. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_PyTorch_GPT2_with_Speedster.ipynb) |
48 | |[Accelerate PyTorch ViT](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_PyTorch_ViT_with_Speedster.ipynb) | Show how to optimize with Speedster a PyTorch ViT model. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_PyTorch_ViT_with_Speedster.ipynb)|
49 | | [Accelerate Hugging Face PyTorch BERT](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_PyTorch_BERT_with_Speedster.ipynb) | Show how to optimize with Speedster the BERT model from Hugging Face with PyTorch backend. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_PyTorch_BERT_with_Speedster.ipynb) |
50 | | [Accelerate Hugging Face PyTorch DistilBERT](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_PyTorch_DistilBERT_with_Speedster.ipynb) | Show how to optimize with Speedster the DistilBERT model from Hugging Face with PyTorch backend. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_PyTorch_DistilBERT_with_Speedster.ipynb) | |
51 | | [Accelerate Hugging Face TensorFlow BERT](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_TensorFlow_BERT_with_Speedster.ipynb) | Show how to optimize with Speedster the BERT model from Hugging Face with TensorFlow backend. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_TensorFlow_BERT_with_Speedster.ipynb) |
52 | | [Accelerate Hugging Face PyTorch T5](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_PyTorch_T5_with_Speedster.ipynb) | Show how to optimize with Speedster the T5 model from Hugging Face with PyTorch backend. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/huggingface/Accelerate_Hugging_Face_PyTorch_T5_with_Speedster.ipynb) |
53 | | [Accelerate ONNX Resnet50](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/onnx/Accelerate_ONNX_ResNet50_with_Speedster.ipynb) | Show how to optimize with Speedster a Resnet50 model in ONNX format. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/onnx/Accelerate_ONNX_ResNet50_with_Speedster.ipynb) |
54 | | [Accelerate Torchvision Resnet50](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_PyTorch_ResNet50_with_Speedster.ipynb) | Show how to optimize with Speedster a Resnet50 model loaded from Torchvision. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_PyTorch_ResNet50_with_Speedster.ipynb) |
55 | | [Accelerate Fast AI Resnet34](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_fast_ai_Resnet34_with_Speedster.ipynb) | Show how to optimize with Speedster a Resnet34 model loaded from Fast AI. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_fast_ai_Resnet34_with_Speedster.ipynb) |
56 | | [Accelerate Ultralytics YOLOv5](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_PyTorch_YOLOv5_with_Speedster.ipynb) | Show how to optimize with Speedster a YOLOv5 model from Ultralytics. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_PyTorch_YOLOv5_with_Speedster.ipynb) |
57 | | [Accelerate Ultralytics YOLOv8](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_PyTorch_YOLOv8_with_Speedster.ipynb) | Show how to optimize with Speedster a YOLOv8 model from Ultralytics. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/pytorch/Accelerate_PyTorch_YOLOv8_with_Speedster.ipynb) |
58 | | [Accelerate Keras Resnet50](https://github.com/nebuly-ai/nebullvm/blob/main/notebooks/speedster/tensorflow/Accelerate_Tensorflow_ResNet50_with_Speedster.ipynb) | Show how to optimize with Speedster a Resnet50 model loaded from keras. | [](https://colab.research.google.com/github/nebuly-ai/nebullvm/blob/main/notebooks/speedster/tensorflow/Accelerate_Tensorflow_ResNet50_with_Speedster.ipynb) |
59 |
--------------------------------------------------------------------------------
/notebooks/imgs/cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/cover.png
--------------------------------------------------------------------------------
/notebooks/imgs/gradio_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/gradio_app.png
--------------------------------------------------------------------------------
/notebooks/imgs/infer-results.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/infer-results.png
--------------------------------------------------------------------------------
/notebooks/imgs/neb.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/neb.jpg
--------------------------------------------------------------------------------
/notebooks/imgs/neb_x_gradio.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/neb_x_gradio.png
--------------------------------------------------------------------------------
/notebooks/imgs/output-stable-diffusion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/output-stable-diffusion.png
--------------------------------------------------------------------------------
/notebooks/imgs/sd-benchmarks.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/sd-benchmarks.png
--------------------------------------------------------------------------------
/notebooks/imgs/sd-cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/sd-cover.png
--------------------------------------------------------------------------------
/notebooks/imgs/speedster-results.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/speedster-results.png
--------------------------------------------------------------------------------
/notebooks/imgs/speedsterdoc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/speedsterdoc.png
--------------------------------------------------------------------------------
/notebooks/imgs/stab1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/stab1.jpg
--------------------------------------------------------------------------------
/notebooks/imgs/stab2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/stab2.jpg
--------------------------------------------------------------------------------
/notebooks/imgs/thanos.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/thanos.png
--------------------------------------------------------------------------------
/notebooks/imgs/tome-arch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/tome-arch.png
--------------------------------------------------------------------------------
/notebooks/imgs/tome-impl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/tome-impl.png
--------------------------------------------------------------------------------
/notebooks/imgs/tome-results.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/tome-results.png
--------------------------------------------------------------------------------
/notebooks/imgs/tome.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/tome.png
--------------------------------------------------------------------------------
/notebooks/imgs/tomeintro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/tomeintro.png
--------------------------------------------------------------------------------
/notebooks/imgs/total-results.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notebooks/imgs/total-results.png
--------------------------------------------------------------------------------
/notebooks/notebooks/stable-diffusion.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "cells": [
3 | {
4 | "cell_type": "markdown",
5 | "id": "b8e4382d",
6 | "metadata": {},
7 | "source": [
8 | ""
9 | ]
10 | },
11 | {
12 | "cell_type": "markdown",
13 | "id": "36df534b",
14 | "metadata": {},
15 | "source": [
16 | "# Accelerate Stable Diffusion Model Using Speedster + New TensorRT 8.6 Release and Gradio App Creation"
17 | ]
18 | },
19 | {
20 | "cell_type": "markdown",
21 | "id": "618b51be-63e5-4fc3-bfc1-70dd947cd79a",
22 | "metadata": {},
23 | "source": [
24 | "#### 🚀 Welcome to this notebook focused on optimizing Stable Diffusion using Speedster 🚀\n",
25 | "\n",
26 | "### Goal\n",
27 | "The goal is to optimize the performance of a Stable Diffusion model using Speedster and the latest TensorRT version, to obtain an inference model that runs ~2-3 times faster than the original one. After that, we will show you how easy it is to integrate an optimized model in a Gradio application, so we will develop a game using Gradio and the accelerated model. The game we create will be called *guess the Pokémon*, the user will have to identify the name of the Pokémon generated using the optimized Stable Diffusion model."
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "id": "8f3ca852-9e20-440c-a073-029ad0baf663",
33 | "metadata": {},
34 | "source": [
35 | "\n",
36 | "
Results obtained on a 3090Ti GPU for the Stable Diffusion 2.1 model.
"
37 | ]
38 | },
39 | {
40 | "cell_type": "markdown",
41 | "id": "6bd4102f",
42 | "metadata": {},
43 | "source": [
44 | "### Stable Diffusion"
45 | ]
46 | },
47 | {
48 | "cell_type": "markdown",
49 | "id": "562dced5",
50 | "metadata": {},
51 | "source": [
52 | "Stable Diffusion, which was released in 2022, is a text-to-image model that is mainly utilized for generating images based on textual descriptions.\n",
53 | "\n",
54 | "Stable Diffusion consists of three main components: \n",
55 | "* **a text-understanding component** that uses a Transformer language model to translate text into a numeric representation\n",
56 | "* **an image generator** that includes an image information creator and an image decoder \n",
57 | "* **an autoencoder decoder** that produces the final image\n",
58 | "\n",
59 | "The image generator works in the latent space and gradually processes the information to generate high-quality images, with the UNet neural network and scheduling algorithm as its components. The image decoder uses the processed information array to produce the final pixel image. Speedster's main focus for model acceleration is the conditional U-Net architecture utilized for denoising the latent component of the encoded image. The reason for this emphasis is that UNet is executed multiple times based on the num_inference_steps hyperparameter, which is usually set to 50 by default. As a result, the computational cost of UNet far outweighs the impact of the other two model components, which are only executed once."
60 | ]
61 | },
62 | {
63 | "cell_type": "markdown",
64 | "id": "87325a48-409c-4ec1-aa8a-67ffb75ae716",
65 | "metadata": {},
66 | "source": [
67 | "
Image taken from The Illustrated Stable Diffusion blog by Jay Alammar.
"
92 | ]
93 | },
94 | {
95 | "cell_type": "markdown",
96 | "id": "8b088504",
97 | "metadata": {},
98 | "source": [
99 | "### Speedster"
100 | ]
101 | },
102 | {
103 | "cell_type": "markdown",
104 | "id": "7758a909-fdda-40d0-947a-9da41ab8ffce",
105 | "metadata": {},
106 | "source": [
107 | "Nebuly's [Speedster](https://github.com/nebuly-ai/nebullvm/tree/main/apps/accelerate/speedster) is an **open-source** module that enables fast AI inference through just a few lines of code. The module automatically applies state-of-the-art optimization techniques to maximize the hardware's physical inference speed-up, including latency, throughput, and model size on a single machine.\n",
108 | "\n",
109 | "To get started, you can refer to the [getting started guide](https://github.com/nebuly-ai/nebullvm/tree/main/apps/accelerate/speedster) for five different input model frameworks supported by Speedster, which are PyTorch, Hugging Face Transformers, Hugging Face Diffusers, TensorFlow/Keras, and ONNX.\n",
110 | "\n",
111 | "In this notebook, we will delve into the details of Stable Diffusion and the Speedster algorithm. We will learn how to implement Speedster in Python and use it to optimize Stable Diffusion.\n",
112 | "\n",
113 | "In addition to optimization techniques, we will also create a Gradio application to interact with our accelerated model."
114 | ]
115 | },
116 | {
117 | "cell_type": "markdown",
118 | "id": "10752f50-4f7f-452b-ab07-e5eaba2fa5b7",
119 | "metadata": {},
120 | "source": [
121 | "
\n",
987 | " Stable Diffusion is a state-of-the-art text-to-image model that generates images from text, \n",
988 | " in this demo it is used to generate Pokèmon from their description.
\n",
989 | " \n",
990 | " \n",
991 | "
\n",
992 | " Instructions: press the \"Generate a Pokémon!\" button to generate an image and try to see if you can guess the movie.\n",
993 | " You can see if you guessed right by pressing the \"Tell me the name\" button.\n",
994 | "
\n",
995 | " \n",
996 | " NOTE: If a completely black image is generated, it means that the NSFW checker has blocked the display of the output.\n",
997 | "
\n",
998 | " \"\"\"\n",
999 | " )\n",
1000 | " with gr.Group():\n",
1001 | " with gr.Box():\n",
1002 | " with gr.Row().style(mobile_collapse=False, equal_height=True):\n",
1003 | " b1 = gr.Button(\"Generate a Pokémon\")\n",
1004 | " b2 = gr.Button(\"Tell me the name\")\n",
1005 | " text = gr.Textbox(label=\"Name:\")\n",
1006 | " image = gr.Image(\n",
1007 | " label=\"Generated images\", show_label=False, elem_id=\"image\"\n",
1008 | " ).style(height=\"auto\")\n",
1009 | "\n",
1010 | " seed = gr.Number(visible=False)\n",
1011 | "\n",
1012 | " b1.click(generate_pokemon, inputs=None, outputs=[image, seed])\n",
1013 | " b2.click(pokemon_name, inputs=seed, outputs=text)\n",
1014 | "\n",
1015 | "demo.launch(share=False)"
1016 | ]
1017 | },
1018 | {
1019 | "cell_type": "markdown",
1020 | "id": "48bd3be9-c1dc-42f0-bc6f-1ca9d1f9d8c7",
1021 | "metadata": {},
1022 | "source": [
1023 | ""
1024 | ]
1025 | },
1026 | {
1027 | "cell_type": "markdown",
1028 | "id": "cdd69a59-a5ac-4b98-b658-aac14917fe13",
1029 | "metadata": {},
1030 | "source": [
1031 | "## Conclusions"
1032 | ]
1033 | },
1034 | {
1035 | "cell_type": "markdown",
1036 | "id": "f4a21ded-8aa7-4dfb-a460-315bec08b4d6",
1037 | "metadata": {},
1038 | "source": [
1039 | "And here we are, Let's summarize what we saw in this notebook:\n",
1040 | "* Stable Diffusion is a text-to-image model mainly used to generate images based on textual descriptions\n",
1041 | "* Accelerating this model with Speedster is very simple and fast\n",
1042 | "* Speedster also integrates the latest version of TensorRT for 🚀🚀🚀🚀 performance and ease of use\n",
1043 | "* Using Speedster we achieve 2x faster model latency\n",
1044 | "* Using a Speedster-optimized model within a Gradio application is straightforward, as we showed in our example with the **guess the Pokémon** application\n",
1045 | "\n",
1046 | "We hope this notebook will be useful to you, also you can find many more speedster use cases in [this repository](https://github.com/nebuly-ai/learning-hub/notebooks).\n",
1047 | "\n",
1048 | "Remember to join our [Discord community](https://discord.com/invite/RbeQMu886J) and if you are interested in AI optimization or if you liked this notebook please leave a star at our repo [Speedster](https://github.com/nebuly-ai/nebullvm/tree/main/apps/accelerate/speedster) 💕🌟!"
1049 | ]
1050 | },
1051 | {
1052 | "cell_type": "markdown",
1053 | "id": "27de5970-a8cc-4f04-a3d6-6d273252f84d",
1054 | "metadata": {},
1055 | "source": [
1056 | ""
1057 | ]
1058 | },
1059 | {
1060 | "cell_type": "code",
1061 | "execution_count": null,
1062 | "id": "7e4c72f5-5a9b-4bd5-838c-72971348a131",
1063 | "metadata": {},
1064 | "outputs": [],
1065 | "source": []
1066 | }
1067 | ],
1068 | "metadata": {
1069 | "kernelspec": {
1070 | "display_name": "Python 3 (ipykernel)",
1071 | "language": "python",
1072 | "name": "python3"
1073 | },
1074 | "language_info": {
1075 | "codemirror_mode": {
1076 | "name": "ipython",
1077 | "version": 3
1078 | },
1079 | "file_extension": ".py",
1080 | "mimetype": "text/x-python",
1081 | "name": "python",
1082 | "nbconvert_exporter": "python",
1083 | "pygments_lexer": "ipython3",
1084 | "version": "3.9.13"
1085 | }
1086 | },
1087 | "nbformat": 4,
1088 | "nbformat_minor": 5
1089 | }
1090 |
--------------------------------------------------------------------------------
/notes/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
31 |
32 | ## ❤️ Hi!
33 | In this repository, you can find notes on various topics including AI, optimization, and others, which have been taken from lectures, videos, or articles. The repository is still under construction 👷♀️ and we welcome contributions in all forms!
34 |
35 |
36 | | **topic** | **notes** | **references** |
37 | |:------------:|:------------:|:--------------:|
38 | |Basics of Neural Networks|[MIT 6.S965 Lecture 02](https://github.com/nebuly-ai/learning-hub/blob/main/notes/files/MIT6.S965/Lecture_02.pdf) | [](https://www.youtube.com/watch?v=5HpLyZd1h0Q)|
39 |
--------------------------------------------------------------------------------
/notes/files/MIT6.S965/Lecture_02.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nebuly-ai/learning-hub/b5d5a2392466bb21d3c38cad524f236bc83e5d41/notes/files/MIT6.S965/Lecture_02.pdf
--------------------------------------------------------------------------------