Spaces:
Build error
Build error
Remove unnecessary files and clean up code
Browse files- CITATION.cff +0 -17
- LICENSE +0 -2
- LICENSE.apache-2.0 +0 -201
- LICENSE.cc-by-nc-sa-4.0 +0 -437
- README.md +2 -30
- app.py +7 -5
- configs/dalle-1.3B.yaml +0 -33
- configs/transfer-imagenet-clscond-gen.yaml +0 -49
- configs/transfer-imagenet-uncond-gen.yaml +0 -48
- dalle_last.ckpt +0 -3
- examples/sampling_ex.py +0 -63
- examples/sampling_interactive_demo.ipynb +0 -298
- examples/transfer_learning_ex.py +0 -172
- last.ckpt +0 -3
- server.py +1 -11
CITATION.cff
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
cff-version: 1.2.0
|
| 2 |
-
message: "If you find this repository useful in your research, please cite"
|
| 3 |
-
authors:
|
| 4 |
-
- family-names: Kim
|
| 5 |
-
given-names: Saehoon
|
| 6 |
-
- family-names: Cho
|
| 7 |
-
given-names: Sanghun
|
| 8 |
-
- family-names: Kim
|
| 9 |
-
given-names: Chiheon
|
| 10 |
-
- family-names: Lee
|
| 11 |
-
given-names: Doyup
|
| 12 |
-
- family-names: Baek
|
| 13 |
-
given-names: Woonhyuk
|
| 14 |
-
title: "minDALL-E on Conceptual Captions"
|
| 15 |
-
version: 0.1
|
| 16 |
-
date-released: 2021-12-14
|
| 17 |
-
repository-code: https://github.com/kakaobrain/minDALL-E
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LICENSE
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
The `source codes` are licensed under [Apache 2.0](LICENSE.apache-2.0) License.
|
| 2 |
-
The `stage2 pretrained weights` are licensed under [CC-BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) License.
|
|
|
|
|
|
|
|
|
LICENSE.apache-2.0
DELETED
|
@@ -1,201 +0,0 @@
|
|
| 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 [2021.11.13] [Kakao Brain]
|
| 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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LICENSE.cc-by-nc-sa-4.0
DELETED
|
@@ -1,437 +0,0 @@
|
|
| 1 |
-
Attribution-NonCommercial-ShareAlike 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-ShareAlike 4.0 International
|
| 58 |
-
Public 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-ShareAlike 4.0 International Public License
|
| 63 |
-
("Public License"). To the extent this Public License may be
|
| 64 |
-
interpreted as a contract, You are granted the Licensed Rights in
|
| 65 |
-
consideration of Your acceptance of these terms and conditions, and the
|
| 66 |
-
Licensor grants You such rights in consideration of benefits the
|
| 67 |
-
Licensor receives from making the Licensed Material available under
|
| 68 |
-
these terms and conditions.
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
Section 1 -- Definitions.
|
| 72 |
-
|
| 73 |
-
a. Adapted Material means material subject to Copyright and Similar
|
| 74 |
-
Rights that is derived from or based upon the Licensed Material
|
| 75 |
-
and in which the Licensed Material is translated, altered,
|
| 76 |
-
arranged, transformed, or otherwise modified in a manner requiring
|
| 77 |
-
permission under the Copyright and Similar Rights held by the
|
| 78 |
-
Licensor. For purposes of this Public License, where the Licensed
|
| 79 |
-
Material is a musical work, performance, or sound recording,
|
| 80 |
-
Adapted Material is always produced where the Licensed Material is
|
| 81 |
-
synched in timed relation with a moving image.
|
| 82 |
-
|
| 83 |
-
b. Adapter's License means the license You apply to Your Copyright
|
| 84 |
-
and Similar Rights in Your contributions to Adapted Material in
|
| 85 |
-
accordance with the terms and conditions of this Public License.
|
| 86 |
-
|
| 87 |
-
c. BY-NC-SA Compatible License means a license listed at
|
| 88 |
-
creativecommons.org/compatiblelicenses, approved by Creative
|
| 89 |
-
Commons as essentially the equivalent of this Public License.
|
| 90 |
-
|
| 91 |
-
d. Copyright and Similar Rights means copyright and/or similar rights
|
| 92 |
-
closely related to copyright including, without limitation,
|
| 93 |
-
performance, broadcast, sound recording, and Sui Generis Database
|
| 94 |
-
Rights, without regard to how the rights are labeled or
|
| 95 |
-
categorized. For purposes of this Public License, the rights
|
| 96 |
-
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
| 97 |
-
Rights.
|
| 98 |
-
|
| 99 |
-
e. Effective Technological Measures means those measures that, in the
|
| 100 |
-
absence of proper authority, may not be circumvented under laws
|
| 101 |
-
fulfilling obligations under Article 11 of the WIPO Copyright
|
| 102 |
-
Treaty adopted on December 20, 1996, and/or similar international
|
| 103 |
-
agreements.
|
| 104 |
-
|
| 105 |
-
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
| 106 |
-
any other exception or limitation to Copyright and Similar Rights
|
| 107 |
-
that applies to Your use of the Licensed Material.
|
| 108 |
-
|
| 109 |
-
g. License Elements means the license attributes listed in the name
|
| 110 |
-
of a Creative Commons Public License. The License Elements of this
|
| 111 |
-
Public License are Attribution, NonCommercial, and ShareAlike.
|
| 112 |
-
|
| 113 |
-
h. Licensed Material means the artistic or literary work, database,
|
| 114 |
-
or other material to which the Licensor applied this Public
|
| 115 |
-
License.
|
| 116 |
-
|
| 117 |
-
i. Licensed Rights means the rights granted to You subject to the
|
| 118 |
-
terms and conditions of this Public License, which are limited to
|
| 119 |
-
all Copyright and Similar Rights that apply to Your use of the
|
| 120 |
-
Licensed Material and that the Licensor has authority to license.
|
| 121 |
-
|
| 122 |
-
j. Licensor means the individual(s) or entity(ies) granting rights
|
| 123 |
-
under this Public License.
|
| 124 |
-
|
| 125 |
-
k. NonCommercial means not primarily intended for or directed towards
|
| 126 |
-
commercial advantage or monetary compensation. For purposes of
|
| 127 |
-
this Public License, the exchange of the Licensed Material for
|
| 128 |
-
other material subject to Copyright and Similar Rights by digital
|
| 129 |
-
file-sharing or similar means is NonCommercial provided there is
|
| 130 |
-
no payment of monetary compensation in connection with the
|
| 131 |
-
exchange.
|
| 132 |
-
|
| 133 |
-
l. Share means to provide material to the public by any means or
|
| 134 |
-
process that requires permission under the Licensed Rights, such
|
| 135 |
-
as reproduction, public display, public performance, distribution,
|
| 136 |
-
dissemination, communication, or importation, and to make material
|
| 137 |
-
available to the public including in ways that members of the
|
| 138 |
-
public may access the material from a place and at a time
|
| 139 |
-
individually chosen by them.
|
| 140 |
-
|
| 141 |
-
m. Sui Generis Database Rights means rights other than copyright
|
| 142 |
-
resulting from Directive 96/9/EC of the European Parliament and of
|
| 143 |
-
the Council of 11 March 1996 on the legal protection of databases,
|
| 144 |
-
as amended and/or succeeded, as well as other essentially
|
| 145 |
-
equivalent rights anywhere in the world.
|
| 146 |
-
|
| 147 |
-
n. You means the individual or entity exercising the Licensed Rights
|
| 148 |
-
under this Public License. Your has a corresponding meaning.
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
Section 2 -- Scope.
|
| 152 |
-
|
| 153 |
-
a. License grant.
|
| 154 |
-
|
| 155 |
-
1. Subject to the terms and conditions of this Public License,
|
| 156 |
-
the Licensor hereby grants You a worldwide, royalty-free,
|
| 157 |
-
non-sublicensable, non-exclusive, irrevocable license to
|
| 158 |
-
exercise the Licensed Rights in the Licensed Material to:
|
| 159 |
-
|
| 160 |
-
a. reproduce and Share the Licensed Material, in whole or
|
| 161 |
-
in part, for NonCommercial purposes only; and
|
| 162 |
-
|
| 163 |
-
b. produce, reproduce, and Share Adapted Material for
|
| 164 |
-
NonCommercial purposes only.
|
| 165 |
-
|
| 166 |
-
2. Exceptions and Limitations. For the avoidance of doubt, where
|
| 167 |
-
Exceptions and Limitations apply to Your use, this Public
|
| 168 |
-
License does not apply, and You do not need to comply with
|
| 169 |
-
its terms and conditions.
|
| 170 |
-
|
| 171 |
-
3. Term. The term of this Public License is specified in Section
|
| 172 |
-
6(a).
|
| 173 |
-
|
| 174 |
-
4. Media and formats; technical modifications allowed. The
|
| 175 |
-
Licensor authorizes You to exercise the Licensed Rights in
|
| 176 |
-
all media and formats whether now known or hereafter created,
|
| 177 |
-
and to make technical modifications necessary to do so. The
|
| 178 |
-
Licensor waives and/or agrees not to assert any right or
|
| 179 |
-
authority to forbid You from making technical modifications
|
| 180 |
-
necessary to exercise the Licensed Rights, including
|
| 181 |
-
technical modifications necessary to circumvent Effective
|
| 182 |
-
Technological Measures. For purposes of this Public License,
|
| 183 |
-
simply making modifications authorized by this Section 2(a)
|
| 184 |
-
(4) never produces Adapted Material.
|
| 185 |
-
|
| 186 |
-
5. Downstream recipients.
|
| 187 |
-
|
| 188 |
-
a. Offer from the Licensor -- Licensed Material. Every
|
| 189 |
-
recipient of the Licensed Material automatically
|
| 190 |
-
receives an offer from the Licensor to exercise the
|
| 191 |
-
Licensed Rights under the terms and conditions of this
|
| 192 |
-
Public License.
|
| 193 |
-
|
| 194 |
-
b. Additional offer from the Licensor -- Adapted Material.
|
| 195 |
-
Every recipient of Adapted Material from You
|
| 196 |
-
automatically receives an offer from the Licensor to
|
| 197 |
-
exercise the Licensed Rights in the Adapted Material
|
| 198 |
-
under the conditions of the Adapter's License You apply.
|
| 199 |
-
|
| 200 |
-
c. No downstream restrictions. You may not offer or impose
|
| 201 |
-
any additional or different terms or conditions on, or
|
| 202 |
-
apply any Effective Technological Measures to, the
|
| 203 |
-
Licensed Material if doing so restricts exercise of the
|
| 204 |
-
Licensed Rights by any recipient of the Licensed
|
| 205 |
-
Material.
|
| 206 |
-
|
| 207 |
-
6. No endorsement. Nothing in this Public License constitutes or
|
| 208 |
-
may be construed as permission to assert or imply that You
|
| 209 |
-
are, or that Your use of the Licensed Material is, connected
|
| 210 |
-
with, or sponsored, endorsed, or granted official status by,
|
| 211 |
-
the Licensor or others designated to receive attribution as
|
| 212 |
-
provided in Section 3(a)(1)(A)(i).
|
| 213 |
-
|
| 214 |
-
b. Other rights.
|
| 215 |
-
|
| 216 |
-
1. Moral rights, such as the right of integrity, are not
|
| 217 |
-
licensed under this Public License, nor are publicity,
|
| 218 |
-
privacy, and/or other similar personality rights; however, to
|
| 219 |
-
the extent possible, the Licensor waives and/or agrees not to
|
| 220 |
-
assert any such rights held by the Licensor to the limited
|
| 221 |
-
extent necessary to allow You to exercise the Licensed
|
| 222 |
-
Rights, but not otherwise.
|
| 223 |
-
|
| 224 |
-
2. Patent and trademark rights are not licensed under this
|
| 225 |
-
Public License.
|
| 226 |
-
|
| 227 |
-
3. To the extent possible, the Licensor waives any right to
|
| 228 |
-
collect royalties from You for the exercise of the Licensed
|
| 229 |
-
Rights, whether directly or through a collecting society
|
| 230 |
-
under any voluntary or waivable statutory or compulsory
|
| 231 |
-
licensing scheme. In all other cases the Licensor expressly
|
| 232 |
-
reserves any right to collect such royalties, including when
|
| 233 |
-
the Licensed Material is used other than for NonCommercial
|
| 234 |
-
purposes.
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
Section 3 -- License Conditions.
|
| 238 |
-
|
| 239 |
-
Your exercise of the Licensed Rights is expressly made subject to the
|
| 240 |
-
following conditions.
|
| 241 |
-
|
| 242 |
-
a. Attribution.
|
| 243 |
-
|
| 244 |
-
1. If You Share the Licensed Material (including in modified
|
| 245 |
-
form), You must:
|
| 246 |
-
|
| 247 |
-
a. retain the following if it is supplied by the Licensor
|
| 248 |
-
with the Licensed Material:
|
| 249 |
-
|
| 250 |
-
i. identification of the creator(s) of the Licensed
|
| 251 |
-
Material and any others designated to receive
|
| 252 |
-
attribution, in any reasonable manner requested by
|
| 253 |
-
the Licensor (including by pseudonym if
|
| 254 |
-
designated);
|
| 255 |
-
|
| 256 |
-
ii. a copyright notice;
|
| 257 |
-
|
| 258 |
-
iii. a notice that refers to this Public License;
|
| 259 |
-
|
| 260 |
-
iv. a notice that refers to the disclaimer of
|
| 261 |
-
warranties;
|
| 262 |
-
|
| 263 |
-
v. a URI or hyperlink to the Licensed Material to the
|
| 264 |
-
extent reasonably practicable;
|
| 265 |
-
|
| 266 |
-
b. indicate if You modified the Licensed Material and
|
| 267 |
-
retain an indication of any previous modifications; and
|
| 268 |
-
|
| 269 |
-
c. indicate the Licensed Material is licensed under this
|
| 270 |
-
Public License, and include the text of, or the URI or
|
| 271 |
-
hyperlink to, this Public License.
|
| 272 |
-
|
| 273 |
-
2. You may satisfy the conditions in Section 3(a)(1) in any
|
| 274 |
-
reasonable manner based on the medium, means, and context in
|
| 275 |
-
which You Share the Licensed Material. For example, it may be
|
| 276 |
-
reasonable to satisfy the conditions by providing a URI or
|
| 277 |
-
hyperlink to a resource that includes the required
|
| 278 |
-
information.
|
| 279 |
-
3. If requested by the Licensor, You must remove any of the
|
| 280 |
-
information required by Section 3(a)(1)(A) to the extent
|
| 281 |
-
reasonably practicable.
|
| 282 |
-
|
| 283 |
-
b. ShareAlike.
|
| 284 |
-
|
| 285 |
-
In addition to the conditions in Section 3(a), if You Share
|
| 286 |
-
Adapted Material You produce, the following conditions also apply.
|
| 287 |
-
|
| 288 |
-
1. The Adapter's License You apply must be a Creative Commons
|
| 289 |
-
license with the same License Elements, this version or
|
| 290 |
-
later, or a BY-NC-SA Compatible License.
|
| 291 |
-
|
| 292 |
-
2. You must include the text of, or the URI or hyperlink to, the
|
| 293 |
-
Adapter's License You apply. You may satisfy this condition
|
| 294 |
-
in any reasonable manner based on the medium, means, and
|
| 295 |
-
context in which You Share Adapted Material.
|
| 296 |
-
|
| 297 |
-
3. You may not offer or impose any additional or different terms
|
| 298 |
-
or conditions on, or apply any Effective Technological
|
| 299 |
-
Measures to, Adapted Material that restrict exercise of the
|
| 300 |
-
rights granted under the Adapter's License You apply.
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
Section 4 -- Sui Generis Database Rights.
|
| 304 |
-
|
| 305 |
-
Where the Licensed Rights include Sui Generis Database Rights that
|
| 306 |
-
apply to Your use of the Licensed Material:
|
| 307 |
-
|
| 308 |
-
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
| 309 |
-
to extract, reuse, reproduce, and Share all or a substantial
|
| 310 |
-
portion of the contents of the database for NonCommercial purposes
|
| 311 |
-
only;
|
| 312 |
-
|
| 313 |
-
b. if You include all or a substantial portion of the database
|
| 314 |
-
contents in a database in which You have Sui Generis Database
|
| 315 |
-
Rights, then the database in which You have Sui Generis Database
|
| 316 |
-
Rights (but not its individual contents) is Adapted Material,
|
| 317 |
-
including for purposes of Section 3(b); and
|
| 318 |
-
|
| 319 |
-
c. You must comply with the conditions in Section 3(a) if You Share
|
| 320 |
-
all or a substantial portion of the contents of the database.
|
| 321 |
-
|
| 322 |
-
For the avoidance of doubt, this Section 4 supplements and does not
|
| 323 |
-
replace Your obligations under this Public License where the Licensed
|
| 324 |
-
Rights include other Copyright and Similar Rights.
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
| 328 |
-
|
| 329 |
-
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
| 330 |
-
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
| 331 |
-
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
| 332 |
-
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
| 333 |
-
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
| 334 |
-
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
| 335 |
-
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
| 336 |
-
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
| 337 |
-
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
| 338 |
-
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
| 339 |
-
|
| 340 |
-
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
| 341 |
-
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
| 342 |
-
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
| 343 |
-
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
| 344 |
-
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
| 345 |
-
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
| 346 |
-
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
| 347 |
-
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
| 348 |
-
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
| 349 |
-
|
| 350 |
-
c. The disclaimer of warranties and limitation of liability provided
|
| 351 |
-
above shall be interpreted in a manner that, to the extent
|
| 352 |
-
possible, most closely approximates an absolute disclaimer and
|
| 353 |
-
waiver of all liability.
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
Section 6 -- Term and Termination.
|
| 357 |
-
|
| 358 |
-
a. This Public License applies for the term of the Copyright and
|
| 359 |
-
Similar Rights licensed here. However, if You fail to comply with
|
| 360 |
-
this Public License, then Your rights under this Public License
|
| 361 |
-
terminate automatically.
|
| 362 |
-
|
| 363 |
-
b. Where Your right to use the Licensed Material has terminated under
|
| 364 |
-
Section 6(a), it reinstates:
|
| 365 |
-
|
| 366 |
-
1. automatically as of the date the violation is cured, provided
|
| 367 |
-
it is cured within 30 days of Your discovery of the
|
| 368 |
-
violation; or
|
| 369 |
-
|
| 370 |
-
2. upon express reinstatement by the Licensor.
|
| 371 |
-
|
| 372 |
-
For the avoidance of doubt, this Section 6(b) does not affect any
|
| 373 |
-
right the Licensor may have to seek remedies for Your violations
|
| 374 |
-
of this Public License.
|
| 375 |
-
|
| 376 |
-
c. For the avoidance of doubt, the Licensor may also offer the
|
| 377 |
-
Licensed Material under separate terms or conditions or stop
|
| 378 |
-
distributing the Licensed Material at any time; however, doing so
|
| 379 |
-
will not terminate this Public License.
|
| 380 |
-
|
| 381 |
-
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
| 382 |
-
License.
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
Section 7 -- Other Terms and Conditions.
|
| 386 |
-
|
| 387 |
-
a. The Licensor shall not be bound by any additional or different
|
| 388 |
-
terms or conditions communicated by You unless expressly agreed.
|
| 389 |
-
|
| 390 |
-
b. Any arrangements, understandings, or agreements regarding the
|
| 391 |
-
Licensed Material not stated herein are separate from and
|
| 392 |
-
independent of the terms and conditions of this Public License.
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
Section 8 -- Interpretation.
|
| 396 |
-
|
| 397 |
-
a. For the avoidance of doubt, this Public License does not, and
|
| 398 |
-
shall not be interpreted to, reduce, limit, restrict, or impose
|
| 399 |
-
conditions on any use of the Licensed Material that could lawfully
|
| 400 |
-
be made without permission under this Public License.
|
| 401 |
-
|
| 402 |
-
b. To the extent possible, if any provision of this Public License is
|
| 403 |
-
deemed unenforceable, it shall be automatically reformed to the
|
| 404 |
-
minimum extent necessary to make it enforceable. If the provision
|
| 405 |
-
cannot be reformed, it shall be severed from this Public License
|
| 406 |
-
without affecting the enforceability of the remaining terms and
|
| 407 |
-
conditions.
|
| 408 |
-
|
| 409 |
-
c. No term or condition of this Public License will be waived and no
|
| 410 |
-
failure to comply consented to unless expressly agreed to by the
|
| 411 |
-
Licensor.
|
| 412 |
-
|
| 413 |
-
d. Nothing in this Public License constitutes or may be interpreted
|
| 414 |
-
as a limitation upon, or waiver of, any privileges and immunities
|
| 415 |
-
that apply to the Licensor or You, including from the legal
|
| 416 |
-
processes of any jurisdiction or authority.
|
| 417 |
-
|
| 418 |
-
=======================================================================
|
| 419 |
-
|
| 420 |
-
Creative Commons is not a party to its public
|
| 421 |
-
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
| 422 |
-
its public licenses to material it publishes and in those instances
|
| 423 |
-
will be considered the “Licensor.” The text of the Creative Commons
|
| 424 |
-
public licenses is dedicated to the public domain under the CC0 Public
|
| 425 |
-
Domain Dedication. Except for the limited purpose of indicating that
|
| 426 |
-
material is shared under a Creative Commons public license or as
|
| 427 |
-
otherwise permitted by the Creative Commons policies published at
|
| 428 |
-
creativecommons.org/policies, Creative Commons does not authorize the
|
| 429 |
-
use of the trademark "Creative Commons" or any other trademark or logo
|
| 430 |
-
of Creative Commons without its prior written consent including,
|
| 431 |
-
without limitation, in connection with any unauthorized modifications
|
| 432 |
-
to any of its public licenses or any other arrangements,
|
| 433 |
-
understandings, or agreements concerning use of licensed material. For
|
| 434 |
-
the avoidance of doubt, this paragraph does not form part of the
|
| 435 |
-
public licenses.
|
| 436 |
-
|
| 437 |
-
Creative Commons may be contacted at creativecommons.org.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -1,37 +1,9 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: 🔥
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: streamlit
|
| 7 |
app_file: app.py
|
| 8 |
pinned: false
|
| 9 |
-
---
|
| 10 |
-
|
| 11 |
-
# Configuration
|
| 12 |
-
|
| 13 |
-
`title`: _string_
|
| 14 |
-
Display title for the Space
|
| 15 |
-
|
| 16 |
-
`emoji`: _string_
|
| 17 |
-
Space emoji (emoji-only character allowed)
|
| 18 |
-
|
| 19 |
-
`colorFrom`: _string_
|
| 20 |
-
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
|
| 21 |
-
|
| 22 |
-
`colorTo`: _string_
|
| 23 |
-
Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
|
| 24 |
-
|
| 25 |
-
`sdk`: _string_
|
| 26 |
-
Can be either `gradio` or `streamlit`
|
| 27 |
-
|
| 28 |
-
`sdk_version` : _string_
|
| 29 |
-
Only applicable for `streamlit` SDK.
|
| 30 |
-
See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
|
| 31 |
-
|
| 32 |
-
`app_file`: _string_
|
| 33 |
-
Path to your main application file (which contains either `gradio` or `streamlit` Python code).
|
| 34 |
-
Path is relative to the root of the repository.
|
| 35 |
-
|
| 36 |
-
`pinned`: _boolean_
|
| 37 |
-
Whether the Space stays on top of your list.
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Logo Generator
|
| 3 |
emoji: 🔥
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: yellow
|
| 6 |
sdk: streamlit
|
| 7 |
app_file: app.py
|
| 8 |
pinned: false
|
| 9 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
import base64
|
| 2 |
import os
|
| 3 |
import time
|
|
@@ -47,14 +49,14 @@ if "models_loaded" not in st.session_state:
|
|
| 47 |
st.session_state["models_loaded"] = False
|
| 48 |
|
| 49 |
|
| 50 |
-
st.header("
|
| 51 |
#st.subheader("Generate images from text")
|
| 52 |
-
st.write("Generate
|
| 53 |
|
| 54 |
if not st.session_state["models_loaded"]:
|
| 55 |
load_models()
|
| 56 |
|
| 57 |
-
prompt = st.text_input("
|
| 58 |
|
| 59 |
DEBUG = False
|
| 60 |
# UI code taken from https://huggingface.co/spaces/flax-community/dalle-mini/blob/main/app/streamlit/app.py
|
|
@@ -91,6 +93,6 @@ if prompt != "":
|
|
| 91 |
cols[(i % n_columns) * 2].image(img)
|
| 92 |
container.markdown(f"**{prompt}**")
|
| 93 |
|
| 94 |
-
st.button("
|
| 95 |
|
| 96 |
-
|
|
|
|
| 1 |
+
""" Code inspired by https://huggingface.co/spaces/flax-community/dalle-mini
|
| 2 |
+
"""
|
| 3 |
import base64
|
| 4 |
import os
|
| 5 |
import time
|
|
|
|
| 49 |
st.session_state["models_loaded"] = False
|
| 50 |
|
| 51 |
|
| 52 |
+
st.header("Logo generator")
|
| 53 |
#st.subheader("Generate images from text")
|
| 54 |
+
st.write("Generate logos from text")
|
| 55 |
|
| 56 |
if not st.session_state["models_loaded"]:
|
| 57 |
load_models()
|
| 58 |
|
| 59 |
+
prompt = st.text_input("Text prompt to generate logo for:")
|
| 60 |
|
| 61 |
DEBUG = False
|
| 62 |
# UI code taken from https://huggingface.co/spaces/flax-community/dalle-mini/blob/main/app/streamlit/app.py
|
|
|
|
| 93 |
cols[(i % n_columns) * 2].image(img)
|
| 94 |
container.markdown(f"**{prompt}**")
|
| 95 |
|
| 96 |
+
st.button("Run again", key="again_button")
|
| 97 |
|
| 98 |
+
|
configs/dalle-1.3B.yaml
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
stage1:
|
| 2 |
-
type: vqgan
|
| 3 |
-
embed_dim: 256
|
| 4 |
-
n_embed: 16384
|
| 5 |
-
hparams:
|
| 6 |
-
double_z: False
|
| 7 |
-
z_channels: 256
|
| 8 |
-
resolution: 256
|
| 9 |
-
in_channels: 3
|
| 10 |
-
out_ch: 3
|
| 11 |
-
ch: 128
|
| 12 |
-
ch_mult: [1, 1, 2, 2, 4]
|
| 13 |
-
num_res_blocks: 2
|
| 14 |
-
attn_resolutions: [16]
|
| 15 |
-
pdrop: 0.0
|
| 16 |
-
|
| 17 |
-
stage2:
|
| 18 |
-
type: transformer1d
|
| 19 |
-
vocab_size_txt: 16384
|
| 20 |
-
vocab_size_img: 16384
|
| 21 |
-
hparams:
|
| 22 |
-
embed_dim: 1536
|
| 23 |
-
n_layers: 42
|
| 24 |
-
n_heads: 24
|
| 25 |
-
n_dense_layers: 42
|
| 26 |
-
ctx_len_img: 256
|
| 27 |
-
ctx_len_txt: 64
|
| 28 |
-
embd_pdrop: 0.0
|
| 29 |
-
resid_pdrop: 0.0
|
| 30 |
-
attn_pdrop: 0.0
|
| 31 |
-
mlp_bias: True
|
| 32 |
-
attn_bias: True
|
| 33 |
-
gelu_use_approx: False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
configs/transfer-imagenet-clscond-gen.yaml
DELETED
|
@@ -1,49 +0,0 @@
|
|
| 1 |
-
dataset:
|
| 2 |
-
dataset: imagenet
|
| 3 |
-
image_resolution: 256
|
| 4 |
-
|
| 5 |
-
stage1:
|
| 6 |
-
type: vqgan
|
| 7 |
-
embed_dim: 256
|
| 8 |
-
n_embed: 16384
|
| 9 |
-
hparams:
|
| 10 |
-
double_z: False
|
| 11 |
-
z_channels: 256
|
| 12 |
-
resolution: 256
|
| 13 |
-
in_channels: 3
|
| 14 |
-
out_ch: 3
|
| 15 |
-
ch: 128
|
| 16 |
-
ch_mult: [1, 1, 2, 2, 4]
|
| 17 |
-
num_res_blocks: 2
|
| 18 |
-
attn_resolutions: [16]
|
| 19 |
-
pdrop: 0.0
|
| 20 |
-
|
| 21 |
-
stage2:
|
| 22 |
-
type: igpt
|
| 23 |
-
use_cls_cond: True
|
| 24 |
-
vocab_size_img: 16384
|
| 25 |
-
hparams:
|
| 26 |
-
embed_dim: 1536
|
| 27 |
-
n_layers: 42
|
| 28 |
-
n_heads: 24
|
| 29 |
-
n_dense_layers: 42
|
| 30 |
-
ctx_len_img: 256
|
| 31 |
-
embd_pdrop: 0.0
|
| 32 |
-
resid_pdrop: 0.0
|
| 33 |
-
attn_pdrop: 0.0
|
| 34 |
-
mlp_bias: True
|
| 35 |
-
attn_bias: True
|
| 36 |
-
gelu_use_approx: False
|
| 37 |
-
n_classes: 1000
|
| 38 |
-
|
| 39 |
-
optimizer:
|
| 40 |
-
opt_type: adamW
|
| 41 |
-
base_lr: 1e-4
|
| 42 |
-
weight_decay: 0.0
|
| 43 |
-
betas: [0.9, 0.95]
|
| 44 |
-
grad_clip_norm: 4.0
|
| 45 |
-
|
| 46 |
-
experiment:
|
| 47 |
-
local_batch_size: 2
|
| 48 |
-
total_batch_size: 512
|
| 49 |
-
epochs: 8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
configs/transfer-imagenet-uncond-gen.yaml
DELETED
|
@@ -1,48 +0,0 @@
|
|
| 1 |
-
dataset:
|
| 2 |
-
dataset: imagenet
|
| 3 |
-
image_resolution: 256
|
| 4 |
-
|
| 5 |
-
stage1:
|
| 6 |
-
type: vqgan
|
| 7 |
-
embed_dim: 256
|
| 8 |
-
n_embed: 16384
|
| 9 |
-
hparams:
|
| 10 |
-
double_z: False
|
| 11 |
-
z_channels: 256
|
| 12 |
-
resolution: 256
|
| 13 |
-
in_channels: 3
|
| 14 |
-
out_ch: 3
|
| 15 |
-
ch: 128
|
| 16 |
-
ch_mult: [1, 1, 2, 2, 4]
|
| 17 |
-
num_res_blocks: 2
|
| 18 |
-
attn_resolutions: [16]
|
| 19 |
-
pdrop: 0.0
|
| 20 |
-
|
| 21 |
-
stage2:
|
| 22 |
-
type: igpt
|
| 23 |
-
use_cls_cond: False
|
| 24 |
-
vocab_size_img: 16384
|
| 25 |
-
hparams:
|
| 26 |
-
embed_dim: 1536
|
| 27 |
-
n_layers: 42
|
| 28 |
-
n_heads: 24
|
| 29 |
-
n_dense_layers: 42
|
| 30 |
-
ctx_len_img: 256
|
| 31 |
-
embd_pdrop: 0.0
|
| 32 |
-
resid_pdrop: 0.0
|
| 33 |
-
attn_pdrop: 0.0
|
| 34 |
-
mlp_bias: True
|
| 35 |
-
attn_bias: True
|
| 36 |
-
gelu_use_approx: False
|
| 37 |
-
|
| 38 |
-
optimizer:
|
| 39 |
-
opt_type: adamW
|
| 40 |
-
base_lr: 1e-4
|
| 41 |
-
weight_decay: 0.0
|
| 42 |
-
betas: [0.9, 0.95]
|
| 43 |
-
grad_clip_norm: 4.0
|
| 44 |
-
|
| 45 |
-
experiment:
|
| 46 |
-
local_batch_size: 2
|
| 47 |
-
total_batch_size: 512
|
| 48 |
-
epochs: 8
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dalle_last.ckpt
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:227f1eb47f5be797bd6c38ff69fa881a669fe177d978f42e572833fb29e6371e
|
| 3 |
-
size 5165951423
|
|
|
|
|
|
|
|
|
|
|
|
examples/sampling_ex.py
DELETED
|
@@ -1,63 +0,0 @@
|
|
| 1 |
-
# ------------------------------------------------------------------------------------
|
| 2 |
-
# Minimal DALL-E
|
| 3 |
-
# Copyright (c) 2021 KakaoBrain. All Rights Reserved.
|
| 4 |
-
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
|
| 5 |
-
# ------------------------------------------------------------------------------------
|
| 6 |
-
|
| 7 |
-
import os
|
| 8 |
-
import sys
|
| 9 |
-
import argparse
|
| 10 |
-
import clip
|
| 11 |
-
import numpy as np
|
| 12 |
-
from PIL import Image
|
| 13 |
-
|
| 14 |
-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 15 |
-
|
| 16 |
-
from dalle.models import Dalle
|
| 17 |
-
from dalle.utils.utils import set_seed, clip_score
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
parser = argparse.ArgumentParser()
|
| 21 |
-
parser.add_argument('-n', '--num_candidates', type=int, default=96)
|
| 22 |
-
parser.add_argument('--prompt', type=str, default='A painting of a tree on the ocean')
|
| 23 |
-
parser.add_argument('--softmax-temperature', type=float, default=1.0)
|
| 24 |
-
parser.add_argument('--top-k', type=int, default=256)
|
| 25 |
-
parser.add_argument('--top-p', type=float, default=None, help='0.0 <= top-p <= 1.0')
|
| 26 |
-
parser.add_argument('--seed', type=int, default=0)
|
| 27 |
-
|
| 28 |
-
args = parser.parse_args()
|
| 29 |
-
|
| 30 |
-
# Setup
|
| 31 |
-
assert args.top_k <= 256, "It is recommended that top_k is set lower than 256."
|
| 32 |
-
|
| 33 |
-
set_seed(args.seed)
|
| 34 |
-
device = 'cuda:0'
|
| 35 |
-
model = Dalle.from_pretrained('minDALL-E/1.3B') # This will automatically download the pretrained model.
|
| 36 |
-
model.to(device=device)
|
| 37 |
-
|
| 38 |
-
# Sampling
|
| 39 |
-
images = model.sampling(prompt=args.prompt,
|
| 40 |
-
top_k=args.top_k,
|
| 41 |
-
top_p=args.top_p,
|
| 42 |
-
softmax_temperature=args.softmax_temperature,
|
| 43 |
-
num_candidates=args.num_candidates,
|
| 44 |
-
device=device).cpu().numpy()
|
| 45 |
-
images = np.transpose(images, (0, 2, 3, 1))
|
| 46 |
-
|
| 47 |
-
# CLIP Re-ranking
|
| 48 |
-
model_clip, preprocess_clip = clip.load("ViT-B/32", device=device)
|
| 49 |
-
model_clip.to(device=device)
|
| 50 |
-
rank = clip_score(prompt=args.prompt,
|
| 51 |
-
images=images,
|
| 52 |
-
model_clip=model_clip,
|
| 53 |
-
preprocess_clip=preprocess_clip,
|
| 54 |
-
device=device)
|
| 55 |
-
|
| 56 |
-
# Save images
|
| 57 |
-
images = images[rank]
|
| 58 |
-
print(rank, images.shape)
|
| 59 |
-
if not os.path.exists('./figures'):
|
| 60 |
-
os.makedirs('./figures')
|
| 61 |
-
for i in range(min(16, args.num_candidates)):
|
| 62 |
-
im = Image.fromarray((images[i]*255).astype(np.uint8))
|
| 63 |
-
im.save(f'./figures/{args.prompt}_{i}.png')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
examples/sampling_interactive_demo.ipynb
DELETED
|
@@ -1,298 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"cells": [
|
| 3 |
-
{
|
| 4 |
-
"cell_type": "code",
|
| 5 |
-
"execution_count": 1,
|
| 6 |
-
"id": "cdf36725-ec00-4027-95d6-374340c2264e",
|
| 7 |
-
"metadata": {},
|
| 8 |
-
"outputs": [
|
| 9 |
-
{
|
| 10 |
-
"name": "stderr",
|
| 11 |
-
"output_type": "stream",
|
| 12 |
-
"text": [
|
| 13 |
-
"100%|█████████████████████████████████████| 4.72G/4.72G [02:04<00:00, 40.7MiB/s]\n",
|
| 14 |
-
"extracting: ./1.3B/tokenizer/bpe-16k-vocab.json (size:0MB): 100%|██████████| 7/7 [00:59<00:00, 8.51s/it]\n"
|
| 15 |
-
]
|
| 16 |
-
},
|
| 17 |
-
{
|
| 18 |
-
"name": "stdout",
|
| 19 |
-
"output_type": "stream",
|
| 20 |
-
"text": [
|
| 21 |
-
"/root/.cache/minDALL-E/1.3B/tokenizer successfully restored..\n",
|
| 22 |
-
"/root/.cache/minDALL-E/1.3B/stage1_last.ckpt successfully restored..\n"
|
| 23 |
-
]
|
| 24 |
-
},
|
| 25 |
-
{
|
| 26 |
-
"name": "stderr",
|
| 27 |
-
"output_type": "stream",
|
| 28 |
-
"text": [
|
| 29 |
-
" 0%| | 0.00/338M [00:00<?, ?iB/s]"
|
| 30 |
-
]
|
| 31 |
-
},
|
| 32 |
-
{
|
| 33 |
-
"name": "stdout",
|
| 34 |
-
"output_type": "stream",
|
| 35 |
-
"text": [
|
| 36 |
-
"/root/.cache/minDALL-E/1.3B/stage2_last.ckpt succesfully restored..\n"
|
| 37 |
-
]
|
| 38 |
-
},
|
| 39 |
-
{
|
| 40 |
-
"name": "stderr",
|
| 41 |
-
"output_type": "stream",
|
| 42 |
-
"text": [
|
| 43 |
-
"100%|███████████████████████████████████████| 338M/338M [00:09<00:00, 38.5MiB/s]\n"
|
| 44 |
-
]
|
| 45 |
-
}
|
| 46 |
-
],
|
| 47 |
-
"source": [
|
| 48 |
-
"import os\n",
|
| 49 |
-
"import sys\n",
|
| 50 |
-
"import math\n",
|
| 51 |
-
"import argparse\n",
|
| 52 |
-
"import clip\n",
|
| 53 |
-
"import numpy as np\n",
|
| 54 |
-
"%matplotlib inline\n",
|
| 55 |
-
"import matplotlib.pyplot as plt\n",
|
| 56 |
-
"from PIL import Image\n",
|
| 57 |
-
"\n",
|
| 58 |
-
"sys.path.append(os.path.dirname(os.getcwd()))\n",
|
| 59 |
-
"\n",
|
| 60 |
-
"from dalle.models import Dalle\n",
|
| 61 |
-
"from dalle.utils.utils import set_seed, clip_score\n",
|
| 62 |
-
"\n",
|
| 63 |
-
"device = 'cuda:0'\n",
|
| 64 |
-
"model = Dalle.from_pretrained(\"minDALL-E/1.3B\")\n",
|
| 65 |
-
"model_clip, preprocess_clip = clip.load(\"ViT-B/32\", device=device)\n",
|
| 66 |
-
"\n",
|
| 67 |
-
"model_clip.to(device=device)\n",
|
| 68 |
-
"model.to(device=device)\n",
|
| 69 |
-
"\n",
|
| 70 |
-
"def sampling(prompt, top_k, softmax_temperature, seed, num_candidates=96, num_samples_for_display=36):\n",
|
| 71 |
-
" # Setup\n",
|
| 72 |
-
" n_row = int(math.sqrt(num_samples_for_display))\n",
|
| 73 |
-
" n_col = int(math.sqrt(num_samples_for_display))\n",
|
| 74 |
-
" set_seed(seed)\n",
|
| 75 |
-
" \n",
|
| 76 |
-
" # Sampling\n",
|
| 77 |
-
" images = model.sampling(prompt=prompt,\n",
|
| 78 |
-
" top_k=top_k,\n",
|
| 79 |
-
" top_p=None,\n",
|
| 80 |
-
" softmax_temperature=softmax_temperature,\n",
|
| 81 |
-
" num_candidates=num_candidates,\n",
|
| 82 |
-
" device=device).cpu().numpy()\n",
|
| 83 |
-
" images = np.transpose(images, (0, 2, 3, 1))\n",
|
| 84 |
-
"\n",
|
| 85 |
-
" # CLIP Re-ranking\n",
|
| 86 |
-
" rank = clip_score(prompt=prompt, images=images, model_clip=model_clip, preprocess_clip=preprocess_clip, device=device)\n",
|
| 87 |
-
" images = images[rank]\n",
|
| 88 |
-
" \n",
|
| 89 |
-
" images = images[:num_samples_for_display]\n",
|
| 90 |
-
" fig = plt.figure(figsize=(8*n_row, 8*n_col))\n",
|
| 91 |
-
"\n",
|
| 92 |
-
" for i in range(num_samples_for_display):\n",
|
| 93 |
-
" ax = fig.add_subplot(n_row, n_col, i+1)\n",
|
| 94 |
-
" ax.imshow(images[i])\n",
|
| 95 |
-
" ax.set_axis_off()\n",
|
| 96 |
-
"\n",
|
| 97 |
-
" plt.tight_layout()\n",
|
| 98 |
-
" plt.show()"
|
| 99 |
-
]
|
| 100 |
-
},
|
| 101 |
-
{
|
| 102 |
-
"cell_type": "code",
|
| 103 |
-
"execution_count": 2,
|
| 104 |
-
"id": "619add15-073e-40f4-9a97-06b89d647c81",
|
| 105 |
-
"metadata": {},
|
| 106 |
-
"outputs": [
|
| 107 |
-
{
|
| 108 |
-
"data": {
|
| 109 |
-
"application/vnd.jupyter.widget-view+json": {
|
| 110 |
-
"model_id": "ee477531ea0e4b86b20d997f8cb83767",
|
| 111 |
-
"version_major": 2,
|
| 112 |
-
"version_minor": 0
|
| 113 |
-
},
|
| 114 |
-
"text/plain": [
|
| 115 |
-
"IntSlider(value=0, description='RND SEED: ', max=1024)"
|
| 116 |
-
]
|
| 117 |
-
},
|
| 118 |
-
"metadata": {},
|
| 119 |
-
"output_type": "display_data"
|
| 120 |
-
},
|
| 121 |
-
{
|
| 122 |
-
"data": {
|
| 123 |
-
"application/vnd.jupyter.widget-view+json": {
|
| 124 |
-
"model_id": "d63edc4725ef4f4e8a6f03f7693a481d",
|
| 125 |
-
"version_major": 2,
|
| 126 |
-
"version_minor": 0
|
| 127 |
-
},
|
| 128 |
-
"text/plain": [
|
| 129 |
-
"FloatSlider(value=1.0, description='SOFTMAX TEMPERATURE:', max=5.0, step=0.2)"
|
| 130 |
-
]
|
| 131 |
-
},
|
| 132 |
-
"metadata": {},
|
| 133 |
-
"output_type": "display_data"
|
| 134 |
-
},
|
| 135 |
-
{
|
| 136 |
-
"data": {
|
| 137 |
-
"application/vnd.jupyter.widget-view+json": {
|
| 138 |
-
"model_id": "5bb9170e9e8b4686a661799d8aff3901",
|
| 139 |
-
"version_major": 2,
|
| 140 |
-
"version_minor": 0
|
| 141 |
-
},
|
| 142 |
-
"text/plain": [
|
| 143 |
-
"IntSlider(value=256, description='TOP-K:', max=512, step=16)"
|
| 144 |
-
]
|
| 145 |
-
},
|
| 146 |
-
"metadata": {},
|
| 147 |
-
"output_type": "display_data"
|
| 148 |
-
},
|
| 149 |
-
{
|
| 150 |
-
"data": {
|
| 151 |
-
"application/vnd.jupyter.widget-view+json": {
|
| 152 |
-
"model_id": "6b97b49debfc4f7ab002748e9fd89864",
|
| 153 |
-
"version_major": 2,
|
| 154 |
-
"version_minor": 0
|
| 155 |
-
},
|
| 156 |
-
"text/plain": [
|
| 157 |
-
"Text(value='A painting of a monkey with sunglasses in the frame', description='String:', placeholder='Text pro…"
|
| 158 |
-
]
|
| 159 |
-
},
|
| 160 |
-
"metadata": {},
|
| 161 |
-
"output_type": "display_data"
|
| 162 |
-
},
|
| 163 |
-
{
|
| 164 |
-
"data": {
|
| 165 |
-
"application/vnd.jupyter.widget-view+json": {
|
| 166 |
-
"model_id": "a520b10d8c0b4dd0bb6db56dc37b4422",
|
| 167 |
-
"version_major": 2,
|
| 168 |
-
"version_minor": 0
|
| 169 |
-
},
|
| 170 |
-
"text/plain": [
|
| 171 |
-
"Button(description='Generate!', style=ButtonStyle())"
|
| 172 |
-
]
|
| 173 |
-
},
|
| 174 |
-
"metadata": {},
|
| 175 |
-
"output_type": "display_data"
|
| 176 |
-
},
|
| 177 |
-
{
|
| 178 |
-
"data": {
|
| 179 |
-
"application/vnd.jupyter.widget-view+json": {
|
| 180 |
-
"model_id": "5a98437abf964636a467677dc4f816bb",
|
| 181 |
-
"version_major": 2,
|
| 182 |
-
"version_minor": 0
|
| 183 |
-
},
|
| 184 |
-
"text/plain": [
|
| 185 |
-
"Output()"
|
| 186 |
-
]
|
| 187 |
-
},
|
| 188 |
-
"metadata": {},
|
| 189 |
-
"output_type": "display_data"
|
| 190 |
-
},
|
| 191 |
-
{
|
| 192 |
-
"data": {
|
| 193 |
-
"application/vnd.jupyter.widget-view+json": {
|
| 194 |
-
"model_id": "90d05006d50e4d88b8fb7c36095b12e7",
|
| 195 |
-
"version_major": 2,
|
| 196 |
-
"version_minor": 0
|
| 197 |
-
},
|
| 198 |
-
"text/plain": [
|
| 199 |
-
"Output()"
|
| 200 |
-
]
|
| 201 |
-
},
|
| 202 |
-
"metadata": {},
|
| 203 |
-
"output_type": "display_data"
|
| 204 |
-
}
|
| 205 |
-
],
|
| 206 |
-
"source": [
|
| 207 |
-
"import ipywidgets as widgets\n",
|
| 208 |
-
"from IPython.display import display\n",
|
| 209 |
-
"from IPython.display import clear_output\n",
|
| 210 |
-
"\n",
|
| 211 |
-
"output = widgets.Output()\n",
|
| 212 |
-
"plot_output = widgets.Output()\n",
|
| 213 |
-
"\n",
|
| 214 |
-
"def btn_eventhandler(obj):\n",
|
| 215 |
-
" output.clear_output()\n",
|
| 216 |
-
" plot_output.clear_output()\n",
|
| 217 |
-
" \n",
|
| 218 |
-
" with output:\n",
|
| 219 |
-
" print(f'SEED: {slider_seed.value}')\n",
|
| 220 |
-
" print(f'Softmax Temperature: {slider_temp.value}')\n",
|
| 221 |
-
" print(f'Top-K: {slider_topk.value}')\n",
|
| 222 |
-
" print(f'Text prompt: {wd_text.value}')\n",
|
| 223 |
-
" \n",
|
| 224 |
-
" with plot_output:\n",
|
| 225 |
-
" sampling(prompt=wd_text.value, top_k=slider_topk.value, softmax_temperature=slider_temp.value, seed=slider_seed.value)\n",
|
| 226 |
-
" \n",
|
| 227 |
-
"slider_seed = widgets.IntSlider(\n",
|
| 228 |
-
" min=0,\n",
|
| 229 |
-
" max=1024,\n",
|
| 230 |
-
" step=1,\n",
|
| 231 |
-
" description='RND SEED: ',\n",
|
| 232 |
-
" value=0\n",
|
| 233 |
-
")\n",
|
| 234 |
-
"slider_topk = widgets.IntSlider(\n",
|
| 235 |
-
" min=0,\n",
|
| 236 |
-
" max=512,\n",
|
| 237 |
-
" step=16,\n",
|
| 238 |
-
" description='TOP-K:',\n",
|
| 239 |
-
" value=256\n",
|
| 240 |
-
")\n",
|
| 241 |
-
"slider_temp = widgets.FloatSlider(\n",
|
| 242 |
-
" min=0.0,\n",
|
| 243 |
-
" max=5.0,\n",
|
| 244 |
-
" step=0.2,\n",
|
| 245 |
-
" description='SOFTMAX TEMPERATURE:',\n",
|
| 246 |
-
" value=1.0\n",
|
| 247 |
-
")\n",
|
| 248 |
-
"wd_text = widgets.Text(\n",
|
| 249 |
-
" value='A painting of a monkey with sunglasses in the frame',\n",
|
| 250 |
-
" placeholder='Text prompt',\n",
|
| 251 |
-
" description='String:',\n",
|
| 252 |
-
" disabled=False\n",
|
| 253 |
-
")\n",
|
| 254 |
-
"\n",
|
| 255 |
-
"display(slider_seed)\n",
|
| 256 |
-
"display(slider_temp)\n",
|
| 257 |
-
"display(slider_topk)\n",
|
| 258 |
-
"display(wd_text)\n",
|
| 259 |
-
"\n",
|
| 260 |
-
"btn = widgets.Button(description='Generate!')\n",
|
| 261 |
-
"display(btn)\n",
|
| 262 |
-
"btn.on_click(btn_eventhandler)\n",
|
| 263 |
-
"\n",
|
| 264 |
-
"display(output)\n",
|
| 265 |
-
"display(plot_output)"
|
| 266 |
-
]
|
| 267 |
-
},
|
| 268 |
-
{
|
| 269 |
-
"cell_type": "code",
|
| 270 |
-
"execution_count": null,
|
| 271 |
-
"id": "20571236-3b9a-426e-ab29-96b643c8cbe1",
|
| 272 |
-
"metadata": {},
|
| 273 |
-
"outputs": [],
|
| 274 |
-
"source": []
|
| 275 |
-
}
|
| 276 |
-
],
|
| 277 |
-
"metadata": {
|
| 278 |
-
"kernelspec": {
|
| 279 |
-
"display_name": "Python 3 (ipykernel)",
|
| 280 |
-
"language": "python",
|
| 281 |
-
"name": "python3"
|
| 282 |
-
},
|
| 283 |
-
"language_info": {
|
| 284 |
-
"codemirror_mode": {
|
| 285 |
-
"name": "ipython",
|
| 286 |
-
"version": 3
|
| 287 |
-
},
|
| 288 |
-
"file_extension": ".py",
|
| 289 |
-
"mimetype": "text/x-python",
|
| 290 |
-
"name": "python",
|
| 291 |
-
"nbconvert_exporter": "python",
|
| 292 |
-
"pygments_lexer": "ipython3",
|
| 293 |
-
"version": "3.7.7"
|
| 294 |
-
}
|
| 295 |
-
},
|
| 296 |
-
"nbformat": 4,
|
| 297 |
-
"nbformat_minor": 5
|
| 298 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
examples/transfer_learning_ex.py
DELETED
|
@@ -1,172 +0,0 @@
|
|
| 1 |
-
# ------------------------------------------------------------------------------------
|
| 2 |
-
# Minimal DALL-E
|
| 3 |
-
# Copyright (c) 2021 KakaoBrain. All Rights Reserved.
|
| 4 |
-
# Licensed under the Apache License, Version 2.0 [see LICENSE for details]
|
| 5 |
-
# ------------------------------------------------------------------------------------
|
| 6 |
-
|
| 7 |
-
import os
|
| 8 |
-
import sys
|
| 9 |
-
import argparse
|
| 10 |
-
from typing import Optional
|
| 11 |
-
from datetime import datetime
|
| 12 |
-
|
| 13 |
-
import torch
|
| 14 |
-
from torch.utils.data import DataLoader
|
| 15 |
-
import torchvision
|
| 16 |
-
import torchvision.transforms as transforms
|
| 17 |
-
import pytorch_lightning as pl
|
| 18 |
-
from pytorch_lightning.callbacks import ModelCheckpoint, Callback
|
| 19 |
-
from pytorch_lightning.loggers import TensorBoardLogger
|
| 20 |
-
from pytorch_lightning.utilities.distributed import rank_zero_only
|
| 21 |
-
|
| 22 |
-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 23 |
-
|
| 24 |
-
from dalle.models import ImageGPT
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
parser = argparse.ArgumentParser()
|
| 28 |
-
|
| 29 |
-
parser.add_argument('-d', '--config-downstream', type=str, default=None, required=True)
|
| 30 |
-
parser.add_argument('-u', '--path-upstream', type=str, default=None, required=True)
|
| 31 |
-
parser.add_argument('-r', '--result-path', type=str, default=None, required=True)
|
| 32 |
-
parser.add_argument('--imagenet-path', type=str, default=None, required=True)
|
| 33 |
-
|
| 34 |
-
parser.add_argument('--n-gpus', type=int, default=1)
|
| 35 |
-
parser.add_argument('--seed', type=int, default=0)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
args = parser.parse_args()
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
class ImageLogger(Callback):
|
| 42 |
-
def __init__(self):
|
| 43 |
-
super().__init__()
|
| 44 |
-
|
| 45 |
-
@rank_zero_only
|
| 46 |
-
def log_img(self, pl_module, batch, current_epoch, split="train"):
|
| 47 |
-
with torch.no_grad():
|
| 48 |
-
images, labels = batch
|
| 49 |
-
recons = pl_module.stage1(images)
|
| 50 |
-
images = images.cpu()
|
| 51 |
-
recons = recons.cpu()
|
| 52 |
-
|
| 53 |
-
grid_org = (torchvision.utils.make_grid(images, nrow=8) + 1.0) / 2.0
|
| 54 |
-
grid_rec = (torchvision.utils.make_grid(recons, nrow=8) + 1.0) / 2.0
|
| 55 |
-
grid_rec = torch.clip(grid_rec, min=0, max=1)
|
| 56 |
-
|
| 57 |
-
pl_module.logger.experiment.add_image(f"images_org/{split}", grid_org, global_step=current_epoch)
|
| 58 |
-
pl_module.logger.experiment.add_image(f"images_rec/{split}", grid_rec, global_step=current_epoch)
|
| 59 |
-
|
| 60 |
-
def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx, dataloader_idx):
|
| 61 |
-
if batch_idx == 0 and trainer.current_epoch < 5:
|
| 62 |
-
self.log_img(pl_module, batch, current_epoch=trainer.current_epoch, split="train")
|
| 63 |
-
|
| 64 |
-
def on_validation_batch_end(self, trainer, pl_module, outputs, batch, batch_idx, dataloader_idx):
|
| 65 |
-
if batch_idx == 0 and trainer.current_epoch < 5:
|
| 66 |
-
self.log_img(pl_module, batch, current_epoch=trainer.current_epoch, split="test")
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
class ImageNetDataModule(pl.LightningDataModule):
|
| 70 |
-
def __init__(self,
|
| 71 |
-
data_dir: Optional[str] = None,
|
| 72 |
-
image_resolution: int = 256,
|
| 73 |
-
train_batch_size: int = 2,
|
| 74 |
-
valid_batch_size: int = 32,
|
| 75 |
-
num_workers: int = 8):
|
| 76 |
-
super().__init__()
|
| 77 |
-
|
| 78 |
-
self.data_dir = data_dir
|
| 79 |
-
self.image_resolution = image_resolution
|
| 80 |
-
self.train_batch_size = train_batch_size
|
| 81 |
-
self.valid_batch_size = valid_batch_size
|
| 82 |
-
self.num_workers = num_workers
|
| 83 |
-
|
| 84 |
-
self.train_transform = transforms.Compose(
|
| 85 |
-
[transforms.Resize(image_resolution),
|
| 86 |
-
transforms.RandomCrop(image_resolution),
|
| 87 |
-
transforms.ToTensor(),
|
| 88 |
-
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])]
|
| 89 |
-
)
|
| 90 |
-
self.valid_transform = transforms.Compose(
|
| 91 |
-
[transforms.Resize(image_resolution),
|
| 92 |
-
transforms.CenterCrop(image_resolution),
|
| 93 |
-
transforms.ToTensor(),
|
| 94 |
-
transforms.Normalize([0.5, 0.5, 0.5], [0.5, 0.5, 0.5])]
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
-
def setup(self, stage=None):
|
| 98 |
-
self.trainset = torchvision.datasets.ImageNet(root=self.data_dir, split='train', transform=self.train_transform)
|
| 99 |
-
self.validset = torchvision.datasets.ImageNet(root=self.data_dir, split='val', transform=self.valid_transform)
|
| 100 |
-
|
| 101 |
-
def train_dataloader(self):
|
| 102 |
-
return DataLoader(self.trainset,
|
| 103 |
-
batch_size=self.train_batch_size,
|
| 104 |
-
num_workers=self.num_workers,
|
| 105 |
-
pin_memory=True)
|
| 106 |
-
|
| 107 |
-
def valid_dataloader(self):
|
| 108 |
-
return DataLoader(self.validset,
|
| 109 |
-
batch_size=self.valid_batch_size,
|
| 110 |
-
num_workers=self.num_workers,
|
| 111 |
-
pin_memory=True)
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
def setup_callbacks(config):
|
| 115 |
-
# Setup callbacks
|
| 116 |
-
now = datetime.now().strftime('%d%m%Y_%H%M%S')
|
| 117 |
-
result_path = os.path.join(args.result_path,
|
| 118 |
-
os.path.basename(args.config_downstream).split('.')[0],
|
| 119 |
-
now)
|
| 120 |
-
ckpt_path = os.path.join(result_path, 'ckpt')
|
| 121 |
-
log_path = os.path.join(result_path, 'log')
|
| 122 |
-
|
| 123 |
-
checkpoint_callback = ModelCheckpoint(
|
| 124 |
-
dirpath=ckpt_path,
|
| 125 |
-
filename="imagenet-clscond-gen-{epoch:02d}" if config.stage2.use_cls_cond else
|
| 126 |
-
"imagenet-uncond-gen-{epoch:02d}",
|
| 127 |
-
every_n_epochs=config.experiment.save_ckpt_freq,
|
| 128 |
-
save_weights_only=True,
|
| 129 |
-
save_last=True
|
| 130 |
-
)
|
| 131 |
-
logger = TensorBoardLogger(log_path, name="iGPT")
|
| 132 |
-
logger_img = ImageLogger()
|
| 133 |
-
return checkpoint_callback, logger, logger_img
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
if __name__ == '__main__':
|
| 137 |
-
pl.seed_everything(args.seed)
|
| 138 |
-
|
| 139 |
-
# Build iGPT
|
| 140 |
-
model, config = ImageGPT.from_pretrained(args.path_upstream, args.config_downstream)
|
| 141 |
-
|
| 142 |
-
# Setup callbacks
|
| 143 |
-
ckpt_callback, logger, logger_img = setup_callbacks(config)
|
| 144 |
-
|
| 145 |
-
# Build data modules
|
| 146 |
-
dataset = ImageNetDataModule(data_dir=args.imagenet_path,
|
| 147 |
-
image_resolution=config.dataset.image_resolution,
|
| 148 |
-
train_batch_size=config.experiment.local_batch_size,
|
| 149 |
-
valid_batch_size=config.experiment.valid_batch_size,
|
| 150 |
-
num_workers=16)
|
| 151 |
-
dataset.setup()
|
| 152 |
-
train_dataloader = dataset.train_dataloader()
|
| 153 |
-
valid_dataloader = dataset.valid_dataloader()
|
| 154 |
-
print(f"len(train_dataset) = {len(dataset.trainset)}")
|
| 155 |
-
print(f"len(valid_dataset) = {len(dataset.validset)}")
|
| 156 |
-
|
| 157 |
-
# Calculate how many batches are accumulated
|
| 158 |
-
assert config.experiment.total_batch_size % (config.experiment.local_batch_size * args.n_gpus) == 0
|
| 159 |
-
grad_accm_steps = config.experiment.total_batch_size // (config.experiment.local_batch_size * args.n_gpus)
|
| 160 |
-
config.optimizer.max_steps = len(dataset.trainset) // config.experiment.total_batch_size * config.experiment.epochs
|
| 161 |
-
|
| 162 |
-
# Build trainer
|
| 163 |
-
trainer = pl.Trainer(max_epochs=config.experiment.epochs,
|
| 164 |
-
accumulate_grad_batches=grad_accm_steps,
|
| 165 |
-
gradient_clip_val=config.optimizer.grad_clip_norm,
|
| 166 |
-
precision=16 if config.experiment.use_amp else 32,
|
| 167 |
-
callbacks=[ckpt_callback, logger_img],
|
| 168 |
-
accelerator="gpu",
|
| 169 |
-
devices=args.n_gpus,
|
| 170 |
-
strategy="ddp",
|
| 171 |
-
logger=logger)
|
| 172 |
-
trainer.fit(model, train_dataloader, valid_dataloader)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
last.ckpt
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:8c8e53ac2ae57e72d2df9bcecd6b758e9ec4ae0eb96a0154719feb1d7ef4708c
|
| 3 |
-
size 980089751
|
|
|
|
|
|
|
|
|
|
|
|
server.py
CHANGED
|
@@ -10,11 +10,10 @@ from fastapi import FastAPI
|
|
| 10 |
import numpy as np
|
| 11 |
from PIL import Image
|
| 12 |
|
| 13 |
-
#import clip
|
| 14 |
from dalle.models import Dalle
|
| 15 |
import logging
|
| 16 |
import streamlit as st
|
| 17 |
-
|
| 18 |
|
| 19 |
print("Loading models...")
|
| 20 |
app = FastAPI()
|
|
@@ -29,13 +28,9 @@ logging.info("End downloading")
|
|
| 29 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 30 |
model = Dalle.from_pretrained("minDALL-E/1.3B")
|
| 31 |
|
| 32 |
-
# NEW METHOD
|
| 33 |
model.load_state_dict(torch.load(full_dict_path, map_location=torch.device('cpu')))
|
| 34 |
model.to(device=device)
|
| 35 |
|
| 36 |
-
# model_clip, preprocess_clip = clip.load("ViT-B/32", device=device)
|
| 37 |
-
# model_clip.to(device=device)
|
| 38 |
-
|
| 39 |
print("Models loaded !")
|
| 40 |
|
| 41 |
|
|
@@ -62,11 +57,6 @@ def sample(prompt):
|
|
| 62 |
logging.info("sampling succeeded")
|
| 63 |
images = np.transpose(images, (0, 2, 3, 1))
|
| 64 |
|
| 65 |
-
# CLIP Re-ranking
|
| 66 |
-
# rank = clip_score(
|
| 67 |
-
# prompt=prompt, images=images, model_clip=model_clip, preprocess_clip=preprocess_clip, device=device
|
| 68 |
-
# )
|
| 69 |
-
# images = images[rank]
|
| 70 |
|
| 71 |
pil_images = []
|
| 72 |
for i in range(len(images)):
|
|
|
|
| 10 |
import numpy as np
|
| 11 |
from PIL import Image
|
| 12 |
|
|
|
|
| 13 |
from dalle.models import Dalle
|
| 14 |
import logging
|
| 15 |
import streamlit as st
|
| 16 |
+
|
| 17 |
|
| 18 |
print("Loading models...")
|
| 19 |
app = FastAPI()
|
|
|
|
| 28 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 29 |
model = Dalle.from_pretrained("minDALL-E/1.3B")
|
| 30 |
|
|
|
|
| 31 |
model.load_state_dict(torch.load(full_dict_path, map_location=torch.device('cpu')))
|
| 32 |
model.to(device=device)
|
| 33 |
|
|
|
|
|
|
|
|
|
|
| 34 |
print("Models loaded !")
|
| 35 |
|
| 36 |
|
|
|
|
| 57 |
logging.info("sampling succeeded")
|
| 58 |
images = np.transpose(images, (0, 2, 3, 1))
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
pil_images = []
|
| 62 |
for i in range(len(images)):
|