.gitattributes DELETED
@@ -1,35 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.vscode/settings.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "flake8.args": [
3
+ "--max-line-length=120"
4
+ ]
5
+ }
LICENSE CHANGED
@@ -1 +1,399 @@
1
- 
2
  This Non-Commercial End User License Agreement (as may be revised
3
  If You wish to Use the Licensed Materials or Derivative Technology
4
  Please read the terms of this Agreement carefully before Using any
5
  We may revise this Agreement from time to time, for any reason.
6
  "Intellectual Property Rights" means all intellectual property and
7
  "Licensed Materials" means the Recursion Software to which We
8
  "Permitted Purpose" means non-commercial research, academic, and
9
  "Recursion Software" means Recursion's proprietary software
10
  "Site" means www.rxrx.ai and https://developer.nvidia.com/login,
11
  "You" (and its correlatives) means the individual(s) or
12
  Subject to Your compliance with the terms of this Agreement, We
13
  For clarity, and without limiting the generality of the foregoing,
14
  (a) sell, lease, rent, lend, license, sublicense, assign,
15
  (b) Use the Licensed Materials or Derivative Technology, in each
16
  (c) Use the Licensed Materials or Derivative Technology, in each
17
  (d) Use the Licensed Materials or Derivative Technology, in each
18
  (d) deploy any AI Model trained on the Licensed Materials or
19
  (e) Use the Licensed Materials or Derivative Technology (including
20
  (f) engage in, or advise in the engaging of, any trading of
21
  (g) publish any article or other document, or deliver any
22
  You must include an attribution to Us in the applicable form set
23
  In addition, You must indicate whether You modified the applicable
24
  If We request, You must remove any of the information required
25
  (a) reverse engineer, disassemble, decompile, decode, adapt, or
26
  (b) except as expressly permitted by Section 3 (License Grant),
27
  (c) except as expressly permitted by Section 3 (License Grant),
28
  (d) Use the Licensed Materials in any manner or for any purpose
29
  (e) remove, delete, alter, or obscure any trademarks or any
30
  (f) Use the Licensed Materials to violate any national or
31
  (g) attempt to interfere with the proper working of the Recursion
32
  (h) disrupt or interfere with the Recursion Software or Our
33
  (i) Use the Licensed Materials in any abusive or illegal way, as
34
  You acknowledge and agree that the Licensed Materials are provided
35
  All rights not expressly granted to You herein are reserved for
36
  Every individual or entity with whom You share the Recursion
37
  If You share any Derivative Technology with any individual(s) or
38
  If You share any Recursion Software or Derivative Technology, You
39
  We will have no obligation to provide upgrades or updates to the
40
  The Licensed Materials may display, include, or make available
41
  You acknowledge that when You Use any of the Licensed Materials,
42
  The term of this Agreement ("Term") commences when You download
43
  Your rights under this Agreement terminate automatically if You
44
  For the avoidance of doubt, We may also offer the Licensed
45
  Upon termination of this Agreement: (i) all licenses and other
46
  THE LICENSED MATERIALS, INCLUDING ANY THIRD-PARTY MATERIALS
47
  TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT
48
  You agree to indemnify, defend, and hold harmless Us, Our
49
  US Government Rights. The Licensed Materials include commercial
50
  Export Regulation. The Licensed Material or Derivative Technology
51
  Assignment. You may not assign this Agreement or any of your
52
  Governing Law; Venue. This Agreement will be governed by and
53
  Equitable Relief. You acknowledge and agree that the restrictions
54
  Section Titles. The section titles and headers are for convenience
55
  Entire Agreement. Other than the Privacy Policy and any commercial
56
  Severability. If any provision of this Agreement is held to be
57
  Waiver. No delay or omission by Us in exercising any right
58
  English Language. This Agreement is in the English language only,
59
  Questions, Comments, and Concerns. All requests for technical
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  This Non-Commercial End User License Agreement (as may be revised
2
  If You wish to Use the Licensed Materials or Derivative Technology
3
  Please read the terms of this Agreement carefully before Using any
4
  We may revise this Agreement from time to time, for any reason.
5
  "Intellectual Property Rights" means all intellectual property and
6
  "Licensed Materials" means the Recursion Software to which We
7
  "Permitted Purpose" means non-commercial research, academic, and
8
  "Recursion Software" means Recursion's proprietary software
9
  "Site" means www.rxrx.ai and https://developer.nvidia.com/login,
10
  "You" (and its correlatives) means the individual(s) or
11
  Subject to Your compliance with the terms of this Agreement, We
12
  For clarity, and without limiting the generality of the foregoing,
13
  (a) sell, lease, rent, lend, license, sublicense, assign,
14
  (b) Use the Licensed Materials or Derivative Technology, in each
15
  (c) Use the Licensed Materials or Derivative Technology, in each
16
  (d) Use the Licensed Materials or Derivative Technology, in each
17
  (d) deploy any AI Model trained on the Licensed Materials or
18
  (e) Use the Licensed Materials or Derivative Technology (including
19
  (f) engage in, or advise in the engaging of, any trading of
20
  (g) publish any article or other document, or deliver any
21
  You must include an attribution to Us in the applicable form set
22
  In addition, You must indicate whether You modified the applicable
23
  If We request, You must remove any of the information required
24
  (a) reverse engineer, disassemble, decompile, decode, adapt, or
25
  (b) except as expressly permitted by Section 3 (License Grant),
26
  (c) except as expressly permitted by Section 3 (License Grant),
27
  (d) Use the Licensed Materials in any manner or for any purpose
28
  (e) remove, delete, alter, or obscure any trademarks or any
29
  (f) Use the Licensed Materials to violate any national or
30
  (g) attempt to interfere with the proper working of the Recursion
31
  (h) disrupt or interfere with the Recursion Software or Our
32
  (i) Use the Licensed Materials in any abusive or illegal way, as
33
  You acknowledge and agree that the Licensed Materials are provided
34
  All rights not expressly granted to You herein are reserved for
35
  Every individual or entity with whom You share the Recursion
36
  If You share any Derivative Technology with any individual(s) or
37
  If You share any Recursion Software or Derivative Technology, You
38
  We will have no obligation to provide upgrades or updates to the
39
  The Licensed Materials may display, include, or make available
40
  You acknowledge that when You Use any of the Licensed Materials,
41
  The term of this Agreement ("Term") commences when You download
42
  Your rights under this Agreement terminate automatically if You
43
  For the avoidance of doubt, We may also offer the Licensed
44
  Upon termination of this Agreement: (i) all licenses and other
45
  THE LICENSED MATERIALS, INCLUDING ANY THIRD-PARTY MATERIALS
46
  TO THE FULLEST EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT
47
  You agree to indemnify, defend, and hold harmless Us, Our
48
  US Government Rights. The Licensed Materials include commercial
49
  Export Regulation. The Licensed Material or Derivative Technology
50
  Assignment. You may not assign this Agreement or any of your
51
  Governing Law; Venue. This Agreement will be governed by and
52
  Equitable Relief. You acknowledge and agree that the restrictions
53
  Section Titles. The section titles and headers are for convenience
54
  Entire Agreement. Other than the Privacy Policy and any commercial
55
  Severability. If any provision of this Agreement is held to be
56
  Waiver. No delay or omission by Us in exercising any right
57
  English Language. This Agreement is in the English language only,
58
  Questions, Comments, and Concerns. All requests for technical
59
+ Attribution-NonCommercial 4.0 International
60
+
61
+ =======================================================================
62
+
63
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
64
+ does not provide legal services or legal advice. Distribution of
65
+ Creative Commons public licenses does not create a lawyer-client or
66
+ other relationship. Creative Commons makes its licenses and related
67
+ information available on an "as-is" basis. Creative Commons gives no
68
+ warranties regarding its licenses, any material licensed under their
69
+ terms and conditions, or any related information. Creative Commons
70
+ disclaims all liability for damages resulting from their use to the
71
+ fullest extent possible.
72
+
73
+ Using Creative Commons Public Licenses
74
+
75
+ Creative Commons public licenses provide a standard set of terms and
76
+ conditions that creators and other rights holders may use to share
77
+ original works of authorship and other material subject to copyright
78
+ and certain other rights specified in the public license below. The
79
+ following considerations are for informational purposes only, are not
80
+ exhaustive, and do not form part of our licenses.
81
+
82
+ Considerations for licensors: Our public licenses are
83
+ intended for use by those authorized to give the public
84
+ permission to use material in ways otherwise restricted by
85
+ copyright and certain other rights. Our licenses are
86
+ irrevocable. Licensors should read and understand the terms
87
+ and conditions of the license they choose before applying it.
88
+ Licensors should also secure all rights necessary before
89
+ applying our licenses so that the public can reuse the
90
+ material as expected. Licensors should clearly mark any
91
+ material not subject to the license. This includes other CC-
92
+ licensed material, or material used under an exception or
93
+ limitation to copyright. More considerations for licensors:
94
+ wiki.creativecommons.org/Considerations_for_licensors
95
+
96
+ Considerations for the public: By using one of our public
97
+ licenses, a licensor grants the public permission to use the
98
+ licensed material under specified terms and conditions. If
99
+ the licensor's permission is not necessary for any reason--for
100
+ example, because of any applicable exception or limitation to
101
+ copyright--then that use is not regulated by the license. Our
102
+ licenses grant only permissions under copyright and certain
103
+ other rights that a licensor has authority to grant. Use of
104
+ the licensed material may still be restricted for other
105
+ reasons, including because others have copyright or other
106
+ rights in the material. A licensor may make special requests,
107
+ such as asking that all changes be marked or described.
108
+ Although not required by our licenses, you are encouraged to
109
+ respect those requests where reasonable. More_considerations
110
+ for the public:
111
+ wiki.creativecommons.org/Considerations_for_licensees
112
+
113
+ =======================================================================
114
+
115
+ Creative Commons Attribution-NonCommercial 4.0 International Public
116
+ License
117
+
118
+ By exercising the Licensed Rights (defined below), You accept and agree
119
+ to be bound by the terms and conditions of this Creative Commons
120
+ Attribution-NonCommercial 4.0 International Public License ("Public
121
+ License"). To the extent this Public License may be interpreted as a
122
+ contract, You are granted the Licensed Rights in consideration of Your
123
+ acceptance of these terms and conditions, and the Licensor grants You
124
+ such rights in consideration of benefits the Licensor receives from
125
+ making the Licensed Material available under these terms and
126
+ conditions.
127
+
128
+ Section 1 -- Definitions.
129
+
130
+ a. Adapted Material means material subject to Copyright and Similar
131
+ Rights that is derived from or based upon the Licensed Material
132
+ and in which the Licensed Material is translated, altered,
133
+ arranged, transformed, or otherwise modified in a manner requiring
134
+ permission under the Copyright and Similar Rights held by the
135
+ Licensor. For purposes of this Public License, where the Licensed
136
+ Material is a musical work, performance, or sound recording,
137
+ Adapted Material is always produced where the Licensed Material is
138
+ synched in timed relation with a moving image.
139
+
140
+ b. Adapter's License means the license You apply to Your Copyright
141
+ and Similar Rights in Your contributions to Adapted Material in
142
+ accordance with the terms and conditions of this Public License.
143
+
144
+ c. Copyright and Similar Rights means copyright and/or similar rights
145
+ closely related to copyright including, without limitation,
146
+ performance, broadcast, sound recording, and Sui Generis Database
147
+ Rights, without regard to how the rights are labeled or
148
+ categorized. For purposes of this Public License, the rights
149
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
150
+ Rights.
151
+ d. Effective Technological Measures means those measures that, in the
152
+ absence of proper authority, may not be circumvented under laws
153
+ fulfilling obligations under Article 11 of the WIPO Copyright
154
+ Treaty adopted on December 20, 1996, and/or similar international
155
+ agreements.
156
+
157
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
158
+ any other exception or limitation to Copyright and Similar Rights
159
+ that applies to Your use of the Licensed Material.
160
+
161
+ f. Licensed Material means the artistic or literary work, database,
162
+ or other material to which the Licensor applied this Public
163
+ License.
164
+
165
+ g. Licensed Rights means the rights granted to You subject to the
166
+ terms and conditions of this Public License, which are limited to
167
+ all Copyright and Similar Rights that apply to Your use of the
168
+ Licensed Material and that the Licensor has authority to license.
169
+
170
+ h. Licensor means the individual(s) or entity(ies) granting rights
171
+ under this Public License.
172
+
173
+ i. NonCommercial means not primarily intended for or directed towards
174
+ commercial advantage or monetary compensation. For purposes of
175
+ this Public License, the exchange of the Licensed Material for
176
+ other material subject to Copyright and Similar Rights by digital
177
+ file-sharing or similar means is NonCommercial provided there is
178
+ no payment of monetary compensation in connection with the
179
+ exchange.
180
+
181
+ j. Share means to provide material to the public by any means or
182
+ process that requires permission under the Licensed Rights, such
183
+ as reproduction, public display, public performance, distribution,
184
+ dissemination, communication, or importation, and to make material
185
+ available to the public including in ways that members of the
186
+ public may access the material from a place and at a time
187
+ individually chosen by them.
188
+
189
+ k. Sui Generis Database Rights means rights other than copyright
190
+ resulting from Directive 96/9/EC of the European Parliament and of
191
+ the Council of 11 March 1996 on the legal protection of databases,
192
+ as amended and/or succeeded, as well as other essentially
193
+ equivalent rights anywhere in the world.
194
+
195
+ l. You means the individual or entity exercising the Licensed Rights
196
+ under this Public License. Your has a corresponding meaning.
197
+
198
+ Section 2 -- Scope.
199
+
200
+ a. License grant.
201
+
202
+ 1. Subject to the terms and conditions of this Public License,
203
+ the Licensor hereby grants You a worldwide, royalty-free,
204
+ non-sublicensable, non-exclusive, irrevocable license to
205
+ exercise the Licensed Rights in the Licensed Material to:
206
+
207
+ a. reproduce and Share the Licensed Material, in whole or
208
+ in part, for NonCommercial purposes only; and
209
+
210
+ b. produce, reproduce, and Share Adapted Material for
211
+ NonCommercial purposes only.
212
+
213
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
214
+ Exceptions and Limitations apply to Your use, this Public
215
+ License does not apply, and You do not need to comply with
216
+ its terms and conditions.
217
+
218
+ 3. Term. The term of this Public License is specified in Section
219
+ 6(a).
220
+
221
+ 4. Media and formats; technical modifications allowed. The
222
+ Licensor authorizes You to exercise the Licensed Rights in
223
+ all media and formats whether now known or hereafter created,
224
+ and to make technical modifications necessary to do so. The
225
+ Licensor waives and/or agrees not to assert any right or
226
+ authority to forbid You from making technical modifications
227
+ necessary to exercise the Licensed Rights, including
228
+ technical modifications necessary to circumvent Effective
229
+ Technological Measures. For purposes of this Public License,
230
+ simply making modifications authorized by this Section 2(a)
231
+ (4) never produces Adapted Material.
232
+
233
+ 5. Downstream recipients.
234
+
235
+ a. Offer from the Licensor -- Licensed Material. Every
236
+ recipient of the Licensed Material automatically
237
+ receives an offer from the Licensor to exercise the
238
+ Licensed Rights under the terms and conditions of this
239
+ Public License.
240
+
241
+ b. No downstream restrictions. You may not offer or impose
242
+ any additional or different terms or conditions on, or
243
+ apply any Effective Technological Measures to, the
244
+ Licensed Material if doing so restricts exercise of the
245
+ Licensed Rights by any recipient of the Licensed
246
+ Material.
247
+
248
+ 6. No endorsement. Nothing in this Public License constitutes or
249
+ may be construed as permission to assert or imply that You
250
+ are, or that Your use of the Licensed Material is, connected
251
+ with, or sponsored, endorsed, or granted official status by,
252
+ the Licensor or others designated to receive attribution as
253
+ provided in Section 3(a)(1)(A)(i).
254
+
255
+ b. Other rights.
256
+
257
+ 1. Moral rights, such as the right of integrity, are not
258
+ licensed under this Public License, nor are publicity,
259
+ privacy, and/or other similar personality rights; however, to
260
+ the extent possible, the Licensor waives and/or agrees not to
261
+ assert any such rights held by the Licensor to the limited
262
+ extent necessary to allow You to exercise the Licensed
263
+ Rights, but not otherwise.
264
+
265
+ 2. Patent and trademark rights are not licensed under this
266
+ Public License.
267
+
268
+ 3. To the extent possible, the Licensor waives any right to
269
+ collect royalties from You for the exercise of the Licensed
270
+ Rights, whether directly or through a collecting society
271
+ under any voluntary or waivable statutory or compulsory
272
+ licensing scheme. In all other cases the Licensor expressly
273
+ reserves any right to collect such royalties, including when
274
+ the Licensed Material is used other than for NonCommercial
275
+ purposes.
276
+
277
+ Section 3 -- License Conditions.
278
+
279
+ Your exercise of the Licensed Rights is expressly made subject to the
280
+ following conditions.
281
+
282
+ a. Attribution.
283
+
284
+ 1. If You Share the Licensed Material (including in modified
285
+ form), You must:
286
+
287
+ a. retain the following if it is supplied by the Licensor
288
+ with the Licensed Material:
289
+
290
+ i. identification of the creator(s) of the Licensed
291
+ Material and any others designated to receive
292
+ attribution, in any reasonable manner requested by
293
+ the Licensor (including by pseudonym if
294
+ designated);
295
+
296
+ ii. a copyright notice;
297
+
298
+ iii. a notice that refers to this Public License;
299
+
300
+ iv. a notice that refers to the disclaimer of
301
+ warranties;
302
+
303
+ v. a URI or hyperlink to the Licensed Material to the
304
+ extent reasonably practicable;
305
+
306
+ b. indicate if You modified the Licensed Material and
307
+ retain an indication of any previous modifications; and
308
+
309
+ c. indicate the Licensed Material is licensed under this
310
+ Public License, and include the text of, or the URI or
311
+ hyperlink to, this Public License.
312
+
313
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
314
+ reasonable manner based on the medium, means, and context in
315
+ which You Share the Licensed Material. For example, it may be
316
+ reasonable to satisfy the conditions by providing a URI or
317
+ hyperlink to a resource that includes the required
318
+ information.
319
+
320
+ 3. If requested by the Licensor, You must remove any of the
321
+ information required by Section 3(a)(1)(A) to the extent
322
+ reasonably practicable.
323
+
324
+ 4. If You Share Adapted Material You produce, the Adapter's
325
+ License You apply must not prevent recipients of the Adapted
326
+ Material from complying with this Public License.
327
+
328
+ Section 4 -- Sui Generis Database Rights.
329
+
330
+ Where the Licensed Rights include Sui Generis Database Rights that
331
+ apply to Your use of the Licensed Material:
332
+
333
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
334
+ to extract, reuse, reproduce, and Share all or a substantial
335
+ portion of the contents of the database for NonCommercial purposes
336
+ only;
337
+
338
+ b. if You include all or a substantial portion of the database
339
+ contents in a database in which You have Sui Generis Database
340
+ Rights, then the database in which You have Sui Generis Database
341
+ Rights (but not its individual contents) is Adapted Material; and
342
+
343
+ c. You must comply with the conditions in Section 3(a) if You Share
344
+ all or a substantial portion of the contents of the database.
345
+
346
+ For the avoidance of doubt, this Section 4 supplements and does not
347
+ replace Your obligations under this Public License where the Licensed
348
+ Rights include other Copyright and Similar Rights.
349
+
350
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
351
+
352
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
353
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
354
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
355
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
356
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
357
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
358
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
359
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
360
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
361
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
362
+
363
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
364
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
365
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
366
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
367
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
368
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
369
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
370
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
371
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
372
+
373
+ c. The disclaimer of warranties and limitation of liability provided
374
+ above shall be interpreted in a manner that, to the extent
375
+ possible, most closely approximates an absolute disclaimer and
376
+ waiver of all liability.
377
+
378
+ Section 6 -- Term and Termination.
379
+
380
+ a. This Public License applies for the term of the Copyright and
381
+ Similar Rights licensed here. However, if You fail to comply with
382
+ this Public License, then Your rights under this Public License
383
+ terminate automatically.
384
+
385
+ b. Where Your right to use the Licensed Material has terminated under
386
+ Section 6(a), it reinstates:
387
+
388
+ 1. automatically as of the date the violation is cured, provided
389
+ it is cured within 30 days of Your discovery of the
390
+ violation; or
391
+
392
+ 2. upon express reinstatement by the Licensor.
393
+
394
+ For the avoidance of doubt, this Section 6(b) does not affect any
395
+ right the Licensor may have to seek remedies for Your violations
396
+ of this Public License.
397
+
398
+ c. For the avoidance of doubt, the Licensor may also offer the
399
+ Licensed Material under separate terms or conditions or stop
400
+ distributing the Licensed Material at any time; however, doing so
401
+ will not terminate this Public License.
402
+
403
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
404
+ License.
405
+
406
+ Section 7 -- Other Terms and Conditions.
407
+
408
+ a. The Licensor shall not be bound by any additional or different
409
+ terms or conditions communicated by You unless expressly agreed.
410
+
411
+ b. Any arrangements, understandings, or agreements regarding the
412
+ Licensed Material not stated herein are separate from and
413
+ independent of the terms and conditions of this Public License.
414
+
415
+ Section 8 -- Interpretation.
416
+
417
+ a. For the avoidance of doubt, this Public License does not, and
418
+ shall not be interpreted to, reduce, limit, restrict, or impose
419
+ conditions on any use of the Licensed Material that could lawfully
420
+ be made without permission under this Public License.
421
+
422
+ b. To the extent possible, if any provision of this Public License is
423
+ deemed unenforceable, it shall be automatically reformed to the
424
+ minimum extent necessary to make it enforceable. If the provision
425
+ cannot be reformed, it shall be severed from this Public License
426
+ without affecting the enforceability of the remaining terms and
427
+ conditions.
428
+
429
+ c. No term or condition of this Public License will be waived and no
430
+ failure to comply consented to unless expressly agreed to by the
431
+ Licensor.
432
+
433
+ d. Nothing in this Public License constitutes or may be interpreted
434
+ as a limitation upon, or waiver of, any privileges and immunities
435
+ that apply to the Licensor or You, including from the legal
436
+ processes of any jurisdiction or authority.
437
+
438
+ =======================================================================
439
+
440
+ Creative Commons is not a party to its public
441
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
442
+ its public licenses to material it publishes and in those instances
443
+ will be considered the “Licensor.” The text of the Creative Commons
444
+ public licenses is dedicated to the public domain under the CC0 Public
445
+ Domain Dedication. Except for the limited purpose of indicating that
446
+ material is shared under a Creative Commons public license or as
447
+ otherwise permitted by the Creative Commons policies published at
448
+ creativecommons.org/policies, Creative Commons does not authorize the
449
+ use of the trademark "Creative Commons" or any other trademark or logo
450
+ of Creative Commons without its prior written consent including,
451
+ without limitation, in connection with any unauthorized modifications
452
+ to any of its public licenses or any other arrangements,
453
+ understandings, or agreements concerning use of licensed material. For
454
+ the avoidance of doubt, this paragraph does not form part of the
455
+ public licenses.
456
+
457
+ Creative Commons may be contacted at creativecommons.org.
MODELCARD.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags: []
4
+ ---
5
+
6
+ # Model Card for Phenom CA-MAE-S/16
7
+
8
+ Channel-agnostic image encoding model designed for microscopy image featurization.
9
+ The model uses a vision transformer backbone with channelwise cross-attention over patch tokens to create contextualized representations separately for each channel.
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ This model is a [channel-agnostic masked autoencoder](https://openaccess.thecvf.com/content/CVPR2024/html/Kraus_Masked_Autoencoders_for_Microscopy_are_Scalable_Learners_of_Cellular_Biology_CVPR_2024_paper.html) trained to reconstruct microscopy images over three datasets:
17
+ 1. RxRx3
18
+ 2. JUMP-CP overexpression
19
+ 3. JUMP-CP gene-knockouts
20
+
21
+ - **Developed, funded, and shared by:** Recursion
22
+ - **Model type:** Vision transformer CA-MAE
23
+ - **Image modality:** Optimized for microscopy images from the CellPainting assay
24
+ - **License:**
25
+
26
+
27
+ ### Model Sources
28
+
29
+ - **Repository:** [https://github.com/recursionpharma/maes_microscopy](https://github.com/recursionpharma/maes_microscopy)
30
+ - **Paper:** [Masked Autoencoders for Microscopy are Scalable Learners of Cellular Biology](https://openaccess.thecvf.com/content/CVPR2024/html/Kraus_Masked_Autoencoders_for_Microscopy_are_Scalable_Learners_of_Cellular_Biology_CVPR_2024_paper.html)
31
+
32
+
33
+ ## Uses
34
+
35
+ NOTE: model embeddings tend to extract features only after using standard batch correction post-processing techniques. **We recommend**, at a *minimum*, after inferencing the model over your images, to do the standard `PCA-CenterScale` pattern or better yet Typical Variation Normalization:
36
+
37
+ 1. Fit a PCA kernel on all the *control images* (or all images if no controls) from across all experimental batches (e.g. the plates of wells from your assay),
38
+ 2. Transform all the embeddings with that PCA kernel,
39
+ 3. For each experimental batch, fit a separate StandardScaler on the transformed embeddings of the controls from step 2, then transform the rest of the embeddings from that batch with that StandardScaler.
40
+
41
+ ### Direct Use
42
+
43
+ - Create biologically useful embeddings of microscopy images
44
+ - Create contextualized embeddings of each channel of a microscopy image (set `return_channelwise_embeddings=True`)
45
+ - Leverage the full MAE encoder + decoder to predict new channels / stains for images without all 6 CellPainting channels
46
+
47
+ ### Downstream Use
48
+
49
+ - A determined ML expert could fine-tune the encoder for downstream tasks such as classification
50
+
51
+ ### Out-of-Scope Use
52
+
53
+ - Unlikely to be especially performant on brightfield microscopy images
54
+ - Out-of-domain medical images, such as H&E (maybe it would be a decent baseline though)
55
+
56
+ ## Bias, Risks, and Limitations
57
+
58
+ - Primary limitation is that the embeddings tend to be more useful at scale. For example, if you only have 1 plate of microscopy images, the embeddings might underperform compared to a supervised bespoke model.
59
+
60
+ ## How to Get Started with the Model
61
+
62
+ You should be able to successfully run the below tests, which demonstrate how to use the model at inference time.
63
+
64
+ ```python
65
+ import pytest
66
+ import torch
67
+
68
+ from huggingface_mae import MAEModel
69
+
70
+ huggingface_phenombeta_model_dir = "."
71
+ # huggingface_modelpath = "recursionpharma/test-pb-model"
72
+
73
+
74
+ @pytest.fixture
75
+ def huggingface_model():
76
+ # Make sure you have the model/config downloaded from https://huggingface.co/recursionpharma/test-pb-model to this directory
77
+ # huggingface-cli download recursionpharma/test-pb-model --local-dir=.
78
+ huggingface_model = MAEModel.from_pretrained(huggingface_phenombeta_model_dir)
79
+ huggingface_model.eval()
80
+ return huggingface_model
81
+
82
+
83
+ @pytest.mark.parametrize("C", [1, 4, 6, 11])
84
+ @pytest.mark.parametrize("return_channelwise_embeddings", [True, False])
85
+ def test_model_predict(huggingface_model, C, return_channelwise_embeddings):
86
+ example_input_array = torch.randint(
87
+ low=0,
88
+ high=255,
89
+ size=(2, C, 256, 256),
90
+ dtype=torch.uint8,
91
+ device=huggingface_model.device,
92
+ )
93
+ huggingface_model.return_channelwise_embeddings = return_channelwise_embeddings
94
+ embeddings = huggingface_model.predict(example_input_array)
95
+ expected_output_dim = 384 * C if return_channelwise_embeddings else 384
96
+ assert embeddings.shape == (2, expected_output_dim)
97
+ ```
98
+
99
+
100
+ ## Training, evaluation and testing details
101
+
102
+ See paper linked above for details on model training and evaluation. Primary hyperparameters are included in the repo linked above.
103
+
104
+
105
+ ## Environmental Impact
106
+
107
+ - **Hardware Type:** Nvidia H100 Hopper nodes
108
+ - **Hours used:** 400
109
+ - **Cloud Provider:** private cloud
110
+ - **Carbon Emitted:** 138.24 kg co2 (roughly the equivalent of one car driving from Toronto to Montreal)
111
+
112
+ **BibTeX:**
113
+
114
+ ```TeX
115
+ @inproceedings{kraus2024masked,
116
+ title={Masked Autoencoders for Microscopy are Scalable Learners of Cellular Biology},
117
+ author={Kraus, Oren and Kenyon-Dean, Kian and Saberian, Saber and Fallah, Maryam and McLean, Peter and Leung, Jess and Sharma, Vasudev and Khan, Ayla and Balakrishnan, Jia and Celik, Safiye and others},
118
+ booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
119
+ pages={11757--11768},
120
+ year={2024}
121
+ }
122
+ ```
123
+
124
+ ## Model Card Contact
125
+
126
+ - Kian Kenyon-Dean: kian.kd@recursion.com
127
+ - Oren Kraus: oren.kraus@recursion.com
128
+ - Or, email: info@rxrx.ai
README.md CHANGED
@@ -1,127 +1,42 @@
1
- ---
2
- library_name: transformers
3
- tags: []
4
- ---
 
 
 
5
 
6
- # Model Card for OpenPhenom-S/16
7
 
8
- Channel-agnostic image encoding model CA-MAE with a ViT-S/16 encoder backbone designed for microscopy image featurization.
9
- The model uses a vision transformer backbone with channelwise cross-attention over patch tokens to create contextualized representations separately for each channel.
10
 
 
 
11
 
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- This model is a [channel-agnostic masked autoencoder](https://openaccess.thecvf.com/content/CVPR2024/html/Kraus_Masked_Autoencoders_for_Microscopy_are_Scalable_Learners_of_Cellular_Biology_CVPR_2024_paper.html) trained to reconstruct microscopy images over three datasets:
17
- 1. RxRx3
18
- 2. JUMP-CP overexpression
19
- 3. JUMP-CP gene-knockouts
20
-
21
- - **Developed, funded, and shared by:** Recursion
22
- - **Model type:** Vision transformer CA-MAE
23
- - **Image modality:** Optimized for microscopy images from the CellPainting assay
24
- - **License:** [Non-Commercial End User License Agreement](https://huggingface.co/recursionpharma/OpenPhenom/blob/main/LICENSE)
25
-
26
-
27
- ### Model Sources
28
-
29
- - **Repository:** [https://github.com/recursionpharma/maes_microscopy](https://github.com/recursionpharma/maes_microscopy)
30
- - **Paper:** [Masked Autoencoders for Microscopy are Scalable Learners of Cellular Biology](https://openaccess.thecvf.com/content/CVPR2024/html/Kraus_Masked_Autoencoders_for_Microscopy_are_Scalable_Learners_of_Cellular_Biology_CVPR_2024_paper.html)
31
-
32
-
33
- ## Uses
34
-
35
- NOTE: model embeddings tend to extract features only after using standard batch correction post-processing techniques. **We recommend**, at a *minimum*, after inferencing the model over your images, to do the standard `PCA-CenterScale` pattern or better yet Typical Variation Normalization:
36
-
37
- 1. Fit a PCA kernel on all the *control images* (or all images if no controls) from across all experimental batches (e.g. the plates of wells from your assay),
38
- 2. Transform all the embeddings with that PCA kernel,
39
- 3. For each experimental batch, fit a separate StandardScaler on the transformed embeddings of the controls from step 2, then transform the rest of the embeddings from that batch with that StandardScaler.
40
-
41
- ### Direct Use
42
-
43
- - Create biologically useful embeddings of microscopy images
44
- - Create contextualized embeddings of each channel of a microscopy image (set `return_channelwise_embeddings=True`)
45
- - Leverage the full MAE encoder + decoder to predict new channels / stains for images without all 6 CellPainting channels
46
-
47
- ### Downstream Use
48
-
49
- - A determined ML expert could fine-tune the encoder for downstream tasks such as classification
50
-
51
- ### Out-of-Scope Use
52
-
53
- - Unlikely to be especially performant on brightfield microscopy images
54
- - Out-of-domain medical images, such as H&E (maybe it would be a decent baseline though)
55
-
56
- ## Bias, Risks, and Limitations
57
-
58
- - Primary limitation is that the embeddings tend to be more useful at scale. For example, if you only have 1 plate of microscopy images, the embeddings might underperform compared to a supervised bespoke model.
59
-
60
- ## How to Get Started with the Model
61
-
62
- You should be able to successfully run the below tests, which demonstrate how to use the model at inference time.
63
-
64
- ```python
65
- import pytest
66
- import torch
67
-
68
- from huggingface_mae import MAEModel
69
-
70
- # huggingface_openphenom_model_dir = "."
71
- huggingface_modelpath = "recursionpharma/OpenPhenom"
72
-
73
-
74
- @pytest.fixture
75
- def huggingface_model():
76
- # This step downloads the model to a local cache, takes a bit to run
77
- huggingface_model = MAEModel.from_pretrained(huggingface_modelpath)
78
- huggingface_model.eval()
79
- return huggingface_model
80
-
81
-
82
- @pytest.mark.parametrize("C", [1, 4, 6, 11])
83
- @pytest.mark.parametrize("return_channelwise_embeddings", [True, False])
84
- def test_model_predict(huggingface_model, C, return_channelwise_embeddings):
85
- example_input_array = torch.randint(
86
- low=0,
87
- high=255,
88
- size=(2, C, 256, 256),
89
- dtype=torch.uint8,
90
- device=huggingface_model.device,
91
- )
92
- huggingface_model.return_channelwise_embeddings = return_channelwise_embeddings
93
- embeddings = huggingface_model.predict(example_input_array)
94
- expected_output_dim = 384 * C if return_channelwise_embeddings else 384
95
- assert embeddings.shape == (2, expected_output_dim)
96
  ```
97
- We also provide a [notebook](https://huggingface.co/recursionpharma/OpenPhenom/blob/main/RxRx3-core_inference.ipynb) for running inference on [RxRx3-core](https://huggingface.co/datasets/recursionpharma/rxrx3-core).
98
-
99
- ## Training, evaluation and testing details
100
-
101
- See paper linked above for details on model training and evaluation. Primary hyperparameters are included in the repo linked above.
102
-
103
-
104
- ## Environmental Impact
105
-
106
- - **Hardware Type:** Nvidia H100 Hopper nodes
107
- - **Hours used:** 400
108
- - **Cloud Provider:** private cloud
109
- - **Carbon Emitted:** 138.24 kg co2 (roughly the equivalent of one car driving from Toronto to Montreal)
110
-
111
- **BibTeX:**
112
-
113
- ```TeX
114
- @inproceedings{kraus2024masked,
115
- title={Masked Autoencoders for Microscopy are Scalable Learners of Cellular Biology},
116
- author={Kraus, Oren and Kenyon-Dean, Kian and Saberian, Saber and Fallah, Maryam and McLean, Peter and Leung, Jess and Sharma, Vasudev and Khan, Ayla and Balakrishnan, Jia and Celik, Safiye and others},
117
- booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
118
- pages={11757--11768},
119
- year={2024}
120
- }
121
  ```
122
 
123
- ## Model Card Contact
 
124
 
125
- - Kian Kenyon-Dean: kian.kd@recursion.com
126
- - Oren Kraus: oren.kraus@recursion.com
127
- - Or, email: info@rxrx.ai
 
1
+ # Masked Autoencoders are Scalable Learners of Cellular Morphology
2
+ Official repo for Recursion's two recently accepted papers:
3
+ - Spotlight full-length paper at [CVPR 2024](https://cvpr.thecvf.com/Conferences/2024/AcceptedPapers) -- Masked Autoencoders for Microscopy are Scalable Learners of Cellular Biology
4
+ - Paper: https://arxiv.org/abs/2404.10242
5
+ - CVPR poster page with video: https://cvpr.thecvf.com/virtual/2024/poster/31565
6
+ - Spotlight workshop paper at [NeurIPS 2023 Generative AI & Biology workshop](https://openreview.net/group?id=NeurIPS.cc/2023/Workshop/GenBio)
7
+ - Paper: https://arxiv.org/abs/2309.16064
8
 
9
+ ![vit_diff_mask_ratios](https://github.com/recursionpharma/maes_microscopy/assets/109550980/c15f46b1-cdb9-41a7-a4af-bdc9684a971d)
10
 
 
 
11
 
12
+ ## Provided code
13
+ See the repo for ingredients required for defining our MAEs. Users seeking to re-implement training will need to stitch together the Encoder and Decoder modules according to their usecase.
14
 
15
+ Furthermore the baseline Vision Transformer architecture backbone used in this work can be built with the following code snippet from Timm:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  ```
17
+ import timm.models.vision_transformer as vit
18
+
19
+ def vit_base_patch16_256(**kwargs):
20
+ default_kwargs = dict(
21
+ img_size=256,
22
+ in_chans=6,
23
+ num_classes=0,
24
+ fc_norm=None,
25
+ class_token=True,
26
+ drop_path_rate=0.1,
27
+ init_values=0.0001,
28
+ block_fn=vit.ParallelScalingBlock,
29
+ qkv_bias=False,
30
+ qk_norm=True,
31
+ )
32
+ for k, v in kwargs.items():
33
+ default_kwargs[k] = v
34
+ return vit.vit_base_patch16_224(**default_kwargs)
 
 
 
 
 
 
35
  ```
36
 
37
+ ## Provided models
38
+ A publicly available model for research can be found via Nvidia's BioNemo platform, which handles inference and auto-scaling: https://www.rxrx.ai/phenom
39
 
40
+ We have partnered with Nvidia to host a publicly-available smaller and more flexible version of the MAE phenomics foundation model, called Phenom-Beta. Interested parties can access it directly through the Nvidia BioNemo API:
41
+ - https://blogs.nvidia.com/blog/drug-discovery-bionemo-generative-ai/
42
+ - https://www.youtube.com/watch?v=Gch6bX1toB0
RxRx3-core_inference.ipynb DELETED
@@ -1,195 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": null,
6
- "id": "5edcb7d2-53dc-4170-9f2f-619c0da0ae4c",
7
- "metadata": {},
8
- "outputs": [],
9
- "source": [
10
- "import torch\n",
11
- "import numpy as np\n",
12
- "from torch.utils.data import DataLoader\n",
13
- "import pandas as pd"
14
- ]
15
- },
16
- {
17
- "cell_type": "markdown",
18
- "id": "f839c8fb-b018-4ab6-86a9-7d5bf7883b45",
19
- "metadata": {},
20
- "source": [
21
- "# Load OpenPhenom"
22
- ]
23
- },
24
- {
25
- "cell_type": "code",
26
- "execution_count": null,
27
- "id": "84b9324d-fde9-4c43-bc5a-eb66cdb4f891",
28
- "metadata": {},
29
- "outputs": [],
30
- "source": [
31
- "# Load model directly\n",
32
- "from huggingface_mae import MAEModel\n",
33
- "open_phenom = MAEModel.from_pretrained(\"recursionpharma/OpenPhenom\")"
34
- ]
35
- },
36
- {
37
- "cell_type": "code",
38
- "execution_count": null,
39
- "id": "57d918c5-78de-4b36-9f46-4652c5da93f2",
40
- "metadata": {},
41
- "outputs": [],
42
- "source": [
43
- "open_phenom.eval()\n",
44
- "cuda_available = torch.cuda.is_available()\n",
45
- "if cuda_available:\n",
46
- " open_phenom.cuda()"
47
- ]
48
- },
49
- {
50
- "cell_type": "markdown",
51
- "id": "7c89d82d-5365-4492-b496-adb3bbd71b32",
52
- "metadata": {},
53
- "source": [
54
- "# Load Rxrx3-core"
55
- ]
56
- },
57
- {
58
- "cell_type": "code",
59
- "execution_count": null,
60
- "id": "deeff3a8-db67-4905-a7e9-c43aad614a84",
61
- "metadata": {},
62
- "outputs": [],
63
- "source": [
64
- "from datasets import load_dataset\n",
65
- "rxrx3_core = load_dataset(\"recursionpharma/rxrx3-core\")['train']"
66
- ]
67
- },
68
- {
69
- "cell_type": "markdown",
70
- "id": "8f2226ce-9415-4dd8-932e-54e4e1bd8c1a",
71
- "metadata": {},
72
- "source": [
73
- "# Infernce loop"
74
- ]
75
- },
76
- {
77
- "cell_type": "code",
78
- "execution_count": null,
79
- "id": "aa1218ab-f9cd-413b-9228-c1146df978be",
80
- "metadata": {},
81
- "outputs": [],
82
- "source": [
83
- "def convert_path_to_well_id(path_str):\n",
84
- " \n",
85
- " return path_str.split('_')[0].replace('/','_').replace('Plate','')\n",
86
- " \n",
87
- "def collate_rxrx3_core(batch):\n",
88
- " \n",
89
- " images = np.stack([np.array(i['jp2']) for i in batch]).reshape(-1,6,512,512)\n",
90
- " images = np.vstack([patch_image(i) for i in images]) # convert to 4 256x256 patches\n",
91
- " images = torch.from_numpy(images)\n",
92
- " well_ids = [convert_path_to_well_id(i['__key__']) for i in batch[::6]]\n",
93
- " return images, well_ids\n",
94
- "\n",
95
- "def iter_border_patches(width, height, patch_size):\n",
96
- " \n",
97
- " x_start, x_end, y_start, y_end = (0, width, 0, height)\n",
98
- "\n",
99
- " for x in range(x_start, x_end - patch_size + 1, patch_size):\n",
100
- " for y in range(y_start, y_end - patch_size + 1, patch_size):\n",
101
- " yield x, y\n",
102
- "\n",
103
- "def patch_image(image_array, patch_size=256):\n",
104
- " \n",
105
- " _, width, height = image_array.shape\n",
106
- " output_patches = []\n",
107
- " patch_count = 0\n",
108
- " for x, y in iter_border_patches(width, height, patch_size):\n",
109
- " patch = image_array[:, y : y + patch_size, x : x + patch_size].copy()\n",
110
- " output_patches.append(patch)\n",
111
- " \n",
112
- " output_patches = np.stack(output_patches)\n",
113
- " \n",
114
- " return output_patches"
115
- ]
116
- },
117
- {
118
- "cell_type": "code",
119
- "execution_count": null,
120
- "id": "de308003-bcfc-4b59-9715-dd884b9b2536",
121
- "metadata": {},
122
- "outputs": [],
123
- "source": [
124
- "# Convert to PyTorch DataLoader\n",
125
- "batch_size = 128\n",
126
- "num_workers = 4\n",
127
- "rxrx3_core_dataloader = DataLoader(rxrx3_core, batch_size=batch_size*6, shuffle=False, \n",
128
- " collate_fn=collate_rxrx3_core, num_workers=num_workers)"
129
- ]
130
- },
131
- {
132
- "cell_type": "code",
133
- "execution_count": null,
134
- "id": "9e3ea6c2-d1aa-4e20-a175-d72ea636153e",
135
- "metadata": {},
136
- "outputs": [],
137
- "source": [
138
- "# Inference loop\n",
139
- "num_features = 384\n",
140
- "n_crops = 4\n",
141
- "well_ids = []\n",
142
- "emb_ind = 0\n",
143
- "embeddings = np.zeros(\n",
144
- " ((len(rxrx3_core_dataloader.dataset)//6), num_features), dtype=np.float32\n",
145
- ")\n",
146
- "forward_pass_counter = 0\n",
147
- "\n",
148
- "for imgs, batch_well_ids in rxrx3_core_dataloader:\n",
149
- "\n",
150
- " if cuda_available:\n",
151
- " with torch.amp.autocast(\"cuda\"), torch.no_grad():\n",
152
- " latent = open_phenom.predict(imgs.cuda())\n",
153
- " else:\n",
154
- " latent = open_phenom.predict(imgs)\n",
155
- " \n",
156
- " latent = latent.view(-1, n_crops, num_features).mean(dim=1) # average over 4 256x256 crops per image\n",
157
- " embeddings[emb_ind : (emb_ind + len(latent))] = latent.detach().cpu().numpy()\n",
158
- " well_ids.extend(batch_well_ids)\n",
159
- "\n",
160
- " emb_ind += len(latent)\n",
161
- " forward_pass_counter += 1\n",
162
- " if forward_pass_counter % 5 == 0:\n",
163
- " print(f\"forward pass {forward_pass_counter} of {len(rxrx3_core_dataloader)} done, wells inferenced {emb_ind}\")\n",
164
- "\n",
165
- "embedding_df = embeddings[:emb_ind]\n",
166
- "embedding_df = pd.DataFrame(embedding_df)\n",
167
- "embedding_df.columns = [f\"feature_{i}\" for i in range(num_features)]\n",
168
- "embedding_df['well_id'] = well_ids\n",
169
- "embedding_df = embedding_df[['well_id']+[f\"feature_{i}\" for i in range(num_features)]]\n",
170
- "embedding_df.to_parquet('OpenPhenom_rxrx3-core_embeddings.parquet')"
171
- ]
172
- }
173
- ],
174
- "metadata": {
175
- "kernelspec": {
176
- "display_name": "photo2",
177
- "language": "python",
178
- "name": "photo2"
179
- },
180
- "language_info": {
181
- "codemirror_mode": {
182
- "name": "ipython",
183
- "version": 3
184
- },
185
- "file_extension": ".py",
186
- "mimetype": "text/x-python",
187
- "name": "python",
188
- "nbconvert_exporter": "python",
189
- "pygments_lexer": "ipython3",
190
- "version": "3.10.14"
191
- }
192
- },
193
- "nbformat": 4,
194
- "nbformat_minor": 5
195
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
__init__.py DELETED
File without changes
config.json CHANGED
@@ -1,9 +1,5 @@
1
  {
2
  "_attn_implementation_autoset": true,
3
- "auto_map": {
4
- "AutoModel": "huggingface_mae.MAEModel",
5
- "AutoConfig": "huggingface_mae.MAEConfig"
6
- },
7
  "apply_loss_unmasked": false,
8
  "architectures": [
9
  "MAEModel"
 
1
  {
2
  "_attn_implementation_autoset": true,
 
 
 
 
3
  "apply_loss_unmasked": false,
4
  "architectures": [
5
  "MAEModel"
generate_reconstructions.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
huggingface_mae.py CHANGED
@@ -4,13 +4,12 @@ import torch
4
  import torch.nn as nn
5
 
6
  from transformers import PretrainedConfig, PreTrainedModel
7
- from transformers.utils import cached_file
8
 
9
- from .loss import FourierLoss
10
- from .normalizer import Normalizer
11
- from .mae_modules import CAMAEDecoder, MAEDecoder, MAEEncoder
12
- from .mae_utils import flatten_images
13
- from .vit import (
14
  generate_2d_sincos_pos_embeddings,
15
  sincos_positional_encoding_vit,
16
  vit_small_patch16_256,
@@ -286,9 +285,9 @@ class MAEModel(PreTrainedModel):
286
  def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs):
287
  filename = kwargs.pop("filename", "model.safetensors")
288
 
 
289
  config = MAEConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
290
- modelpath = cached_file(pretrained_model_name_or_path, filename=filename)
291
  state_dict = torch.load(modelpath, map_location="cpu")
292
- model = cls(config)
293
  model.load_state_dict(state_dict["state_dict"])
294
  return model
 
4
  import torch.nn as nn
5
 
6
  from transformers import PretrainedConfig, PreTrainedModel
 
7
 
8
+ from loss import FourierLoss
9
+ from normalizer import Normalizer
10
+ from mae_modules import CAMAEDecoder, MAEDecoder, MAEEncoder
11
+ from mae_utils import flatten_images
12
+ from vit import (
13
  generate_2d_sincos_pos_embeddings,
14
  sincos_positional_encoding_vit,
15
  vit_small_patch16_256,
 
285
  def from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs):
286
  filename = kwargs.pop("filename", "model.safetensors")
287
 
288
+ modelpath = f"{pretrained_model_name_or_path}/{filename}"
289
  config = MAEConfig.from_pretrained(pretrained_model_name_or_path, **kwargs)
 
290
  state_dict = torch.load(modelpath, map_location="cpu")
291
+ model = cls(config, *model_args, **kwargs)
292
  model.load_state_dict(state_dict["state_dict"])
293
  return model
mae_modules.py CHANGED
@@ -7,8 +7,8 @@ import torch.nn as nn
7
  from timm.models.helpers import checkpoint_seq
8
  from timm.models.vision_transformer import Block, Mlp, VisionTransformer
9
 
10
- from .masking import transformer_random_masking
11
- from .vit import channel_agnostic_vit
12
 
13
  # If interested in training new MAEs, combine an encoder and decoder into a new module, and you should
14
  # leverage the flattening and unflattening utilities as needed from mae_utils.py.
 
7
  from timm.models.helpers import checkpoint_seq
8
  from timm.models.vision_transformer import Block, Mlp, VisionTransformer
9
 
10
+ from masking import transformer_random_masking
11
+ from vit import channel_agnostic_vit
12
 
13
  # If interested in training new MAEs, combine an encoder and decoder into a new module, and you should
14
  # leverage the flattening and unflattening utilities as needed from mae_utils.py.
model.safetensors DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f6e5f1c97101331b1574c9e4b99623260191c55eea5d98e40460849c0e4c4d47
3
- size 712434294
 
 
 
 
test_huggingface_mae.py CHANGED
@@ -1,16 +1,17 @@
1
  import pytest
2
  import torch
3
 
4
- # huggingface_openphenom_model_dir = "."
5
- huggingface_modelpath = "recursionpharma/OpenPhenom"
6
 
7
- from .huggingface_mae import MAEModel
 
8
 
9
 
10
  @pytest.fixture
11
  def huggingface_model():
12
- # This step downloads the model to a local cache, takes a bit to run
13
- huggingface_model = MAEModel.from_pretrained(huggingface_modelpath)
 
14
  huggingface_model.eval()
15
  return huggingface_model
16
 
 
1
  import pytest
2
  import torch
3
 
4
+ from huggingface_mae import MAEModel
 
5
 
6
+ huggingface_phenombeta_model_dir = "."
7
+ # huggingface_modelpath = "recursionpharma/test-pb-model"
8
 
9
 
10
  @pytest.fixture
11
  def huggingface_model():
12
+ # Make sure you have the model/config downloaded from https://huggingface.co/recursionpharma/test-pb-model to this directory
13
+ # huggingface-cli download recursionpharma/test-pb-model --local-dir=.
14
+ huggingface_model = MAEModel.from_pretrained(huggingface_phenombeta_model_dir)
15
  huggingface_model.eval()
16
  return huggingface_model
17