muzairkhattak commited on
Commit
37b3db0
·
1 Parent(s): fcf60fb

first commit for the demo

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. CODE_OF_CONDUCT.md +80 -0
  2. CONTRIBUTING.md +31 -0
  3. HISTORY.md +10 -0
  4. LICENSE +399 -0
  5. MANIFEST.in +3 -0
  6. Makefile +9 -0
  7. app.py.py +135 -0
  8. clipeval/dataset_catalog.json +157 -0
  9. clipeval/datasets.py +718 -0
  10. clipeval/eval_zeroshot.py +359 -0
  11. clipeval/labels.json +0 -0
  12. clipeval/radimagenet_labels.txt +165 -0
  13. clipeval/templates.json +353 -0
  14. configs.py +105 -0
  15. constants.py +0 -0
  16. data_prepration_scripts/CheXpert/webdataset_chexpert.py +74 -0
  17. data_prepration_scripts/ChestX-ray8/chest-xray_8_webdataset.py +72 -0
  18. data_prepration_scripts/LLaVA-Med/llava_med_alignment_webdataset.py +76 -0
  19. data_prepration_scripts/LLaVA-Med/llava_med_instruct_webdataset.py +104 -0
  20. data_prepration_scripts/MIMIC-CXR/webdataset_mimic_cxr.py +83 -0
  21. data_prepration_scripts/Openi/openi_webdataset.py +70 -0
  22. data_prepration_scripts/PMC-OA/pmc_oa_webdataset.py +64 -0
  23. data_prepration_scripts/Quilt-1M/quilt_1m_webdataset.py +70 -0
  24. data_prepration_scripts/ROCOV2/roco_webdataset.py +65 -0
  25. data_prepration_scripts/RadImageNet/radimagenet_webdataset.py +72 -0
  26. data_prepration_scripts/Retinal-Datasets/retina_webdataset_part1.py +86 -0
  27. data_prepration_scripts/Retinal-Datasets/retina_webdataset_part2.py +105 -0
  28. data_prepration_scripts/Retinal-Datasets/retina_webdataset_part3.py +77 -0
  29. getting_started_unimed_clip.ipynb +227 -0
  30. local_data/08_ODIR200x3.csv +601 -0
  31. local_data/13_FIVES.csv +801 -0
  32. local_data/25_REFUGE.csv +401 -0
  33. local_data/chexpert-5x200.csv +0 -0
  34. metadata.json +0 -0
  35. openclip_CITATION.cff +36 -0
  36. openclip_LICENSE +23 -0
  37. requirements.txt +9 -0
  38. run_configs_400m.py +136 -0
  39. setup.py +59 -0
  40. src/open_clip/__init__.py +8 -0
  41. src/open_clip/bpe_simple_vocab_16e6.txt.gz +3 -0
  42. src/open_clip/factory.py +175 -0
  43. src/open_clip/hf_configs.py +67 -0
  44. src/open_clip/hf_model.py +193 -0
  45. src/open_clip/loss.py +123 -0
  46. src/open_clip/model.py +574 -0
  47. src/open_clip/model_configs/RN101-quickgelu.json +22 -0
  48. src/open_clip/model_configs/RN101.json +21 -0
  49. src/open_clip/model_configs/RN50-quickgelu.json +22 -0
  50. src/open_clip/model_configs/RN50.json +21 -0
CODE_OF_CONDUCT.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to make participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies within all project spaces, and it also applies when
49
+ an individual is representing the project or its community in public spaces.
50
+ Examples of representing a project or community include using an official
51
+ project e-mail address, posting via an official social media account, or acting
52
+ as an appointed representative at an online or offline event. Representation of
53
+ a project may be further defined and clarified by project maintainers.
54
+
55
+ This Code of Conduct also applies outside the project spaces when there is a
56
+ reasonable belief that an individual's behavior may have a negative impact on
57
+ the project or its community.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported by contacting the project team at <[email protected]>. All
63
+ complaints will be reviewed and investigated and will result in a response that
64
+ is deemed necessary and appropriate to the circumstances. The project team is
65
+ obligated to maintain confidentiality with regard to the reporter of an incident.
66
+ Further details of specific enforcement policies may be posted separately.
67
+
68
+ Project maintainers who do not follow or enforce the Code of Conduct in good
69
+ faith may face temporary or permanent repercussions as determined by other
70
+ members of the project's leadership.
71
+
72
+ ## Attribution
73
+
74
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
75
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
76
+
77
+ [homepage]: https://www.contributor-covenant.org
78
+
79
+ For answers to common questions about this code of conduct, see
80
+ https://www.contributor-covenant.org/faq
CONTRIBUTING.md ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to CiT
2
+ We want to make contributing to this project as easy and transparent as
3
+ possible.
4
+
5
+ ## Pull Requests
6
+ We actively welcome your pull requests.
7
+
8
+ 1. Fork the repo and create your branch from `main`.
9
+ 2. If you've added code that should be tested, add tests.
10
+ 3. If you've changed APIs, update the documentation.
11
+ 4. Ensure the test suite passes.
12
+ 5. Make sure your code lints.
13
+ 6. If you haven't already, complete the Contributor License Agreement ("CLA").
14
+
15
+ ## Contributor License Agreement ("CLA")
16
+ In order to accept your pull request, we need you to submit a CLA. You only need
17
+ to do this once to work on any of Facebook's open source projects.
18
+
19
+ Complete your CLA here: <https://code.facebook.com/cla>
20
+
21
+ ## Issues
22
+ We use GitHub issues to track public bugs. Please ensure your description is
23
+ clear and has sufficient instructions to be able to reproduce the issue.
24
+
25
+ Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
26
+ disclosure of security bugs. In those cases, please go through the process
27
+ outlined on that page and do not file a public issue.
28
+
29
+ ## License
30
+ By contributing to CiT, you agree that your contributions will be licensed
31
+ under the LICENSE file in the root directory of this source tree.
HISTORY.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ ## 1.2.0
2
+
3
+ * ViT-B/32 trained on Laion2B-en
4
+ * add missing openai RN50x64 model
5
+
6
+ ## 1.1.1
7
+
8
+ * ViT-B/16+
9
+ * Add grad checkpointing support
10
+ * more robust data loader
LICENSE ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Attribution-NonCommercial 4.0 International
2
+
3
+ =======================================================================
4
+
5
+ Creative Commons Corporation ("Creative Commons") is not a law firm and
6
+ does not provide legal services or legal advice. Distribution of
7
+ Creative Commons public licenses does not create a lawyer-client or
8
+ other relationship. Creative Commons makes its licenses and related
9
+ information available on an "as-is" basis. Creative Commons gives no
10
+ warranties regarding its licenses, any material licensed under their
11
+ terms and conditions, or any related information. Creative Commons
12
+ disclaims all liability for damages resulting from their use to the
13
+ fullest extent possible.
14
+
15
+ Using Creative Commons Public Licenses
16
+
17
+ Creative Commons public licenses provide a standard set of terms and
18
+ conditions that creators and other rights holders may use to share
19
+ original works of authorship and other material subject to copyright
20
+ and certain other rights specified in the public license below. The
21
+ following considerations are for informational purposes only, are not
22
+ exhaustive, and do not form part of our licenses.
23
+
24
+ Considerations for licensors: Our public licenses are
25
+ intended for use by those authorized to give the public
26
+ permission to use material in ways otherwise restricted by
27
+ copyright and certain other rights. Our licenses are
28
+ irrevocable. Licensors should read and understand the terms
29
+ and conditions of the license they choose before applying it.
30
+ Licensors should also secure all rights necessary before
31
+ applying our licenses so that the public can reuse the
32
+ material as expected. Licensors should clearly mark any
33
+ material not subject to the license. This includes other CC-
34
+ licensed material, or material used under an exception or
35
+ limitation to copyright. More considerations for licensors:
36
+ wiki.creativecommons.org/Considerations_for_licensors
37
+
38
+ Considerations for the public: By using one of our public
39
+ licenses, a licensor grants the public permission to use the
40
+ licensed material under specified terms and conditions. If
41
+ the licensor's permission is not necessary for any reason--for
42
+ example, because of any applicable exception or limitation to
43
+ copyright--then that use is not regulated by the license. Our
44
+ licenses grant only permissions under copyright and certain
45
+ other rights that a licensor has authority to grant. Use of
46
+ the licensed material may still be restricted for other
47
+ reasons, including because others have copyright or other
48
+ rights in the material. A licensor may make special requests,
49
+ such as asking that all changes be marked or described.
50
+ Although not required by our licenses, you are encouraged to
51
+ respect those requests where reasonable. More_considerations
52
+ for the public:
53
+ wiki.creativecommons.org/Considerations_for_licensees
54
+
55
+ =======================================================================
56
+
57
+ Creative Commons Attribution-NonCommercial 4.0 International Public
58
+ License
59
+
60
+ By exercising the Licensed Rights (defined below), You accept and agree
61
+ to be bound by the terms and conditions of this Creative Commons
62
+ Attribution-NonCommercial 4.0 International Public License ("Public
63
+ License"). To the extent this Public License may be interpreted as a
64
+ contract, You are granted the Licensed Rights in consideration of Your
65
+ acceptance of these terms and conditions, and the Licensor grants You
66
+ such rights in consideration of benefits the Licensor receives from
67
+ making the Licensed Material available under these terms and
68
+ conditions.
69
+
70
+ Section 1 -- Definitions.
71
+
72
+ a. Adapted Material means material subject to Copyright and Similar
73
+ Rights that is derived from or based upon the Licensed Material
74
+ and in which the Licensed Material is translated, altered,
75
+ arranged, transformed, or otherwise modified in a manner requiring
76
+ permission under the Copyright and Similar Rights held by the
77
+ Licensor. For purposes of this Public License, where the Licensed
78
+ Material is a musical work, performance, or sound recording,
79
+ Adapted Material is always produced where the Licensed Material is
80
+ synched in timed relation with a moving image.
81
+
82
+ b. Adapter's License means the license You apply to Your Copyright
83
+ and Similar Rights in Your contributions to Adapted Material in
84
+ accordance with the terms and conditions of this Public License.
85
+
86
+ c. Copyright and Similar Rights means copyright and/or similar rights
87
+ closely related to copyright including, without limitation,
88
+ performance, broadcast, sound recording, and Sui Generis Database
89
+ Rights, without regard to how the rights are labeled or
90
+ categorized. For purposes of this Public License, the rights
91
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
92
+ Rights.
93
+ d. Effective Technological Measures means those measures that, in the
94
+ absence of proper authority, may not be circumvented under laws
95
+ fulfilling obligations under Article 11 of the WIPO Copyright
96
+ Treaty adopted on December 20, 1996, and/or similar international
97
+ agreements.
98
+
99
+ e. Exceptions and Limitations means fair use, fair dealing, and/or
100
+ any other exception or limitation to Copyright and Similar Rights
101
+ that applies to Your use of the Licensed Material.
102
+
103
+ f. Licensed Material means the artistic or literary work, database,
104
+ or other material to which the Licensor applied this Public
105
+ License.
106
+
107
+ g. Licensed Rights means the rights granted to You subject to the
108
+ terms and conditions of this Public License, which are limited to
109
+ all Copyright and Similar Rights that apply to Your use of the
110
+ Licensed Material and that the Licensor has authority to license.
111
+
112
+ h. Licensor means the individual(s) or entity(ies) granting rights
113
+ under this Public License.
114
+
115
+ i. NonCommercial means not primarily intended for or directed towards
116
+ commercial advantage or monetary compensation. For purposes of
117
+ this Public License, the exchange of the Licensed Material for
118
+ other material subject to Copyright and Similar Rights by digital
119
+ file-sharing or similar means is NonCommercial provided there is
120
+ no payment of monetary compensation in connection with the
121
+ exchange.
122
+
123
+ j. Share means to provide material to the public by any means or
124
+ process that requires permission under the Licensed Rights, such
125
+ as reproduction, public display, public performance, distribution,
126
+ dissemination, communication, or importation, and to make material
127
+ available to the public including in ways that members of the
128
+ public may access the material from a place and at a time
129
+ individually chosen by them.
130
+
131
+ k. Sui Generis Database Rights means rights other than copyright
132
+ resulting from Directive 96/9/EC of the European Parliament and of
133
+ the Council of 11 March 1996 on the legal protection of databases,
134
+ as amended and/or succeeded, as well as other essentially
135
+ equivalent rights anywhere in the world.
136
+
137
+ l. You means the individual or entity exercising the Licensed Rights
138
+ under this Public License. Your has a corresponding meaning.
139
+
140
+ Section 2 -- Scope.
141
+
142
+ a. License grant.
143
+
144
+ 1. Subject to the terms and conditions of this Public License,
145
+ the Licensor hereby grants You a worldwide, royalty-free,
146
+ non-sublicensable, non-exclusive, irrevocable license to
147
+ exercise the Licensed Rights in the Licensed Material to:
148
+
149
+ a. reproduce and Share the Licensed Material, in whole or
150
+ in part, for NonCommercial purposes only; and
151
+
152
+ b. produce, reproduce, and Share Adapted Material for
153
+ NonCommercial purposes only.
154
+
155
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
156
+ Exceptions and Limitations apply to Your use, this Public
157
+ License does not apply, and You do not need to comply with
158
+ its terms and conditions.
159
+
160
+ 3. Term. The term of this Public License is specified in Section
161
+ 6(a).
162
+
163
+ 4. Media and formats; technical modifications allowed. The
164
+ Licensor authorizes You to exercise the Licensed Rights in
165
+ all media and formats whether now known or hereafter created,
166
+ and to make technical modifications necessary to do so. The
167
+ Licensor waives and/or agrees not to assert any right or
168
+ authority to forbid You from making technical modifications
169
+ necessary to exercise the Licensed Rights, including
170
+ technical modifications necessary to circumvent Effective
171
+ Technological Measures. For purposes of this Public License,
172
+ simply making modifications authorized by this Section 2(a)
173
+ (4) never produces Adapted Material.
174
+
175
+ 5. Downstream recipients.
176
+
177
+ a. Offer from the Licensor -- Licensed Material. Every
178
+ recipient of the Licensed Material automatically
179
+ receives an offer from the Licensor to exercise the
180
+ Licensed Rights under the terms and conditions of this
181
+ Public License.
182
+
183
+ b. No downstream restrictions. You may not offer or impose
184
+ any additional or different terms or conditions on, or
185
+ apply any Effective Technological Measures to, the
186
+ Licensed Material if doing so restricts exercise of the
187
+ Licensed Rights by any recipient of the Licensed
188
+ Material.
189
+
190
+ 6. No endorsement. Nothing in this Public License constitutes or
191
+ may be construed as permission to assert or imply that You
192
+ are, or that Your use of the Licensed Material is, connected
193
+ with, or sponsored, endorsed, or granted official status by,
194
+ the Licensor or others designated to receive attribution as
195
+ provided in Section 3(a)(1)(A)(i).
196
+
197
+ b. Other rights.
198
+
199
+ 1. Moral rights, such as the right of integrity, are not
200
+ licensed under this Public License, nor are publicity,
201
+ privacy, and/or other similar personality rights; however, to
202
+ the extent possible, the Licensor waives and/or agrees not to
203
+ assert any such rights held by the Licensor to the limited
204
+ extent necessary to allow You to exercise the Licensed
205
+ Rights, but not otherwise.
206
+
207
+ 2. Patent and trademark rights are not licensed under this
208
+ Public License.
209
+
210
+ 3. To the extent possible, the Licensor waives any right to
211
+ collect royalties from You for the exercise of the Licensed
212
+ Rights, whether directly or through a collecting society
213
+ under any voluntary or waivable statutory or compulsory
214
+ licensing scheme. In all other cases the Licensor expressly
215
+ reserves any right to collect such royalties, including when
216
+ the Licensed Material is used other than for NonCommercial
217
+ purposes.
218
+
219
+ Section 3 -- License Conditions.
220
+
221
+ Your exercise of the Licensed Rights is expressly made subject to the
222
+ following conditions.
223
+
224
+ a. Attribution.
225
+
226
+ 1. If You Share the Licensed Material (including in modified
227
+ form), You must:
228
+
229
+ a. retain the following if it is supplied by the Licensor
230
+ with the Licensed Material:
231
+
232
+ i. identification of the creator(s) of the Licensed
233
+ Material and any others designated to receive
234
+ attribution, in any reasonable manner requested by
235
+ the Licensor (including by pseudonym if
236
+ designated);
237
+
238
+ ii. a copyright notice;
239
+
240
+ iii. a notice that refers to this Public License;
241
+
242
+ iv. a notice that refers to the disclaimer of
243
+ warranties;
244
+
245
+ v. a URI or hyperlink to the Licensed Material to the
246
+ extent reasonably practicable;
247
+
248
+ b. indicate if You modified the Licensed Material and
249
+ retain an indication of any previous modifications; and
250
+
251
+ c. indicate the Licensed Material is licensed under this
252
+ Public License, and include the text of, or the URI or
253
+ hyperlink to, this Public License.
254
+
255
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
256
+ reasonable manner based on the medium, means, and context in
257
+ which You Share the Licensed Material. For example, it may be
258
+ reasonable to satisfy the conditions by providing a URI or
259
+ hyperlink to a resource that includes the required
260
+ information.
261
+
262
+ 3. If requested by the Licensor, You must remove any of the
263
+ information required by Section 3(a)(1)(A) to the extent
264
+ reasonably practicable.
265
+
266
+ 4. If You Share Adapted Material You produce, the Adapter's
267
+ License You apply must not prevent recipients of the Adapted
268
+ Material from complying with this Public License.
269
+
270
+ Section 4 -- Sui Generis Database Rights.
271
+
272
+ Where the Licensed Rights include Sui Generis Database Rights that
273
+ apply to Your use of the Licensed Material:
274
+
275
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
276
+ to extract, reuse, reproduce, and Share all or a substantial
277
+ portion of the contents of the database for NonCommercial purposes
278
+ only;
279
+
280
+ b. if You include all or a substantial portion of the database
281
+ contents in a database in which You have Sui Generis Database
282
+ Rights, then the database in which You have Sui Generis Database
283
+ Rights (but not its individual contents) is Adapted Material; and
284
+
285
+ c. You must comply with the conditions in Section 3(a) if You Share
286
+ all or a substantial portion of the contents of the database.
287
+
288
+ For the avoidance of doubt, this Section 4 supplements and does not
289
+ replace Your obligations under this Public License where the Licensed
290
+ Rights include other Copyright and Similar Rights.
291
+
292
+ Section 5 -- Disclaimer of Warranties and Limitation of Liability.
293
+
294
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
295
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
296
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
297
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
298
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
299
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
300
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
301
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
302
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
303
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
304
+
305
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
306
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
307
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
308
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
309
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
310
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
311
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
312
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
313
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
314
+
315
+ c. The disclaimer of warranties and limitation of liability provided
316
+ above shall be interpreted in a manner that, to the extent
317
+ possible, most closely approximates an absolute disclaimer and
318
+ waiver of all liability.
319
+
320
+ Section 6 -- Term and Termination.
321
+
322
+ a. This Public License applies for the term of the Copyright and
323
+ Similar Rights licensed here. However, if You fail to comply with
324
+ this Public License, then Your rights under this Public License
325
+ terminate automatically.
326
+
327
+ b. Where Your right to use the Licensed Material has terminated under
328
+ Section 6(a), it reinstates:
329
+
330
+ 1. automatically as of the date the violation is cured, provided
331
+ it is cured within 30 days of Your discovery of the
332
+ violation; or
333
+
334
+ 2. upon express reinstatement by the Licensor.
335
+
336
+ For the avoidance of doubt, this Section 6(b) does not affect any
337
+ right the Licensor may have to seek remedies for Your violations
338
+ of this Public License.
339
+
340
+ c. For the avoidance of doubt, the Licensor may also offer the
341
+ Licensed Material under separate terms or conditions or stop
342
+ distributing the Licensed Material at any time; however, doing so
343
+ will not terminate this Public License.
344
+
345
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
346
+ License.
347
+
348
+ Section 7 -- Other Terms and Conditions.
349
+
350
+ a. The Licensor shall not be bound by any additional or different
351
+ terms or conditions communicated by You unless expressly agreed.
352
+
353
+ b. Any arrangements, understandings, or agreements regarding the
354
+ Licensed Material not stated herein are separate from and
355
+ independent of the terms and conditions of this Public License.
356
+
357
+ Section 8 -- Interpretation.
358
+
359
+ a. For the avoidance of doubt, this Public License does not, and
360
+ shall not be interpreted to, reduce, limit, restrict, or impose
361
+ conditions on any use of the Licensed Material that could lawfully
362
+ be made without permission under this Public License.
363
+
364
+ b. To the extent possible, if any provision of this Public License is
365
+ deemed unenforceable, it shall be automatically reformed to the
366
+ minimum extent necessary to make it enforceable. If the provision
367
+ cannot be reformed, it shall be severed from this Public License
368
+ without affecting the enforceability of the remaining terms and
369
+ conditions.
370
+
371
+ c. No term or condition of this Public License will be waived and no
372
+ failure to comply consented to unless expressly agreed to by the
373
+ Licensor.
374
+
375
+ d. Nothing in this Public License constitutes or may be interpreted
376
+ as a limitation upon, or waiver of, any privileges and immunities
377
+ that apply to the Licensor or You, including from the legal
378
+ processes of any jurisdiction or authority.
379
+
380
+ =======================================================================
381
+
382
+ Creative Commons is not a party to its public
383
+ licenses. Notwithstanding, Creative Commons may elect to apply one of
384
+ its public licenses to material it publishes and in those instances
385
+ will be considered the “Licensor.” The text of the Creative Commons
386
+ public licenses is dedicated to the public domain under the CC0 Public
387
+ Domain Dedication. Except for the limited purpose of indicating that
388
+ material is shared under a Creative Commons public license or as
389
+ otherwise permitted by the Creative Commons policies published at
390
+ creativecommons.org/policies, Creative Commons does not authorize the
391
+ use of the trademark "Creative Commons" or any other trademark or logo
392
+ of Creative Commons without its prior written consent including,
393
+ without limitation, in connection with any unauthorized modifications
394
+ to any of its public licenses or any other arrangements,
395
+ understandings, or agreements concerning use of licensed material. For
396
+ the avoidance of doubt, this paragraph does not form part of the
397
+ public licenses.
398
+
399
+ Creative Commons may be contacted at creativecommons.org.
MANIFEST.in ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ include src/open_clip/bpe_simple_vocab_16e6.txt.gz
2
+ include src/open_clip/model_configs/*.json
3
+
Makefile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ install: ## [Local development] Upgrade pip, install requirements, install package.
2
+ python -m pip install -U pip
3
+ python -m pip install -e .
4
+
5
+ install-dev: ## [Local development] Install test requirements
6
+ python -m pip install -r requirements-test.txt
7
+
8
+ test: ## [Local development] Run unit tests
9
+ python -m pytest -x -s -v tests
app.py.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ # Switch path to root of project
4
+ import os
5
+ import sys
6
+ # Get the current working directory
7
+ current_dir = os.getcwd()
8
+ src_path = os.path.join(current_dir, 'src')
9
+ os.chdir(src_path)
10
+ # Add src directory to sys.path
11
+ sys.path.append(src_path)
12
+ from open_clip import create_model_and_transforms
13
+ from huggingface_hub import hf_hub_download
14
+ from open_clip import HFTokenizer
15
+ import torch
16
+
17
+ class create_unimed_clip_model:
18
+ def __init__(self, model_name):
19
+ # self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
20
+ self.device = 'cpu'
21
+ mean = (0.48145466, 0.4578275, 0.40821073) # OpenAI dataset mean
22
+ std = (0.26862954, 0.26130258, 0.27577711) # OpenAI dataset std
23
+ if model_name == "ViT/B-16":
24
+ # Download the weights
25
+ weights_path = hf_hub_download(
26
+ repo_id="UzairK/unimed-clip-vit-b16",
27
+ filename="unimed-clip-vit-b16.pt"
28
+ )
29
+ self.pretrained = weights_path # Path to pretrained weights
30
+ self.text_encoder_name = "microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract"
31
+ self.model_name = "ViT-B-16-quickgelu"
32
+ elif model_name == 'ViT/L-14@336px-base-text':
33
+ # Download the weights
34
+ self.model_name = "ViT-L-14-336-quickgelu"
35
+ weights_path = hf_hub_download(
36
+ repo_id="UzairK/unimed_clip_vit_l14_base_text_encoder",
37
+ filename="unimed_clip_vit_l14_base_text_encoder.pt"
38
+ )
39
+ self.pretrained = weights_path # Path to pretrained weights
40
+ self.text_encoder_name = "microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract"
41
+ self.tokenizer = HFTokenizer(
42
+ self.text_encoder_name,
43
+ context_length=256,
44
+ **{},
45
+ )
46
+ self.model, _, self.processor = create_model_and_transforms(
47
+ self.model_name,
48
+ self.pretrained,
49
+ precision='amp',
50
+ device=self.device,
51
+ force_quick_gelu=True,
52
+ pretrained_image=False,
53
+ mean=mean, std=std,
54
+ inmem=True,
55
+ text_encoder_name=self.text_encoder_name,
56
+ )
57
+
58
+ def __call__(self, input_image, candidate_labels, hypothesis_template):
59
+ # Preprocess input
60
+ input_image = self.processor(input_image).unsqueeze(0).to(self.device)
61
+ if hypothesis_template == "":
62
+ texts = [
63
+ self.tokenizer(cls_text).to(self.device)
64
+ for cls_text in candidate_labels
65
+ ]
66
+ else:
67
+ texts = [
68
+ self.tokenizer(hypothesis_template + " " + cls_text).to(self.device)
69
+ for cls_text in candidate_labels
70
+ ]
71
+ texts = torch.cat(texts, dim=0)
72
+ # Perform inference
73
+ with torch.no_grad():
74
+ text_features = self.model.encode_text(texts)
75
+ text_features = text_features / text_features.norm(dim=-1, keepdim=True)
76
+ image_features = self.model.encode_image(input_image)
77
+ logits = (image_features @ text_features.t()).softmax(dim=-1).cpu().numpy()
78
+ return {cls_text: float(score) for cls_text, score in zip(candidate_labels, logits[0])}
79
+
80
+ pipes = {
81
+ "ViT/B-16": create_unimed_clip_model(model_name="ViT/B-16"),
82
+ "ViT/L-14@336px-base-text": create_unimed_clip_model(model_name='ViT/L-14@336px-base-text'),
83
+ }
84
+ # Define Gradio inputs and outputs
85
+ inputs = [
86
+ gr.Image(type="pil", label="Image"),
87
+ gr.Textbox(label="Candidate Labels (comma-separated)"),
88
+ gr.Radio(
89
+ choices=["ViT/B-16", "ViT/L-14@336px-base-text"],
90
+ label="Model",
91
+ value="ViT/B-16",
92
+ ),
93
+ gr.Textbox(label="Prompt Template", placeholder="Optional prompt template as prefix",
94
+ value=""),
95
+ ]
96
+ outputs = gr.Label(label="Predicted Scores")
97
+
98
+ def shot(image, labels_text, model_name, hypothesis_template):
99
+ labels = [label.strip(" ") for label in labels_text.strip(" ").split(",")]
100
+ res = pipes[model_name](input_image=image,
101
+ candidate_labels=labels,
102
+ hypothesis_template=hypothesis_template)
103
+ return {single_key: res[single_key] for single_key in res.keys()}
104
+ # Define examples
105
+
106
+ examples = [
107
+ ["../docs/sample_images/brain_MRI.jpg", "CT scan image displaying the anatomical structure of the right kidney., pneumonia is indicated in this chest X-ray image., this is a MRI photo of a brain., this fundus image shows optic nerve damage due to glaucoma., a histopathology slide showing Tumor, Cardiomegaly is evident in the X-ray image of the chest.", "ViT/B-16", ""],
108
+ ["../docs/sample_images/ct_scan_right_kidney.jpg",
109
+ "CT scan image displaying the anatomical structure of the right kidney., pneumonia is indicated in this chest X-ray image., this is a MRI photo of a brain., this fundus image shows optic nerve damage due to glaucoma., a histopathology slide showing Tumor, Cardiomegaly is evident in the X-ray image of the chest.",
110
+ "ViT/B-16", ""],
111
+ ["../docs/sample_images/retina_glaucoma.jpg",
112
+ "CT scan image displaying the anatomical structure of the right kidney., pneumonia is indicated in this chest X-ray image., this is a MRI photo of a brain., this fundus image shows optic nerve damage due to glaucoma., a histopathology slide showing Tumor, Cardiomegaly is evident in the X-ray image of the chest.",
113
+ "ViT/B-16", ""],
114
+ ["../docs/sample_images/tumor_histo_pathology.jpg",
115
+ "CT scan image displaying the anatomical structure of the right kidney., pneumonia is indicated in this chest X-ray image., this is a MRI photo of a brain., this fundus image shows optic nerve damage due to glaucoma., a histopathology slide showing Tumor, Cardiomegaly is evident in the X-ray image of the chest.",
116
+ "ViT/B-16", ""],
117
+ ["../docs/sample_images/xray_cardiomegaly.jpg",
118
+ "CT scan image displaying the anatomical structure of the right kidney., pneumonia is indicated in this chest X-ray image., this is a MRI photo of a brain., this fundus image shows optic nerve damage due to glaucoma., a histopathology slide showing Tumor, Cardiomegaly is evident in the X-ray image of the chest.",
119
+ "ViT/B-16", ""],
120
+ ["../docs/sample_images//xray_pneumonia.png",
121
+ "CT scan image displaying the anatomical structure of the right kidney., pneumonia is indicated in this chest X-ray image., this is a MRI photo of a brain., this fundus image shows optic nerve damage due to glaucoma., a histopathology slide showing Tumor, Cardiomegaly is evident in the X-ray image of the chest.",
122
+ "ViT/B-16", ""],
123
+ ]
124
+
125
+ iface = gr.Interface(shot,
126
+ inputs,
127
+ outputs,
128
+ examples=examples,
129
+ description="""<p>Demo for UniMed CLIP, a family of strong Medical Contrastive VLMs trained on UniMed-dataset. For more information about our project, refer to our paper and github repository. <br>
130
+ Paper: <a href='https://arxiv.org/abs/2412.10372'>https://arxiv.org/abs/2412.10372</a> <br>
131
+ Github: <a href='https://github.com/mbzuai-oryx/UniMed-CLIP'>https://github.com/mbzuai-oryx/UniMed-CLIP</a> <br><br>
132
+ <b>[DEMO USAGE]</b> To begin with the demo, provide a picture (either upload manually, or select from the given examples) and class labels. Optionally you can also add template as an prefix to the class labels. <br> </p>""",
133
+ title="Zero-shot Medical Image Classification with UniMed-CLIP")
134
+
135
+ iface.launch()
clipeval/dataset_catalog.json ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ { "acl_mri": {
2
+ "path": "/scratch/uzair/med/evaluation_datasets/acl_mri/",
3
+ "type": "special",
4
+ "train": "train",
5
+ "test": "val"
6
+ },
7
+ "meniscal_mri": {
8
+ "path": "/scratch/uzair/med/evaluation_datasets/meniscal_mri/",
9
+ "type": "special",
10
+ "train": "train",
11
+ "test": "val"
12
+ },
13
+
14
+ "breast_us": {
15
+ "path": "/scratch/uzair/med/evaluation_datasets/breast_us/",
16
+ "type": "special",
17
+ "train": "train",
18
+ "test": "val"
19
+ },
20
+ "thyroid_us": {
21
+ "path": "/scratch/uzair/med/evaluation_datasets/thyroid_us/",
22
+ "type": "special",
23
+ "train": "train",
24
+ "test": "val"
25
+ },
26
+ "chexpert-5x200": {
27
+ "path": "/scratch/uzair/med/evaluation_datasets/chexpert/",
28
+ "type": "special",
29
+ "train": "train",
30
+ "test": "val"
31
+ },
32
+ "rsna_pneumonia": {
33
+ "path": "/scratch/uzair/med/evaluation_datasets/rsna_custom_test_set/",
34
+ "type": "special",
35
+ "train": "train",
36
+ "test": "val"
37
+ },
38
+ "radimagenet": {
39
+ "path": "/scratch/uzair/med/evaluation_datasets/",
40
+ "type": "special",
41
+ "train": "train",
42
+ "test": "val"
43
+ },
44
+ "imagenet": {
45
+ "path": "/scratch/uzair/med/evaluation_datasets/talal_datasets/imagenet/images/",
46
+ "type": "imagefolder",
47
+ "train": "train",
48
+ "test": "val"
49
+ },
50
+ "CT_axial": {
51
+ "path": "/scratch/uzair/med/evaluation_datasets/",
52
+ "type": "special",
53
+ "train": "train",
54
+ "test": "val"
55
+ },
56
+ "CT_coronal": {
57
+ "path": "/scratch/uzair/med/evaluation_datasets/",
58
+ "type": "special",
59
+ "train": "train",
60
+ "test": "val"
61
+ },
62
+ "CT_sagittal": {
63
+ "path": "/scratch/uzair/med/evaluation_datasets/",
64
+ "type": "special",
65
+ "train": "train",
66
+ "test": "val"
67
+ },
68
+ "dr_regular": {
69
+ "path": "/scratch/uzair/med/evaluation_datasets/",
70
+ "type": "special",
71
+ "train": "train",
72
+ "test": "val"
73
+ },
74
+ "dr_uwf": {
75
+ "path": "/scratch/uzair/med/evaluation_datasets/",
76
+ "type": "special",
77
+ "train": "train",
78
+ "test": "val"
79
+ },
80
+ "LC25000_lung": {
81
+ "path": "/scratch/uzair/med/evaluation_datasets/LC25000_test/",
82
+ "type": "special",
83
+ "train": "train",
84
+ "test": "val"
85
+ },
86
+ "LC25000_colon": {
87
+ "path": "/scratch/uzair/med/evaluation_datasets/LC25000_test/",
88
+ "type": "special",
89
+ "train": "train",
90
+ "test": "val"
91
+ },
92
+ "PCAM": {
93
+ "path": "/scratch/uzair/med/evaluation_datasets/",
94
+ "type": "special",
95
+ "train": "train",
96
+ "test": "val"
97
+ },
98
+ "NCK_CRC": {
99
+ "path": "/scratch/uzair/med/evaluation_datasets/",
100
+ "type": "special",
101
+ "train": "train",
102
+ "test": "val"
103
+ },
104
+ "BACH": {
105
+ "path": "/scratch/uzair/med/evaluation_datasets/",
106
+ "type": "special",
107
+ "train": "train",
108
+ "test": "val"
109
+ },
110
+ "SICAPv2": {
111
+ "path": "/scratch/uzair/med/evaluation_datasets/",
112
+ "type": "special",
113
+ "train": "train",
114
+ "test": "val"
115
+ },
116
+ "Osteo": {
117
+ "path": "/scratch/uzair/med/evaluation_datasets/",
118
+ "type": "special",
119
+ "train": "train",
120
+ "test": "val"
121
+ },
122
+
123
+ "skin_cancer": {
124
+ "path": "/scratch/uzair/med/evaluation_datasets/",
125
+ "type": "special",
126
+ "train": "train",
127
+ "test": "val"
128
+ },
129
+
130
+ "skin_tumor": {
131
+ "path": "/scratch/uzair/med/evaluation_datasets/",
132
+ "type": "special",
133
+ "train": "train",
134
+ "test": "val"
135
+ },
136
+
137
+ "refuge_retina": {
138
+ "path": "/scratch/uzair/med/evaluation_datasets/",
139
+ "type": "special",
140
+ "train": "train",
141
+ "test": "val"
142
+ },
143
+
144
+ "five_retina": {
145
+ "path": "/scratch/uzair/med/evaluation_datasets/",
146
+ "type": "special",
147
+ "train": "train",
148
+ "test": "val"
149
+ },
150
+
151
+ "odir_retina": {
152
+ "path": "/scratch/uzair/med/evaluation_datasets/",
153
+ "type": "special",
154
+ "train": "train",
155
+ "test": "val"
156
+ }
157
+ }
clipeval/datasets.py ADDED
@@ -0,0 +1,718 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+
4
+ # This source code is licensed under the license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+ from collections import defaultdict
7
+ import json
8
+ import os
9
+ import pickle
10
+ import zipfile
11
+ import pandas as pd
12
+ import numpy as np
13
+ from PIL import Image, ImageFile
14
+ import ast
15
+ import torch
16
+ import random
17
+ from constants import CHEXPERT_COMPETITION_TASKS
18
+ from torchvision import transforms
19
+ from torchvision import datasets as t_datasets
20
+ import ast
21
+
22
+ ImageFile.LOAD_TRUNCATED_IMAGES = True
23
+
24
+
25
+ def pil_loader(path):
26
+ # open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
27
+ with open(path, 'rb') as f:
28
+ img = Image.open(f)
29
+ return img.convert('RGB')
30
+
31
+
32
+ class FileListDataset(torch.utils.data.Dataset):
33
+ def __init__(self, images, labels, transform=None, target_transform=None):
34
+ self.transform = transform
35
+ self.target_transform = target_transform
36
+ self.images = np.load(images)
37
+ self.labels = np.load(labels)
38
+
39
+ def __getitem__(self, index):
40
+ img = pil_loader(self.images[index])
41
+ target = self.labels[index]
42
+
43
+ if self.transform is not None:
44
+ img = self.transform(img)
45
+
46
+ if self.target_transform is not None:
47
+ target = self.target_transform(target)
48
+
49
+ return img, target
50
+
51
+ def __len__(self):
52
+ return len(self.images)
53
+
54
+
55
+ def get_downstream_dataset(catalog, name, is_train, transform):
56
+ entry = catalog[name]
57
+ root = entry['path']
58
+ if entry['type'] == 'imagefolder':
59
+ dataset = t_datasets.ImageFolder(os.path.join(root, entry['train'] if is_train else entry['test']),
60
+ transform=transform)
61
+ elif entry['type'] == 'special':
62
+ if name == 'CIFAR10':
63
+ dataset = t_datasets.CIFAR10(root, train=is_train,
64
+ transform=transform, download=True)
65
+ elif name == 'CIFAR100':
66
+ dataset = t_datasets.CIFAR100(root, train=is_train,
67
+ transform=transform, download=True)
68
+ elif name == 'STL10':
69
+ dataset = t_datasets.STL10(root, split='train' if is_train else 'test',
70
+ transform=transform, download=True)
71
+ elif name == 'MNIST':
72
+ dataset = t_datasets.MNIST(root, train=is_train,
73
+ transform=transform, download=True)
74
+ elif name == 'chexpert-5x200':
75
+ dataset = ZeroShotImageDataset(['chexpert-5x200'], CHEXPERT_COMPETITION_TASKS, transform
76
+ , parent_data_path=root)
77
+ elif name == "radimagenet":
78
+ dataset = RadImageNet(root, transform)
79
+ elif name == "rsna_pneumonia":
80
+ dataset = RSNA_Pneumonia(root, transform)
81
+ elif name == "thyroid_us":
82
+ dataset = thyroid_us_and_breast(root, transform, "thyroid_test_fold1.csv")
83
+ elif name == "breast_us":
84
+ dataset = thyroid_us_and_breast(root, transform, "breast_test_fold1.csv")
85
+ elif name == "meniscal_mri":
86
+ dataset = meniscal_mri(root, transform, "meniscus_test_fold1.csv")
87
+ elif name == 'acl_mri':
88
+ dataset = acl_mri(root, transform, "test_fold1.csv")
89
+ elif name == 'CT_axial':
90
+ dataset = CT_dataset(root, transform, "organs_axial")
91
+ elif name == 'CT_coronal':
92
+ dataset = CT_dataset(root, transform, "organs_coronal")
93
+ elif name == 'CT_sagittal':
94
+ dataset = CT_dataset(root, transform, "organs_sagittal")
95
+ elif name == 'dr_regular':
96
+ dataset = CT_dataset(root, transform, "dr_regular")
97
+ elif name == 'dr_uwf':
98
+ dataset = CT_dataset(root, transform, "dr_uwf")
99
+ elif name == 'LC25000_lung':
100
+ dataset = LC25000(root, transform, "lung")
101
+ elif name == 'LC25000_colon':
102
+ dataset = LC25000(root, transform, "colon")
103
+ elif name == 'PCAM':
104
+ dataset = PCAM(root, transform, "PCam_Test_preprocessed")
105
+ elif name == 'NCK_CRC':
106
+ dataset = NCK_CRC(root, transform, "CRC-VAL-HE-7K")
107
+ elif name == 'BACH':
108
+ dataset = BACH(root, transform, "BACH")
109
+ elif name == 'Osteo':
110
+ dataset = Osteo(root, transform, "Osteosarcoma")
111
+ elif name == 'skin_cancer':
112
+ dataset = Skin_datasets(root, transform, "skin_tumor", 'cancer')
113
+ elif name == 'skin_tumor':
114
+ dataset = Skin_datasets(root, transform, "skin_tumor", 'tumor')
115
+ elif name == 'refuge_retina':
116
+ dataset = Retina_datasets(root, transform, '25_REFUGE.csv')
117
+ elif name == 'five_retina':
118
+ dataset = Retina_datasets(root, transform, '13_FIVES.csv')
119
+ elif name == 'odir_retina':
120
+ dataset = Retina_datasets(root, transform, '08_ODIR200x3.csv')
121
+
122
+ elif entry['type'] == 'filelist':
123
+ path = entry['train'] if is_train else entry['test']
124
+ val_images = os.path.join(root, path + '_images.npy')
125
+ val_labels = os.path.join(root, path + '_labels.npy')
126
+ if name == 'CLEVRCounts':
127
+ target_transform = lambda x: ['count_10', 'count_3', 'count_4', 'count_5', 'count_6', 'count_7', 'count_8',
128
+ 'count_9'].index(x)
129
+ else:
130
+ target_transform = None
131
+ dataset = FileListDataset(val_images, val_labels, transform, target_transform)
132
+ else:
133
+ raise Exception('Unknown dataset')
134
+
135
+ return dataset
136
+
137
+
138
+ class ZeroShotImageDataset(torch.utils.data.Dataset):
139
+ def __init__(self,
140
+ datalist=['chexpert-5x200'],
141
+ class_names=None,
142
+ imgtransform=None,
143
+ parent_data_path="",
144
+ ) -> None:
145
+ '''support data list in mimic-5x200, chexpert-5x200, rsna-balanced-test, covid-test
146
+ args:
147
+ imgtransform: a torchvision transform
148
+ cls_prompts: a dict of prompt sentences, cls:[sent1, sent2, ..],
149
+ '''
150
+ super().__init__()
151
+
152
+ self.transform = imgtransform
153
+
154
+ self.class_names = class_names
155
+ self.parent_data_path = parent_data_path
156
+ # imgpath, subject_id, report, labels...(14 labels)
157
+ df_list = []
158
+ for data in datalist:
159
+ filename = f'./local_data/{data}.csv'
160
+ print('load data from', filename)
161
+ df = pd.read_csv(filename, index_col=0)
162
+ df_list.append(df)
163
+ self.df = pd.concat(df_list, axis=0).reset_index(drop=True)
164
+
165
+ def __getitem__(self, index):
166
+ row = self.df.iloc[index]
167
+ img = Image.open(os.path.join(self.parent_data_path, row.imgpath))
168
+ # img = self._pad_img(img)
169
+ img = self.transform(img)
170
+ label = torch.from_numpy(row[self.class_names].values.astype(np.float_))
171
+ return img, label
172
+
173
+ def _pad_img(self, img, min_size=224, fill_color=0):
174
+ '''pad img to square.
175
+ '''
176
+ x, y = img.size
177
+ size = max(min_size, x, y)
178
+ new_im = Image.new('L', (size, size), fill_color)
179
+ new_im.paste(img, (int((size - x) / 2), int((size - y) / 2)))
180
+ return new_im
181
+
182
+ def __len__(self):
183
+ return len(self.df)
184
+
185
+
186
+ class RadImageNet(torch.utils.data.Dataset):
187
+ def __init__(self, parent_path, transform=None):
188
+ """
189
+ Args:
190
+ csv_file (string): Path to the CSV file containing image paths and labels.
191
+ transform (callable, optional): Optional transform to be applied
192
+ on a sample.
193
+ """
194
+ self.data = pd.read_csv(os.path.join(parent_path, "radimagenet_test_set_formatted.csv"))
195
+ self.transform = transform
196
+ self.parent_data_path = parent_path
197
+
198
+ def __len__(self):
199
+ return len(self.data)
200
+
201
+ def __getitem__(self, idx):
202
+ if torch.is_tensor(idx):
203
+ idx = idx.tolist()
204
+
205
+ img_name = self.data.iloc[idx, 0]
206
+ img_name = ast.literal_eval(img_name)[0]
207
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
208
+ label = self.data.iloc[idx, 1]
209
+
210
+ if self.transform:
211
+ image = self.transform(img)
212
+
213
+ return image, label
214
+
215
+
216
+ class CT_dataset(torch.utils.data.Dataset):
217
+ def __init__(self, parent_path, transform=None, foldername=None):
218
+ """
219
+ Args:
220
+ csv_file (string): Path to the CSV file containing image paths and labels.
221
+ transform (callable, optional): Optional transform to be applied
222
+ on a sample.
223
+ """
224
+ all_data = pd.read_csv(os.path.join(os.path.join(parent_path, foldername),
225
+ "annotations.csv"))
226
+ # Filter the data to only retain the test samples
227
+ self.data = all_data[all_data['split'] == 'test']
228
+ self.transform = transform
229
+ self.parent_data_path = os.path.join(parent_path, foldername)
230
+
231
+ def __len__(self):
232
+ return len(self.data)
233
+
234
+ def __getitem__(self, idx):
235
+ if torch.is_tensor(idx):
236
+ idx = idx.tolist()
237
+
238
+ img_name = self.data.iloc[idx, 0]
239
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
240
+ label = self.data.iloc[idx, 2]
241
+
242
+ if self.transform:
243
+ image = self.transform(img)
244
+
245
+ return image, label
246
+
247
+
248
+ class LC25000(torch.utils.data.Dataset):
249
+ def __init__(self, parent_path, transform=None, split=None):
250
+ """
251
+ Args:
252
+ csv_file (string): Path to the CSV file containing image paths and labels.
253
+ transform (callable, optional): Optional transform to be applied
254
+ on a sample.
255
+ """
256
+ if split == "lung":
257
+ classes = ['lung_aca', 'lung_n', 'lung_scc']
258
+ else:
259
+ classes = ['colon_aca', 'colon_n']
260
+ self.split = split
261
+ self.class_name_folder = []
262
+ self.images = []
263
+ self.labels = []
264
+ for idx, single_class_folder in enumerate(classes):
265
+ images_per_classes = list(os.listdir(os.path.join(parent_path, single_class_folder)))
266
+ self.images = self.images + images_per_classes
267
+ self.labels = self.labels + ([idx] * len(images_per_classes))
268
+ self.class_name_folder = self.class_name_folder + ([single_class_folder] * len(images_per_classes))
269
+ self.transform = transform
270
+ self.parent_data_path = parent_path
271
+ assert len(self.images) == len(self.labels) == len(self.class_name_folder)
272
+
273
+ def __len__(self):
274
+ return len(self.images)
275
+
276
+ def __getitem__(self, idx):
277
+ if torch.is_tensor(idx):
278
+ idx = idx.tolist()
279
+
280
+ img_name = self.images[idx]
281
+ class_folder_name = self.class_name_folder[idx]
282
+ img = Image.open(os.path.join(os.path.join(self.parent_data_path, class_folder_name), img_name))
283
+ label = self.labels[idx]
284
+
285
+ if self.transform:
286
+ image = self.transform(img)
287
+
288
+ return image, label
289
+
290
+
291
+ class PCAM(torch.utils.data.Dataset):
292
+ def __init__(self, parent_path, transform=None, foldername=None):
293
+ """
294
+ Args:
295
+ csv_file (string): Path to the CSV file containing image paths and labels.
296
+ transform (callable, optional): Optional transform to be applied
297
+ on a sample.
298
+ """
299
+ all_files = os.listdir(os.path.join(parent_path, foldername))
300
+ # Filter the data to only retain the test samples
301
+ self.data = all_files
302
+ # Create labels
303
+ labels = []
304
+ for single_file in all_files:
305
+ splitted_label = int(single_file.split("_")[1].split(".")[0])
306
+ labels.append(splitted_label)
307
+ self.labels = labels
308
+ self.transform = transform
309
+ self.parent_data_path = os.path.join(parent_path, foldername)
310
+ assert len(self.labels) == len(self.data)
311
+
312
+ def __len__(self):
313
+ return len(self.data)
314
+
315
+ def __getitem__(self, idx):
316
+ if torch.is_tensor(idx):
317
+ idx = idx.tolist()
318
+
319
+ img_name = self.data[idx]
320
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
321
+ label = self.labels[idx]
322
+
323
+ if self.transform:
324
+ image = self.transform(img)
325
+
326
+ return image, label
327
+
328
+
329
+ class NCK_CRC(torch.utils.data.Dataset):
330
+ def __init__(self, parent_path, transform=None, foldername=None):
331
+ """
332
+ Args:
333
+ csv_file (string): Path to the CSV file containing image paths and labels.
334
+ transform (callable, optional): Optional transform to be applied
335
+ on a sample.
336
+ """
337
+ NCK_CRC_converter = {"ADI": 0,
338
+ "DEB": 1,
339
+ "LYM": 2,
340
+ "MUC": 3,
341
+ "MUS": 4,
342
+ "NORM": 5,
343
+ "STR": 6,
344
+ "TUM": 7,
345
+ }
346
+ all_data = []
347
+ all_class_names = []
348
+ all_labels = []
349
+ folder_names = os.listdir(os.path.join(parent_path, foldername))
350
+ for single_folder in folder_names:
351
+ class_path = os.path.join(os.path.join(parent_path, foldername), single_folder)
352
+ images_inside_folder = os.listdir(class_path)
353
+ class_label = [NCK_CRC_converter[single_folder]] * len(images_inside_folder)
354
+ all_data.extend(images_inside_folder)
355
+ all_labels.extend(class_label)
356
+ all_class_names.extend([single_folder] * len(images_inside_folder))
357
+ # Filter the data to only retain the test samples
358
+ self.data = all_data
359
+ self.labels = all_labels
360
+ self.prefix_name = all_class_names
361
+ assert len(self.data) == len(self.labels) == len(self.prefix_name)
362
+ self.transform = transform
363
+ self.parent_data_path = os.path.join(parent_path, foldername)
364
+
365
+ def __len__(self):
366
+ return len(self.data)
367
+
368
+ def __getitem__(self, idx):
369
+ if torch.is_tensor(idx):
370
+ idx = idx.tolist()
371
+
372
+ img_name = self.data[idx]
373
+ class_name = self.prefix_name[idx]
374
+ label = self.labels[idx]
375
+ img = Image.open(os.path.join(self.parent_data_path, os.path.join(class_name, img_name)))
376
+ if self.transform:
377
+ image = self.transform(img)
378
+
379
+ return image, label
380
+
381
+
382
+ class BACH(torch.utils.data.Dataset):
383
+ def __init__(self, parent_path, transform=None, foldername=None):
384
+ """
385
+ Args:
386
+ csv_file (string): Path to the CSV file containing image paths and labels.
387
+ transform (callable, optional): Optional transform to be applied
388
+ on a sample.
389
+ """
390
+ all_data = pd.read_csv(os.path.join(os.path.join(parent_path, foldername),
391
+ "microscopy_ground_truth.csv"))
392
+
393
+ self.data = all_data
394
+ self.transform = transform
395
+ self.parent_data_path = os.path.join(parent_path, foldername)
396
+ self.label_to_text_mapping = {'Normal': 3, 'Invasive': 2, 'InSitu': 1, "Benign": 0}
397
+
398
+ def __len__(self):
399
+ return len(self.data)
400
+
401
+ def __getitem__(self, idx):
402
+ if torch.is_tensor(idx):
403
+ idx = idx.tolist()
404
+
405
+ img_name = self.data.iloc[idx, 0]
406
+ label_text = self.data.iloc[idx, 1]
407
+ img = Image.open(os.path.join(self.parent_data_path, label_text + "/" + img_name))
408
+
409
+ label = self.label_to_text_mapping[label_text]
410
+
411
+ if self.transform:
412
+ image = self.transform(img)
413
+
414
+ return image, label
415
+
416
+
417
+ class Retina_datasets(torch.utils.data.Dataset):
418
+ def __init__(self, parent_path, transform=None, data=None):
419
+ """
420
+ Args:
421
+ csv_file (string): Path to the CSV file containing image paths and labels.
422
+ transform (callable, optional): Optional transform to be applied
423
+ on a sample.
424
+ """
425
+ filename = f'./local_data/{data}'
426
+ all_data = pd.read_csv(filename)
427
+
428
+ self.data = all_data
429
+ self.transform = transform
430
+ self.parent_data_path = parent_path
431
+
432
+ if data == '25_REFUGE.csv':
433
+ self.label_to_text_mapping = {'no glaucoma': 0, 'glaucoma': 1}
434
+ elif data == '13_FIVES.csv':
435
+ self.label_to_text_mapping = {"age related macular degeneration": 0,
436
+ "diabetic retinopathy": 1,
437
+ "glaucoma": 2,
438
+ "normal": 3}
439
+ elif data == '08_ODIR200x3.csv':
440
+ self.label_to_text_mapping = {"normal": 0,
441
+ "pathologic myopia": 1,
442
+ "cataract": 2}
443
+
444
+ def __len__(self):
445
+ return len(self.data)
446
+
447
+ def __getitem__(self, idx):
448
+ if torch.is_tensor(idx):
449
+ idx = idx.tolist()
450
+
451
+ img_name = self.data.iloc[idx, 1]
452
+ label_text = self.data.iloc[idx, 3] # it is a list
453
+ label_text = ast.literal_eval(label_text)[0]
454
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
455
+
456
+ label = self.label_to_text_mapping[label_text]
457
+
458
+ if self.transform:
459
+ image = self.transform(img)
460
+
461
+ return image, label
462
+
463
+ class Skin_datasets(torch.utils.data.Dataset):
464
+ def __init__(self, parent_path, transform=None, foldername=None, split_type='cancer'):
465
+ """
466
+ Args:
467
+ csv_file (string): Path to the CSV file containing image paths and labels.
468
+ transform (callable, optional): Optional transform to be applied
469
+ on a sample.
470
+ """
471
+ if split_type == 'cancer':
472
+ all_data = pd.read_csv(os.path.join(os.path.join(parent_path, foldername),
473
+ "data/tiles-v2.csv"))
474
+ # Filter the dataset and take only test samples...
475
+ all_data = all_data[all_data['set'] == 'Test']
476
+ self.label_to_text_mapping = {
477
+ "nontumor_skin_necrosis_necrosis": 0,
478
+
479
+ "nontumor_skin_muscle_skeletal":
480
+ 1,
481
+
482
+ "nontumor_skin_sweatglands_sweatglands":
483
+ 2,
484
+
485
+ "nontumor_skin_vessel_vessel":
486
+ 3,
487
+
488
+ "nontumor_skin_elastosis_elastosis":
489
+ 4,
490
+
491
+ "nontumor_skin_chondraltissue_chondraltissue":
492
+ 5,
493
+
494
+ "nontumor_skin_hairfollicle_hairfollicle":
495
+ 6,
496
+ "nontumor_skin_epidermis_epidermis": 7,
497
+ "nontumor_skin_nerves_nerves":
498
+ 8,
499
+
500
+ "nontumor_skin_subcutis_subcutis":
501
+ 9,
502
+
503
+ "nontumor_skin_dermis_dermis":
504
+ 10,
505
+
506
+ "nontumor_skin_sebaceousglands_sebaceousglands":
507
+ 11,
508
+
509
+ "tumor_skin_epithelial_sqcc":
510
+ 12,
511
+
512
+ "tumor_skin_melanoma_melanoma":
513
+ 13,
514
+
515
+ "tumor_skin_epithelial_bcc":
516
+ 14,
517
+
518
+ "tumor_skin_naevus_naevus":
519
+ 15
520
+ }
521
+ else:
522
+ all_data = pd.read_csv(os.path.join(os.path.join(parent_path, foldername),
523
+ "data/SkinTumorSubset.csv"))
524
+ # Filter the dataset and take only test samples...
525
+ all_data = all_data[all_data['set'] == 'Test']
526
+ self.label_to_text_mapping = {"tumor_skin_epithelial_sqcc":
527
+ 0,
528
+
529
+ "tumor_skin_melanoma_melanoma":
530
+ 1,
531
+
532
+ "tumor_skin_epithelial_bcc":
533
+ 2,
534
+
535
+ "tumor_skin_naevus_naevus":
536
+ 3
537
+ }
538
+
539
+ self.data = all_data
540
+ self.transform = transform
541
+ self.parent_data_path = os.path.join(parent_path, foldername)
542
+
543
+ def __len__(self):
544
+ return len(self.data)
545
+
546
+ def __getitem__(self, idx):
547
+ if torch.is_tensor(idx):
548
+ idx = idx.tolist()
549
+
550
+ img_name = self.data.iloc[idx, 1]
551
+ label_text = self.data.iloc[idx, 2]
552
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
553
+
554
+ label = self.label_to_text_mapping[label_text]
555
+
556
+ if self.transform:
557
+ image = self.transform(img)
558
+
559
+ return image, label
560
+
561
+
562
+ class Osteo(torch.utils.data.Dataset):
563
+ def __init__(self, parent_path, transform=None, foldername=None):
564
+ """
565
+ Args:
566
+ csv_file (string): Path to the CSV file containing image paths and labels.
567
+ transform (callable, optional): Optional transform to be applied
568
+ on a sample.
569
+ """
570
+
571
+ all_data = pd.read_csv(os.path.join(os.path.join(parent_path, foldername),
572
+ "annotations_final.csv"))
573
+
574
+ self.data = all_data
575
+ self.transform = transform
576
+ self.parent_data_path = os.path.join(parent_path, foldername)
577
+ self.label_to_text_mapping = {'Viable': 2, 'Non-Tumor': 0, "Non-Viable-Tumor": 1}
578
+
579
+ def __len__(self):
580
+ return len(self.data)
581
+
582
+ def __getitem__(self, idx):
583
+ if torch.is_tensor(idx):
584
+ idx = idx.tolist()
585
+
586
+ img_name = self.data.iloc[idx, 0]
587
+ label_text = self.data.iloc[idx, 1]
588
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
589
+
590
+ label = self.label_to_text_mapping[label_text]
591
+
592
+ if self.transform:
593
+ image = self.transform(img)
594
+
595
+ return image, label
596
+
597
+
598
+ class RSNA_Pneumonia(torch.utils.data.Dataset):
599
+ def __init__(self, parent_path, transform=None):
600
+ """
601
+ Args:
602
+ csv_file (string): Path to the CSV file containing image paths and labels.
603
+ transform (callable, optional): Optional transform to be applied
604
+ on a sample.
605
+ """
606
+ self.data = pd.read_csv(os.path.join(parent_path, "RSNA_pneumonia_balanced_testfile.csv"))
607
+ self.transform = transform
608
+ self.parent_data_path = parent_path
609
+
610
+ def __len__(self):
611
+ return len(self.data)
612
+
613
+ def __getitem__(self, idx):
614
+ if torch.is_tensor(idx):
615
+ idx = idx.tolist()
616
+
617
+ img_name = self.data.iloc[idx, 1]
618
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
619
+ label = self.data.iloc[idx, 2]
620
+
621
+ if self.transform:
622
+ image = self.transform(img)
623
+
624
+ return image, label
625
+
626
+
627
+ class thyroid_us_and_breast(torch.utils.data.Dataset):
628
+ def __init__(self, parent_path, transform, csv_file_name):
629
+ """
630
+ Args:
631
+ csv_file (string): Path to the CSV file containing image paths and labels.
632
+ transform (callable, optional): Optional transform to be applied
633
+ on a sample.
634
+ """
635
+ self.data = pd.read_csv(os.path.join(parent_path, csv_file_name))
636
+ self.transform = transform
637
+ self.parent_data_path = parent_path
638
+ # self.mapping = {'malignant': 0, 'benign': 1}
639
+ self.mapping = {'malignant': 1, 'benign': 0}
640
+
641
+ def __len__(self):
642
+ return len(self.data)
643
+
644
+ def __getitem__(self, idx):
645
+ if torch.is_tensor(idx):
646
+ idx = idx.tolist()
647
+
648
+ img_name = self.data.iloc[idx, 0]
649
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
650
+ label_name = self.data.iloc[idx, 1]
651
+ label = self.mapping[label_name]
652
+
653
+ if self.transform:
654
+ image = self.transform(img)
655
+
656
+ return image, label
657
+
658
+
659
+ class meniscal_mri(torch.utils.data.Dataset):
660
+ def __init__(self, parent_path, transform, csv_file_name):
661
+ """
662
+ Args:
663
+ csv_file (string): Path to the CSV file containing image paths and labels.
664
+ transform (callable, optional): Optional transform to be applied
665
+ on a sample.
666
+ """
667
+ self.data = pd.read_csv(os.path.join(parent_path, csv_file_name))
668
+ self.transform = transform
669
+ self.parent_data_path = parent_path
670
+ self.mapping = {'p': 1, 'n': 0}
671
+
672
+ def __len__(self):
673
+ return len(self.data)
674
+
675
+ def __getitem__(self, idx):
676
+ if torch.is_tensor(idx):
677
+ idx = idx.tolist()
678
+
679
+ img_name = self.data.iloc[idx, 0]
680
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
681
+ label_name = self.data.iloc[idx, 1]
682
+ label = self.mapping[label_name]
683
+
684
+ if self.transform:
685
+ image = self.transform(img)
686
+
687
+ return image, label
688
+
689
+
690
+ class acl_mri(torch.utils.data.Dataset):
691
+ def __init__(self, parent_path, transform, csv_file_name):
692
+ """
693
+ Args:
694
+ csv_file (string): Path to the CSV file containing image paths and labels.
695
+ transform (callable, optional): Optional transform to be applied
696
+ on a sample.
697
+ """
698
+ self.data = pd.read_csv(os.path.join(parent_path, csv_file_name))
699
+ self.transform = transform
700
+ self.parent_data_path = parent_path
701
+ self.mapping = {'yes': 1, 'no': 0}
702
+
703
+ def __len__(self):
704
+ return len(self.data)
705
+
706
+ def __getitem__(self, idx):
707
+ if torch.is_tensor(idx):
708
+ idx = idx.tolist()
709
+
710
+ img_name = self.data.iloc[idx, 0]
711
+ img = Image.open(os.path.join(self.parent_data_path, img_name))
712
+ label_name = self.data.iloc[idx, 1]
713
+ label = self.mapping[label_name]
714
+
715
+ if self.transform:
716
+ image = self.transform(img)
717
+
718
+ return image, label
clipeval/eval_zeroshot.py ADDED
@@ -0,0 +1,359 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+
4
+ # This source code is licensed under the license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ """refactored from `main` in `eval_zeroshot.py` (SLIP) for clarity.
8
+ """
9
+ import random
10
+ import torch
11
+ import json
12
+ import os
13
+ from tqdm import tqdm
14
+ from sklearn import metrics
15
+ from constants import RSNA_CLASS_PROMPTS_webdataset, modality_indices_radimagenet_test_set
16
+ from collections import defaultdict
17
+
18
+
19
+ def load_metadata(metadir="clipeval"):
20
+ with open(os.path.join(metadir, 'dataset_catalog.json')) as f:
21
+ catalog = json.load(f)
22
+
23
+ with open(os.path.join(metadir, 'templates.json')) as f:
24
+ all_templates = json.load(f)
25
+
26
+ with open(os.path.join(metadir, 'labels.json')) as f:
27
+ all_labels = json.load(f)
28
+ return catalog, all_templates, all_labels
29
+
30
+
31
+ def evaluate(d, val_loader, templates, labels, model, tokenizer, classnorm=False):
32
+ print('Evaluating {}'.format(d))
33
+
34
+ is_acc = d not in ['FGVCAircraft', 'OxfordPets', 'Caltech101', 'Flowers102', 'Kinetics700', 'HatefulMemes']
35
+ if d == 'radimagenet':
36
+ acc, us_acc, mri_acc, ct_acc = validate_zeroshot(val_loader, templates, labels, model, tokenizer,
37
+ is_acc, d, classnorm)
38
+ else:
39
+ acc_or_outputs = validate_zeroshot(val_loader, templates, labels, model, tokenizer, is_acc, d, classnorm)
40
+ if d in ['FGVCAircraft', 'OxfordPets', 'Caltech101', 'Flowers102']:
41
+ metric = mean_per_class(*acc_or_outputs)
42
+ elif d == 'Kinetics700':
43
+ top1, top5 = accuracy(*acc_or_outputs, topk=(1, 5))
44
+ metric = (top1 + top5) / 2
45
+ metric = metric.item()
46
+ elif d == 'HatefulMemes':
47
+ metric = roc_auc(*acc_or_outputs)
48
+ elif d == 'radimagenet':
49
+ metric = {"acc": acc, "US acc": us_acc, "MRI acc": mri_acc, "CT acc": ct_acc}
50
+ else:
51
+ metric = acc_or_outputs
52
+
53
+ return metric
54
+
55
+
56
+ @torch.no_grad()
57
+ def build_text_features(templates, labels, model, tokenizer, skip_text_projection=False, classnorm=False):
58
+ # TODO: add device
59
+ text_features = []
60
+ if type(templates) == dict:
61
+ class_similarities = []
62
+ class_names = []
63
+ for cls_name, cls_text in templates.items():
64
+ texts = tokenizer(cls_text).to(next(model.parameters()).device, non_blocking=True)
65
+ class_embeddings = model.encode_text(texts)
66
+ class_embeddings = class_embeddings / class_embeddings.norm(dim=-1, keepdim=True)
67
+
68
+ if True:
69
+ cls_sim = class_embeddings.mean(dim=0) # equivalent to prompt ensembling
70
+ else:
71
+ cls_sim = class_embeddings[0]
72
+ class_similarities.append(cls_sim)
73
+ class_names.append(cls_name)
74
+
75
+ text_features = torch.stack(class_similarities, dim=0)
76
+ elif type(templates) == list and templates[0] == "Meniscal abnormality detected in MRI imaging of the knee.":
77
+ print("Encoding captions for RadImageNet dataset")
78
+ for single_template in templates:
79
+ texts = tokenizer(single_template).to(next(model.parameters()).device, non_blocking=True)
80
+ class_embeddings = model.encode_text(texts)
81
+ class_embeddings = class_embeddings / class_embeddings.norm(dim=-1, keepdim=True)
82
+ text_features.append(class_embeddings)
83
+ text_features = torch.stack(text_features, dim=0).squeeze(1)
84
+ else:
85
+ for label in labels:
86
+ if isinstance(label, list):
87
+ texts = [t.format(l) for t in templates for l in label]
88
+ else:
89
+ texts = [t.format(label) for t in templates]
90
+
91
+ texts = tokenizer(texts).to(next(model.parameters()).device, non_blocking=True)
92
+ class_embeddings = model.encode_text(texts)
93
+ class_embeddings = class_embeddings / class_embeddings.norm(dim=-1, keepdim=True)
94
+ class_embeddings = class_embeddings.mean(dim=0)
95
+ text_features.append(class_embeddings)
96
+ text_features = torch.stack(text_features, dim=0)
97
+ mean, std = None, None
98
+ if classnorm:
99
+ mean, std = text_features.mean(dim=0)[None, :], text_features.std(dim=0)[None, :]
100
+ text_features = (text_features - mean) / std
101
+ text_features = text_features / text_features.norm(dim=-1, keepdim=True)
102
+ return text_features, mean, std
103
+
104
+
105
+ def generate_chexpert_class_prompts(class_prompts, n=None):
106
+ """Generate text prompts for each CheXpert classification task
107
+ Parameters
108
+ ----------
109
+ n: int
110
+ number of prompts per class
111
+ Returns
112
+ -------
113
+ class prompts : dict
114
+ dictionary of class to prompts
115
+ """
116
+
117
+ prompts = {}
118
+ for k, v in class_prompts.items():
119
+ cls_prompts = []
120
+ keys = list(v.keys())
121
+
122
+ # severity
123
+ for k0 in v[keys[0]]:
124
+ # subtype
125
+ for k1 in v[keys[1]]:
126
+ # location
127
+ for k2 in v[keys[2]]:
128
+ cls_prompts.append(f"{k0} {k1} {k2}")
129
+
130
+ # randomly sample n prompts for zero-shot classification
131
+ # TODO: we shall make use all the candidate prompts for autoprompt tuning
132
+ if n is not None and n < len(cls_prompts):
133
+ prompts[k] = random.sample(cls_prompts, n)
134
+ else:
135
+ prompts[k] = cls_prompts
136
+ print(f'sample {len(prompts[k])} num of prompts for {k} from total {len(cls_prompts)}')
137
+ return prompts
138
+
139
+
140
+ def generate_rsna_class_prompts(class_prompts, n=None):
141
+ prompts = {}
142
+ for k, v in class_prompts.items():
143
+ cls_prompts = []
144
+ keys = list(v.keys())
145
+
146
+ for k0 in v[keys[0]]:
147
+ for k1 in v[keys[1]]:
148
+ for k2 in v[keys[2]]:
149
+ cls_prompts.append(f"{k0} {k1} {k2}")
150
+
151
+ # randomly sample n prompts for zero-shot classification
152
+ if n is not None and n < len(cls_prompts):
153
+ prompts[k] = random.sample(cls_prompts, n)
154
+ else:
155
+ prompts[k] = cls_prompts
156
+ print(f'sample {len(prompts[k])} num of prompts for {k} from total {len(cls_prompts)}')
157
+ return prompts
158
+
159
+
160
+ @torch.no_grad()
161
+ def validate_zeroshot(val_loader, templates, labels, model, tokenizer, is_acc, name, classnorm=False):
162
+ # switch to evaluate mode
163
+ model.cuda()
164
+ model.eval()
165
+
166
+ total_top1 = 0
167
+ total_images = 0
168
+
169
+ all_outputs = []
170
+ all_targets = []
171
+
172
+ text_features = None
173
+ # Initialize per-class accuracy variables
174
+ class_correct = defaultdict(int)
175
+ class_total = defaultdict(int)
176
+
177
+ for samples in tqdm(val_loader):
178
+ # Below if will run only for one iteration
179
+ if text_features is None:
180
+ print('=> encoding captions')
181
+ if name == "chexpert-5x200":
182
+ if not type(templates[list(templates.keys())[0]]) == list:
183
+ prompted_templates = generate_chexpert_class_prompts(templates, 10) # 10 prompts per class
184
+ else:
185
+ k = 11 # This means all 10 templates to be used...
186
+ print(f"Using {k - 1} templates for the ensembling at test time")
187
+ for single_key in templates.keys():
188
+ templates[single_key] = templates[single_key][0:k]
189
+ prompted_templates = templates
190
+ text_features, mean, std = build_text_features(prompted_templates, None, model, tokenizer,
191
+ classnorm=classnorm)
192
+ elif name == "rsna_pneumonia":
193
+ if not type(templates[list(templates.keys())[0]]) == list:
194
+ temp = generate_rsna_class_prompts(templates, 10) # 10 prompts per class
195
+ # For the case of Pneumonia, we also need second template for normal as well
196
+ prompted_templates = {'normal': RSNA_CLASS_PROMPTS_webdataset['Normal'],
197
+ 'pneumonia': temp['Pneumonia']}
198
+ else:
199
+ k = 1 # This means all 10 templates to be used...
200
+ print(f"Using {k - 1} templates for the ensembling at test time")
201
+ for single_key in templates.keys():
202
+ templates[single_key] = templates[single_key][0:k]
203
+ prompted_templates = templates
204
+ text_features, mean, std = build_text_features(prompted_templates, None, model, tokenizer,
205
+ classnorm=classnorm)
206
+ else:
207
+ if type(templates) == dict:
208
+ k = 11 # This means all 10 templates to be used...
209
+ print(f"Using {k - 1} templates for the ensembling at test time")
210
+ for single_key in templates.keys():
211
+ length = len(templates[single_key])
212
+ templates[single_key] = templates[single_key][0:length]
213
+ prompted_templates = templates
214
+ else:
215
+ prompted_templates = templates
216
+ text_features, mean, std = build_text_features(prompted_templates, labels, model, tokenizer,
217
+ classnorm=classnorm)
218
+ if isinstance(samples, tuple) or isinstance(samples, list):
219
+ images, target = samples[0], samples[1]
220
+ elif isinstance(samples, dict):
221
+ images, target = samples["pixel_values"], samples["targets"]
222
+ else:
223
+ raise ValueError("unknown sample type", type(samples))
224
+
225
+ images = images.cuda(non_blocking=True)
226
+ target = target.cuda(non_blocking=True)
227
+
228
+ # encode images
229
+ image_features = model.encode_image(images)
230
+
231
+ if classnorm:
232
+ image_features = (image_features - mean) / std
233
+ print("no normalizing this time)")
234
+ # image_features = image_features / image_features.norm(dim=-1, keepdim=True)
235
+ # cosine similarity as logits
236
+ logits_per_image = image_features @ text_features.t()
237
+ logits_per_image = logits_per_image.cpu()
238
+ target = target.cpu()
239
+ if name == "chexpert-5x200":
240
+ # convert to label encoding
241
+ target = torch.argmax(target, axis=1)
242
+ if is_acc:
243
+ # measure accuracy and record loss
244
+ pred = logits_per_image.argmax(dim=1)
245
+ correct = pred.eq(target).sum()
246
+ total_top1 += correct.item()
247
+ total_images += images.size(0)
248
+ if name == "radimagenet":
249
+ # Update per-class accuracy counts
250
+ for t, p in zip(target, pred):
251
+ class_correct[t.item()] += p.eq(t).item()
252
+ class_total[t.item()] += 1
253
+ # Also save those to have results for the other metrics
254
+ all_outputs.append(logits_per_image)
255
+ all_targets.append(target)
256
+ else:
257
+ all_outputs.append(logits_per_image)
258
+ all_targets.append(target)
259
+
260
+ if is_acc:
261
+ if name == "radimagenet":
262
+ # Now calculate accuracies for each modality
263
+ US_all_class_correct = 0
264
+ MRI_all_class_correct = 0
265
+ CT_all_class_correct = 0
266
+ US_all_class_total = 0
267
+ MRI_all_class_total = 0
268
+ CT_all_class_total = 0
269
+ for single_us_index in modality_indices_radimagenet_test_set['US']:
270
+ US_all_class_correct += class_correct[single_us_index]
271
+ US_all_class_total += class_total[single_us_index]
272
+ for single_mri_index in modality_indices_radimagenet_test_set['MRI']:
273
+ MRI_all_class_correct += class_correct[single_mri_index]
274
+ MRI_all_class_total += class_total[single_mri_index]
275
+ for single_ct_index in modality_indices_radimagenet_test_set['CT']:
276
+ CT_all_class_correct += class_correct[single_ct_index]
277
+ CT_all_class_total += class_total[single_ct_index]
278
+
279
+ return 100 * total_top1 / total_images, \
280
+ 100 * US_all_class_correct / US_all_class_total, \
281
+ 100 * MRI_all_class_correct / MRI_all_class_total, \
282
+ 100 * CT_all_class_correct / CT_all_class_total
283
+ if name == 'radimagenet' or name == 'chexpert-5x200' or name == 'CT_sagittal' or name == 'CT_axial' \
284
+ or name == 'CT_coronal' or name == 'dr_uwf' or name == 'dr_regular' \
285
+ or name == 'PCAM' or name == 'LC25000_lung' or name == 'LC25000_colon' \
286
+ or name == "NCK_CRC" or name == 'BACH' or name == 'Osteo' \
287
+ or name == 'skin_cancer' or name == 'skin_tumor' or name == 'SICAPv2' \
288
+ or name == 'five_retina' or name == 'odir_retina':
289
+ return 100 * total_top1 / total_images
290
+ else:
291
+ # Now also return the other metric results
292
+ all_outputs = torch.cat(all_outputs)
293
+ all_targets = torch.cat(all_targets)
294
+ accuracy = 100 * total_top1 / total_images
295
+ auc_roc = roc_auc(all_outputs, all_targets)
296
+ f1_score = F1_score(all_outputs, all_targets)
297
+ precision_score = Precision_score(all_outputs, all_targets)
298
+ recall_score = Recall_score(all_outputs, all_targets)
299
+ return {"acc": accuracy, "auc_roc": auc_roc, "f1_score": f1_score,
300
+ "precision_score": precision_score, "recall_score": recall_score}
301
+ else:
302
+ return torch.cat(all_outputs), torch.cat(all_targets)
303
+
304
+
305
+ def accuracy(output, target, topk=(1,)):
306
+ """Computes the accuracy over the k top predictions for the specified values of k"""
307
+ with torch.no_grad():
308
+ maxk = max(topk)
309
+ batch_size = target.size(0)
310
+
311
+ _, pred = output.topk(maxk, 1, True, True)
312
+ pred = pred.t()
313
+ correct = pred.eq(target.reshape(1, -1).expand_as(pred))
314
+
315
+ res = []
316
+ for k in topk:
317
+ correct_k = correct[:k].reshape(-1).float().sum(0, keepdim=True)
318
+ res.append(correct_k.mul_(100.0 / batch_size))
319
+ return res
320
+
321
+
322
+ def Recall_score(outputs, targets):
323
+ pred = outputs.argmax(1)
324
+ Recall_score = metrics.recall_score(targets, pred)
325
+ return 100 * Recall_score
326
+
327
+
328
+ def F1_score(outputs, targets):
329
+ pred = outputs.argmax(1)
330
+ F1_score = metrics.f1_score(targets, pred)
331
+ return 100 * F1_score
332
+
333
+
334
+ def Precision_score(outputs, targets):
335
+ pred = outputs.argmax(1)
336
+ Precision_score = metrics.precision_score(targets, pred)
337
+ return 100 * Precision_score
338
+
339
+
340
+ def mean_per_class(outputs, targets):
341
+ pred = outputs.argmax(1)
342
+ confusion_matrix = metrics.confusion_matrix(targets, pred)
343
+ per_classes = confusion_matrix.diagonal() / confusion_matrix.sum(axis=1)
344
+
345
+ return 100 * per_classes.mean()
346
+
347
+
348
+ def roc_auc(outputs, targets):
349
+ pos_score = outputs[:, 1] - outputs[:, 0]
350
+ metric = metrics.roc_auc_score(targets, pos_score)
351
+
352
+ return 100 * metric
353
+
354
+
355
+ if __name__ == '__main__':
356
+ logits = torch.randn(128, 10)
357
+ targets = torch.randint(size=(128,), low=0, high=10)
358
+
359
+ evaluate("imagenet", logits, targets)
clipeval/labels.json ADDED
The diff for this file is too large to render. See raw diff
 
clipeval/radimagenet_labels.txt ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Meniscal abnormality detected in MRI imaging of the knee.
2
+ Chondral abnormality evident in the MRI image of the knee.
3
+ MRI scan showing pathology of the medial collateral ligament (MCL) in the knee.
4
+ Soft tissue fluid collection evident in the MRI of the knee.
5
+ Fractured knee depicted in MRI imaging.
6
+ MRI imaging depicts inflammation of the bone in the knee region.
7
+ ACL pathology is evident in the MRI imaging of the knee..
8
+ Pathological condition of the patella evident in the MRI image of the knee.
9
+ MRI depicting intra-articular pathology of the knee.
10
+ Quad pathology evident in the MRI of the knee.
11
+ Post-operative ACL MRI scan of the knee.
12
+ MRI imaging revealing edema within the soft tissues of the knee.
13
+ MRI image demonstrating pathology of the posterior cruciate ligament (PCL) in the knee.
14
+ MRI image displaying pathology of the fibular collateral ligament in the knee.
15
+ MRI image depicts a hematoma in the knee region..
16
+ Muscle strain is evident in the MRI image of the knee..
17
+ Soft tissue mass identified in the knee on MRI imaging.
18
+ Labral pathology identified in an MRI image of the shoulder..
19
+ Supraspinatus pathology evident in MRI of the shoulder.
20
+ Soft tissue fluid evident in an MRI image of the shoulder.
21
+ Osteoarthritis visibly characterized in the shoulder joint on MRI imaging.
22
+ Acromioclavicular joint osteoarthritis evident in MRI of the shoulder.
23
+ Osseous lesion identified in the shoulder from MRI imaging.
24
+ Subscapularis pathology depicted in MRI imaging of the shoulder.
25
+ Postoperative MRI scan of the shoulder.
26
+ Inflammatory changes noted within the marrow of the shoulder on MRI imaging.
27
+ MRI image showing edema within the soft tissues of the shoulder.
28
+ Infraspinatus pathology is evident in the MRI of the shoulder.
29
+ MRI image depicting calcific tendinosis in the shoulder region.
30
+ MRI scan demonstrating pathology of the biceps in the shoulder region.
31
+ Chondral pathology evident in the MRI image of the hip.
32
+ MRI image reveals labral pathology in the hip region.
33
+ MRI image showing inflammation in the bone marrow of the hip.
34
+ Fluid accumulation in soft tissues observed in the hip MRI image.
35
+ Post-operative MRI scan of the hip demonstrating surgical changes.
36
+ MRI image depicting a soft tissue mass in the hip region..
37
+ Osseous disruption evident in the MRI image of the hip.
38
+ Osseous lesion identified in the hip region on MRI imaging.
39
+ Abductor pathology is evident in the MRI image of the hip.
40
+ Soft tissue edema evident in MRI of the hip.
41
+ Hematoma evident in the hip region on MRI imaging.
42
+ Hamstring pathology is evident in the MRI image of the hip.
43
+ Capsular pathology is evident in the MRI image of the hip..
44
+ Cord pathology evident in MRI imaging of the spine.
45
+ MRI reveals the presence of a dural epidural abnormality in the spine.
46
+ Foraminal pathology evident in the MRI of the spine.
47
+ Disc pathology evident in MRI imaging of the spine.
48
+ Facet arthropathy is displayed in this MRI image of the spine..
49
+ Cystic lesions identified on MRI imaging of the spine.
50
+ Osseous abnormalities detected in the MRI of the spine.
51
+ Image depicts scoliosis on an MRI of the spine.
52
+ Chronic infarct evidenced in brain MRI imaging..
53
+ White matter alterations observable on brain MRI imaging.
54
+ Focal FLAIR hyperintensity observed in the brain MRI image.
55
+ Arteriovenous anomaly depicted in the MRI of the brain.
56
+ MRI imaging reveals cerebral edema.
57
+ Acute infarct displayed in the MRI image of the brain.
58
+ MRI image reveals extraneous tissue within the brain.
59
+ MRI image showing intracranial abnormality in the brain.
60
+ Pituitary lesion depicted in MRI imaging of the brain.
61
+ MRI image showing signs of hepatic pathology.
62
+ Adrenal pathology is evident in the MRI photo of the abdomen..
63
+ Arterial pathology depicted in the MRI image of the abdomen.
64
+ MRI image showing ascites in the abdominal cavity.
65
+ MRI image showing ovarian pathology in the abdomen.
66
+ Intraperitoneal mass evident in MRI abdominal imaging.
67
+ MRI scan showing biliary dilatation in the abdomen.
68
+ MRI imaging reveals a lesion on the liver.
69
+ Bladder pathology depicted in MRI abdomen imaging.
70
+ Abnormality in bowel structure as depicted in an MRI of the abdomen.
71
+ MRI image depicting inflammation of the bowel.
72
+ MRI image displaying a mass in the abdominal bowel region..
73
+ Degenerative changes are evident in the MRI of the abdomen.
74
+ MRI image showing dilation of the urinary tract.
75
+ MRI image reveals organomegaly in the abdominal region.
76
+ MRI image depicting gallbladder pathology in the abdominal region.
77
+ Renal lesion is evident in the MRI of the abdomen.
78
+ MRI photo reveals a uterine pathology in the abdominal scan.
79
+ MRI depicts abnormal marrow in the abdomen..
80
+ Osseous neoplasm identified in MRI of the abdomen.
81
+ MRI image depicting a lesion in the pancreas.
82
+ Prostate lesion depicted in MRI abdominal imaging..
83
+ Soft tissue collection identified in MRI of the abdomen.
84
+ Soft tissue mass observed in abdominal MRI imaging.
85
+ Splenic lesion evident on MRI abdominal image.
86
+ Gallstone identified on abdominal CT scan.
87
+ Prostate lesion identified in CT imaging of the abdomen.
88
+ The entire organ shows abnormalities on the CT scan of the abdomen..
89
+ Pancreatic lesion identified using CT imaging of the abdomen.
90
+ CT imaging reveals biliary dilation involving the abdomen.
91
+ CT imaging shows dilation of the urinary tract..
92
+ Urolithiasis identified in the abdominal CT scan.
93
+ A computed tomography scan revealing an abnormality in the abdominal bowel.
94
+ Bowel inflammation depicted on abdominal CT imaging.
95
+ Osseous neoplasm identified in abdominal CT imaging.
96
+ Liver lesion identified in CT scan of the abdomen.
97
+ Renal lesion identified on abdominal CT scan..
98
+ Post-operative changes observed in abdominal CT imaging.
99
+ CT imaging reveals pathology of the uterus..
100
+ Adrenal pathology identified on computed tomography of the abdomen.
101
+ Ovarian pathology is evident in the CT scan of the abdomen..
102
+ Arterial pathology identified in the abdominal CT scan.
103
+ Ascites evidenced in CT imaging of the abdomen.
104
+ Splenic lesion identified on the CT scan of the abdomen.
105
+ Bladder pathology identified in CT imaging of the abdomen.
106
+ A fat-containing tumor is depicted in the abdominal CT imaging..
107
+ Degenerative changes identified in the abdomen on CT imaging.
108
+ Soft tissue collection identified in the abdominal CT imaging..
109
+ Gallbladder pathology identified on abdominal CT scan.
110
+ Soft tissue mass identified on abdominal CT scan.
111
+ An intraperitoneal mass is identified on the CT scan of the abdomen.
112
+ A bowel mass is identified in the abdominal CT imaging..
113
+ MRI image depicting an osseous disruption in the atrial fibrillation (AF) region..
114
+ Bone inflammation depicted in MRI imaging of the forearm.
115
+ Fluid accumulation in soft tissues evidenced in the MRI image.
116
+ Osseous neoplasm depicted in MRI imaging of the foot.
117
+ Chondral abnormality depicted in MRI imaging of the atrial fibrillation affected area.
118
+ Plantar fascia pathology evident in MRI imaging.
119
+ ATFL pathology depicted in MRI imaging of the ankle.
120
+ MRI image depicting soft tissue edomain the ankle region..
121
+ MRI image demonstrating a soft tissue mass in the atrial fibrillation area.
122
+ Intra-atrial fibrillation observed in an MRI imaging.
123
+ MRI image reveals a pathology in the extensor compartment of the forearm..
124
+ Plantar plate tear evident in MRI imaging of the foot.
125
+ Achilles pathology evident in MRI imaging of the ankle.
126
+ Hematoma presented in an MRI image of the atrial fibrillation affected area.
127
+ CFL pathology evident in the MRI image of the ankle.
128
+ Peroneal pathology evidenced in MRI imaging.
129
+ MRI image depicting pathology of the deltoid muscle.
130
+ Post-operative MRI showing atrial fibrillation characteristics.
131
+ Flexor pathology evident in MRI imaging of the forearm.
132
+ MRI image showing a tumor characterized by fat content in the atrial fibrillation region.
133
+ Pathology of syndesmosis depicted in an MRI image of the ankle..
134
+ MRI image demonstrating Lisfranc pathology in a patient with atrial fibrillation.
135
+ MRI reveals a coalition in the tarsal bones.
136
+ MRI image depicting a spring ligament injury in a patient with atrial fibrillation.
137
+ A CT scan of the abdomen shows no abnormalities..
138
+ Normal abdominal MRI image showing no abnormalities.
139
+ MRI image showing a normal atrial fibrillation pattern..
140
+ MRI image depicts a normal brain structure..
141
+ MRI image displays a normal hip structure.
142
+ Normal appearance of the knee in MRI imaging.
143
+ Normal anatomical structures are evident in this MRI image of the shoulder..
144
+ Normal spinal anatomy depicted in MRI imaging..
145
+ Fibroid identified in ultrasound imaging of the uterus..
146
+ Ultrasound depiction of a kidney showing the renal structure..
147
+ Ultrasound image depicting a healthy uterus..
148
+ Ultrasound depicting ovarian morphology..
149
+ The ultrasound image depicts pancreatitis involving the pancreas..
150
+ Ultrasound scan showing liver morphology..
151
+ Ultrasound depicting gallbladder pathology..
152
+ Ultrasound imaging reveals common bile duct dilation.
153
+ Ultrasound reveals an enlarged splean indicative of splenomegaly..
154
+ The ultrasound reveals an image of the aorta..
155
+ Ultrasound imaging depicting the Inferior Vena Cava (IVC).
156
+ Bladder inflammation depicted in ultrasound imaging.
157
+ Portal vein thrombosis evident in the ultrasound image of the portal vein..
158
+ Ultrasound imaging reveals the structure of the thyroid gland..
159
+ The CT scan displays normal lung anatomy without pathological findings..
160
+ Airspace opacity is evident in the lung on the CT scan.
161
+ A CT scan image showing a nodule in the lung tissue..
162
+ Interstitial lung disease as depicted in a CT scan of the lung..
163
+ Parenchyma destruction is evident in the lung from the CT scan.
164
+ Bronchiectasis is evident in the CT scan of the lung.
165
+ Ultrasound imaging reveals the structure of the thyroid gland..
clipeval/templates.json ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "CUB200": [
3
+ "a photo of a {}, a type of bird."
4
+ ],
5
+ "Birdsnap": [
6
+ "a photo of a {}, a type of bird."
7
+ ],
8
+ "CIFAR10": [
9
+ "a photo of a {}.",
10
+ "a blurry photo of a {}.",
11
+ "a black and white photo of a {}.",
12
+ "a low contrast photo of a {}.",
13
+ "a high contrast photo of a {}.",
14
+ "a bad photo of a {}.",
15
+ "a good photo of a {}.",
16
+ "a photo of a small {}.",
17
+ "a photo of a big {}.",
18
+ "a photo of the {}.",
19
+ "a blurry photo of the {}.",
20
+ "a black and white photo of the {}.",
21
+ "a low contrast photo of the {}.",
22
+ "a high contrast photo of the {}.",
23
+ "a bad photo of the {}.",
24
+ "a good photo of the {}.",
25
+ "a photo of the small {}.",
26
+ "a photo of the big {}."
27
+ ],
28
+ "CIFAR100": [
29
+ "a photo of a {}.",
30
+ "a blurry photo of a {}.",
31
+ "a black and white photo of a {}.",
32
+ "a low contrast photo of a {}.",
33
+ "a high contrast photo of a {}.",
34
+ "a bad photo of a {}.",
35
+ "a good photo of a {}.",
36
+ "a photo of a small {}.",
37
+ "a photo of a big {}.",
38
+ "a photo of the {}.",
39
+ "a blurry photo of the {}.",
40
+ "a black and white photo of the {}.",
41
+ "a low contrast photo of the {}.",
42
+ "a high contrast photo of the {}.",
43
+ "a bad photo of the {}.",
44
+ "a good photo of the {}.",
45
+ "a photo of the small {}.",
46
+ "a photo of the big {}."
47
+ ],
48
+ "CLEVRCounts": [
49
+ "a photo of {} objects."
50
+ ],
51
+ "Caltech101": [
52
+ "a photo of a {}.",
53
+ "a painting of a {}.",
54
+ "a plastic {}.",
55
+ "a sculpture of a {}.",
56
+ "a sketch of a {}.",
57
+ "a tattoo of a {}.",
58
+ "a toy {}.",
59
+ "a rendition of a {}.",
60
+ "a embroidered {}.",
61
+ "a cartoon {}.",
62
+ "a {} in a video game.",
63
+ "a plushie {}.",
64
+ "a origami {}.",
65
+ "art of a {}.",
66
+ "graffiti of a {}.",
67
+ "a drawing of a {}.",
68
+ "a doodle of a {}.",
69
+ "a photo of the {}.",
70
+ "a painting of the {}.",
71
+ "the plastic {}.",
72
+ "a sculpture of the {}.",
73
+ "a sketch of the {}.",
74
+ "a tattoo of the {}.",
75
+ "the toy {}.",
76
+ "a rendition of the {}.",
77
+ "the embroidered {}.",
78
+ "the cartoon {}.",
79
+ "the {} in a video game.",
80
+ "the plushie {}.",
81
+ "the origami {}.",
82
+ "art of the {}.",
83
+ "graffiti of the {}.",
84
+ "a drawing of the {}.",
85
+ "a doodle of the {}."
86
+ ],
87
+ "Country211": [
88
+ "a photo i took in {}.",
89
+ "a photo i took while visiting {}.",
90
+ "a photo from my home country of {}.",
91
+ "a photo from my visit to {}.",
92
+ "a photo showing the country of {}."
93
+ ],
94
+ "DescribableTextures": [
95
+ "a photo of a {} texture.",
96
+ "a photo of a {} pattern.",
97
+ "a photo of a {} thing.",
98
+ "a photo of a {} object.",
99
+ "a photo of the {} texture.",
100
+ "a photo of the {} pattern.",
101
+ "a photo of the {} thing.",
102
+ "a photo of the {} object."
103
+ ],
104
+ "EuroSAT": [
105
+ "a centered satellite photo of {}.",
106
+ "a centered satellite photo of a {}.",
107
+ "a centered satellite photo of the {}."
108
+ ],
109
+ "FGVCAircraft": [
110
+ "a photo of a {}, a type of aircraft.",
111
+ "a photo of the {}, a type of aircraft."
112
+ ],
113
+ "FacialEmotionRecognition2013": [
114
+ "a photo of a {} looking face.",
115
+ "a photo of a face showing the emotion: {}.",
116
+ "a photo of a face looking {}.",
117
+ "a face that looks {}.",
118
+ "they look {}.",
119
+ "look at how {} they are."
120
+ ],
121
+ "Flowers102": [
122
+ "a photo of a {}, a type of flower."
123
+ ],
124
+ "Food101": [
125
+ "a photo of {}, a type of food."
126
+ ],
127
+ "GTSRB": [
128
+ "a zoomed in photo of a \"{}\" traffic sign.",
129
+ "a centered photo of a \"{}\" traffic sign.",
130
+ "a close up photo of a \"{}\" traffic sign."
131
+ ],
132
+ "HatefulMemes": [
133
+ "a {}."
134
+ ],
135
+ "KITTI": [
136
+ "{}"
137
+ ],
138
+ "Kinetics700": [
139
+ "a photo of {}.",
140
+ "a photo of a person {}.",
141
+ "a photo of a person using {}.",
142
+ "a photo of a person doing {}.",
143
+ "a photo of a person during {}.",
144
+ "a photo of a person performing {}.",
145
+ "a photo of a person practicing {}.",
146
+ "a video of {}.",
147
+ "a video of a person {}.",
148
+ "a video of a person using {}.",
149
+ "a video of a person doing {}.",
150
+ "a video of a person during {}.",
151
+ "a video of a person performing {}.",
152
+ "a video of a person practicing {}.",
153
+ "a example of {}.",
154
+ "a example of a person {}.",
155
+ "a example of a person using {}.",
156
+ "a example of a person doing {}.",
157
+ "a example of a person during {}.",
158
+ "a example of a person performing {}.",
159
+ "a example of a person practicing {}.",
160
+ "a demonstration of {}.",
161
+ "a demonstration of a person {}.",
162
+ "a demonstration of a person using {}.",
163
+ "a demonstration of a person doing {}.",
164
+ "a demonstration of a person during {}.",
165
+ "a demonstration of a person performing {}.",
166
+ "a demonstration of a person practicing {}."
167
+ ],
168
+ "MNIST": [
169
+ "a photo of the number: \"{}\"."
170
+ ],
171
+ "OxfordPets": [
172
+ "a photo of a {}, a type of pet."
173
+ ],
174
+ "PascalVOC2007": [
175
+ "a photo of a {}."
176
+ ],
177
+ "PatchCamelyon": [
178
+ "this is a photo of {}"
179
+ ],
180
+ "RESISC45": [
181
+ "satellite imagery of {}.",
182
+ "aerial imagery of {}.",
183
+ "satellite photo of {}.",
184
+ "aerial photo of {}.",
185
+ "satellite view of {}.",
186
+ "aerial view of {}.",
187
+ "satellite imagery of a {}.",
188
+ "aerial imagery of a {}.",
189
+ "satellite photo of a {}.",
190
+ "aerial photo of a {}.",
191
+ "satellite view of a {}.",
192
+ "aerial view of a {}.",
193
+ "satellite imagery of the {}.",
194
+ "aerial imagery of the {}.",
195
+ "satellite photo of the {}.",
196
+ "aerial photo of the {}.",
197
+ "satellite view of the {}.",
198
+ "aerial view of the {}."
199
+ ],
200
+ "SST2": [
201
+ "a {} review of a movie."
202
+ ],
203
+ "STL10": [
204
+ "a photo of a {}.",
205
+ "a photo of the {}."
206
+ ],
207
+ "SUN397": [
208
+ "a photo of a {}.",
209
+ "a photo of the {}."
210
+ ],
211
+ "StanfordCars": [
212
+ "a photo of a {}.",
213
+ "a photo of the {}.",
214
+ "a photo of my {}.",
215
+ "i love my {}!",
216
+ "a photo of my dirty {}.",
217
+ "a photo of my clean {}.",
218
+ "a photo of my new {}.",
219
+ "a photo of my old {}."
220
+ ],
221
+ "UCF101": [
222
+ "a photo of a person {}.",
223
+ "a video of a person {}.",
224
+ "a example of a person {}.",
225
+ "a demonstration of a person {}.",
226
+ "a photo of the person {}.",
227
+ "a video of the person {}.",
228
+ "a example of the person {}.",
229
+ "a demonstration of the person {}.",
230
+ "a photo of a person using {}.",
231
+ "a video of a person using {}.",
232
+ "a example of a person using {}.",
233
+ "a demonstration of a person using {}.",
234
+ "a photo of the person using {}.",
235
+ "a video of the person using {}.",
236
+ "a example of the person using {}.",
237
+ "a demonstration of the person using {}.",
238
+ "a photo of a person doing {}.",
239
+ "a video of a person doing {}.",
240
+ "a example of a person doing {}.",
241
+ "a demonstration of a person doing {}.",
242
+ "a photo of the person doing {}.",
243
+ "a video of the person doing {}.",
244
+ "a example of the person doing {}.",
245
+ "a demonstration of the person doing {}.",
246
+ "a photo of a person during {}.",
247
+ "a video of a person during {}.",
248
+ "a example of a person during {}.",
249
+ "a demonstration of a person during {}.",
250
+ "a photo of the person during {}.",
251
+ "a video of the person during {}.",
252
+ "a example of the person during {}.",
253
+ "a demonstration of the person during {}.",
254
+ "a photo of a person performing {}.",
255
+ "a video of a person performing {}.",
256
+ "a example of a person performing {}.",
257
+ "a demonstration of a person performing {}.",
258
+ "a photo of the person performing {}.",
259
+ "a video of the person performing {}.",
260
+ "a example of the person performing {}.",
261
+ "a demonstration of the person performing {}.",
262
+ "a photo of a person practicing {}.",
263
+ "a video of a person practicing {}.",
264
+ "a example of a person practicing {}.",
265
+ "a demonstration of a person practicing {}.",
266
+ "a photo of the person practicing {}.",
267
+ "a video of the person practicing {}.",
268
+ "a example of the person practicing {}.",
269
+ "a demonstration of the person practicing {}."
270
+ ],
271
+ "imagenet": [
272
+ "a bad photo of a {}.",
273
+ "a photo of many {}.",
274
+ "a sculpture of a {}.",
275
+ "a photo of the hard to see {}.",
276
+ "a low resolution photo of the {}.",
277
+ "a rendering of a {}.",
278
+ "graffiti of a {}.",
279
+ "a bad photo of the {}.",
280
+ "a cropped photo of the {}.",
281
+ "a tattoo of a {}.",
282
+ "the embroidered {}.",
283
+ "a photo of a hard to see {}.",
284
+ "a bright photo of a {}.",
285
+ "a photo of a clean {}.",
286
+ "a photo of a dirty {}.",
287
+ "a dark photo of the {}.",
288
+ "a drawing of a {}.",
289
+ "a photo of my {}.",
290
+ "the plastic {}.",
291
+ "a photo of the cool {}.",
292
+ "a close-up photo of a {}.",
293
+ "a black and white photo of the {}.",
294
+ "a painting of the {}.",
295
+ "a painting of a {}.",
296
+ "a pixelated photo of the {}.",
297
+ "a sculpture of the {}.",
298
+ "a bright photo of the {}.",
299
+ "a cropped photo of a {}.",
300
+ "a plastic {}.",
301
+ "a photo of the dirty {}.",
302
+ "a jpeg corrupted photo of a {}.",
303
+ "a blurry photo of the {}.",
304
+ "a photo of the {}.",
305
+ "a good photo of the {}.",
306
+ "a rendering of the {}.",
307
+ "a {} in a video game.",
308
+ "a photo of one {}.",
309
+ "a doodle of a {}.",
310
+ "a close-up photo of the {}.",
311
+ "a photo of a {}.",
312
+ "the origami {}.",
313
+ "the {} in a video game.",
314
+ "a sketch of a {}.",
315
+ "a doodle of the {}.",
316
+ "a origami {}.",
317
+ "a low resolution photo of a {}.",
318
+ "the toy {}.",
319
+ "a rendition of the {}.",
320
+ "a photo of the clean {}.",
321
+ "a photo of a large {}.",
322
+ "a rendition of a {}.",
323
+ "a photo of a nice {}.",
324
+ "a photo of a weird {}.",
325
+ "a blurry photo of a {}.",
326
+ "a cartoon {}.",
327
+ "art of a {}.",
328
+ "a sketch of the {}.",
329
+ "a embroidered {}.",
330
+ "a pixelated photo of a {}.",
331
+ "itap of the {}.",
332
+ "a jpeg corrupted photo of the {}.",
333
+ "a good photo of a {}.",
334
+ "a plushie {}.",
335
+ "a photo of the nice {}.",
336
+ "a photo of the small {}.",
337
+ "a photo of the weird {}.",
338
+ "the cartoon {}.",
339
+ "art of the {}.",
340
+ "a drawing of the {}.",
341
+ "a photo of the large {}.",
342
+ "a black and white photo of a {}.",
343
+ "the plushie {}.",
344
+ "a dark photo of a {}.",
345
+ "itap of a {}.",
346
+ "graffiti of the {}.",
347
+ "a toy {}.",
348
+ "itap of my {}.",
349
+ "a photo of a cool {}.",
350
+ "a photo of a small {}.",
351
+ "a tattoo of the {}."
352
+ ]
353
+ }
configs.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import inspect
3
+
4
+ from collections import OrderedDict
5
+ from dataclasses import dataclass
6
+
7
+ import sys
8
+ sys.path.append("src")
9
+
10
+ from training.params import get_default_params
11
+
12
+
13
+ @dataclass
14
+ class Config:
15
+ tokenizer_context_length = 256
16
+ eval_freq = 1
17
+ text_encoder_model_name = 'microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract'
18
+ distributed_engine = "ddp"
19
+ train_data = None
20
+ val_data = None
21
+ train_num_samples = None
22
+ val_num_samples = None
23
+ dataset_type = "auto"
24
+ dataset_resampled = False
25
+ csv_separator = "\t"
26
+ csv_img_key = "filepath"
27
+ csv_caption_key = "title"
28
+ imagenet_val = "/datasets01/imagenet_full_size/061417/val"
29
+ imagenet_v2 = None
30
+ logs = "./logs/"
31
+ log_local = False
32
+ name = None
33
+ workers = 8
34
+ batch_size = 64
35
+ epochs = 32
36
+ lr = None
37
+ beta1 = None
38
+ beta2 = None
39
+ eps = None
40
+ wd = 0.2
41
+ warmup = 2000 # 10000
42
+ use_bn_sync = False
43
+ skip_scheduler = False
44
+ save_frequency = 10
45
+ save_most_recent = True # False
46
+ zeroshot_frequency = 1
47
+ val_frequency = 1
48
+ resume = None
49
+ precision = "amp"
50
+ clip_model = "CLIP"
51
+ model = "RN50"
52
+ pretrained = ''
53
+ pretrained_image = False
54
+ lock_image = False
55
+ lock_image_unlocked_groups = 0
56
+ lock_image_freeze_bn_stats = False
57
+ grad_checkpointing = False
58
+ local_loss = False
59
+ gather_with_grad = False
60
+ force_quick_gelu = False
61
+ torchscript = False
62
+ trace = False
63
+ dist_url = "env://"
64
+ dist_backend = "nccl"
65
+ report_to = ""
66
+ wandb_notes = ''
67
+ debug = False
68
+ copy_codebase = False
69
+ horovod = False
70
+ ddp_static_graph = False
71
+ no_set_device_rank = False
72
+ seed = 0
73
+ norm_gradient_clip = None
74
+ train_data_upsampling_factors = None
75
+
76
+ def __post_init__(self):
77
+ args = self
78
+ args.name = self.__class__.__name__
79
+ args.output_dir = os.path.join(args.logs, args.name)
80
+
81
+ for name, val in get_default_params(args.model).items():
82
+ if getattr(args, name) is None:
83
+ setattr(args, name, val)
84
+
85
+
86
+ def parse_start_end(shards):
87
+ start, end = os.path.basename(shards).split("{")[1].split("}")[0].split("..")
88
+ return int(start), int(end)
89
+
90
+
91
+ def search_config(config_name):
92
+ import importlib
93
+ project_dir = os.path.dirname(__file__)
94
+ all_configs = {}
95
+ for code in os.listdir(project_dir):
96
+ if code.endswith(".py") and code.startswith("run_configs"):
97
+ module = importlib.import_module(code[:-3])
98
+ for _config_name in dir(module):
99
+ if _config_name in ["Config"] or _config_name.startswith("__") or _config_name.startswith("run_config"):
100
+ continue
101
+ if _config_name not in all_configs:
102
+ all_configs[_config_name] = module
103
+ print(f"launching {config_name} from {all_configs[config_name].__file__}")
104
+ config = getattr(all_configs[config_name], config_name)()
105
+ return config
constants.py ADDED
The diff for this file is too large to render. See raw diff
 
data_prepration_scripts/CheXpert/webdataset_chexpert.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import pandas as pd
5
+ import ast
6
+ from tqdm import tqdm
7
+ import argparse
8
+
9
+
10
+ def create_webdataset(csv_file, output_dir, parent_dataset_path, tar_size=1000):
11
+ os.makedirs(output_dir, exist_ok=True)
12
+
13
+ with open(csv_file, newline='') as f:
14
+ reader = pd.read_csv(csv_file, delimiter=',')
15
+
16
+ tar_index = 0
17
+ file_count = 0
18
+ tar = None
19
+
20
+ for row in tqdm(reader.values):
21
+ if file_count % tar_size == 0:
22
+ if tar:
23
+ tar.close()
24
+ tar_index += 1
25
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
26
+ tar = tarfile.open(tar_path, 'w')
27
+
28
+ filename = ast.literal_eval(row[0])[0]
29
+ label = ast.literal_eval(row[1])
30
+ all_caption = ast.literal_eval(row[2])
31
+ caption = ''
32
+ for single_caption in all_caption: caption += single_caption.strip('.') + "._chexpert_"
33
+ # Read the image file
34
+ image_path = os.path.join(parent_dataset_path, filename)
35
+ with open(image_path, 'rb') as img_file:
36
+ img_data = img_file.read()
37
+
38
+ # Create an in-memory tarfile
39
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
40
+ img_tarinfo.size = len(img_data)
41
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
42
+
43
+ # Add label.txt to the tarfile
44
+ label_data = label[0].encode('utf-8')
45
+ label_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.cls")
46
+ label_tarinfo.size = len(label_data)
47
+ # tar.addfile(label_tarinfo, io.BytesIO(label_data))
48
+
49
+ # Add caption.txt to the tarfile
50
+ caption_data = caption.encode('utf-8')
51
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
52
+ caption_tarinfo.size = len(caption_data)
53
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
54
+
55
+ file_count += 1
56
+
57
+ if tar:
58
+ tar.close()
59
+
60
+
61
+ if __name__ == "__main__":
62
+ # Argument parser setup
63
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
64
+ parser.add_argument('--csv_file', type=str, required=True, help="Path to the CSV file")
65
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
66
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
67
+ help="Path to the parent dataset containing images")
68
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
69
+
70
+ # Parse the arguments
71
+ args = parser.parse_args()
72
+
73
+ # Call the function with the parsed arguments
74
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
data_prepration_scripts/ChestX-ray8/chest-xray_8_webdataset.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import pandas as pd
5
+ import ast
6
+ from tqdm import tqdm
7
+ import argparse
8
+
9
+ def create_webdataset(csv_file, output_dir, parent_dataset_path, tar_size=1000):
10
+ os.makedirs(output_dir, exist_ok=True)
11
+
12
+ with open(csv_file, newline='') as f:
13
+ reader = pd.read_csv(csv_file, delimiter=',')
14
+
15
+ tar_index = 0
16
+ file_count = 0
17
+ tar = None
18
+
19
+ for row in tqdm(reader.values):
20
+ if file_count % tar_size == 0:
21
+ if tar:
22
+ tar.close()
23
+ tar_index += 1
24
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
25
+ tar = tarfile.open(tar_path, 'w')
26
+
27
+ filename = ast.literal_eval(row[0])[0]
28
+ label = ast.literal_eval(row[1])
29
+ all_caption = ast.literal_eval(row[2])
30
+ caption = ''
31
+ for single_caption in all_caption: caption += single_caption.strip('.') + "._chestxray8_"
32
+ # Read the image file
33
+ image_path = os.path.join(parent_dataset_path, filename)
34
+ with open(image_path, 'rb') as img_file:
35
+ img_data = img_file.read()
36
+
37
+ # Create an in-memory tarfile
38
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
39
+ img_tarinfo.size = len(img_data)
40
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
41
+
42
+ # Add label.txt to the tarfile
43
+ label_data = label[0].encode('utf-8')
44
+ label_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.cls")
45
+ label_tarinfo.size = len(label_data)
46
+ # tar.addfile(label_tarinfo, io.BytesIO(label_data))
47
+
48
+ # Add caption.txt to the tarfile
49
+ caption_data = caption.encode('utf-8')
50
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
51
+ caption_tarinfo.size = len(caption_data)
52
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
53
+
54
+ file_count += 1
55
+
56
+ if tar:
57
+ tar.close()
58
+
59
+ if __name__ == "__main__":
60
+ # Argument parser setup
61
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
62
+ parser.add_argument('--csv_file', type=str, required=True, help="Path to the CSV file")
63
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
64
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
65
+ help="Path to the parent dataset containing images")
66
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
67
+
68
+ # Parse the arguments
69
+ args = parser.parse_args()
70
+
71
+ # Call the function with the parsed arguments
72
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
data_prepration_scripts/LLaVA-Med/llava_med_alignment_webdataset.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ import tarfile
4
+ import io
5
+ from tqdm import tqdm
6
+ import argparse
7
+
8
+ def create_webdataset(json_file_path, output_dir, parent_dataset_path, tar_size=1000):
9
+ os.makedirs(output_dir, exist_ok=True)
10
+
11
+ with open(json_file_path, "r") as f:
12
+ json_dict = json.load(f)
13
+ tar_index = 0
14
+ file_count = 0
15
+ tar = None
16
+
17
+ for single_dict in tqdm(json_dict):
18
+ row = single_dict
19
+ # Read the image file
20
+ filename = row["image"]
21
+ image_path = os.path.join(parent_dataset_path, filename)
22
+ try:
23
+ with open(image_path, 'rb') as img_file:
24
+ img_data = img_file.read()
25
+ except:
26
+ print(f"image not found: {image_path}, skipping... ")
27
+ continue
28
+ if file_count % tar_size == 0:
29
+ if tar:
30
+ tar.close()
31
+ tar_index += 1
32
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
33
+ tar = tarfile.open(tar_path, 'w')
34
+
35
+
36
+ # label = ast.literal_eval(row[1])
37
+ all_caption = row["conversations"][1]["value"] # GPT response...
38
+ caption = all_caption.strip().strip("\n\n").strip("\n")
39
+
40
+ # Create an in-memory tarfile
41
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
42
+ img_tarinfo.size = len(img_data)
43
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
44
+
45
+
46
+ # Add caption.txt to the tarfile
47
+ caption_data = caption.encode('utf-8')
48
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
49
+ caption_tarinfo.size = len(caption_data)
50
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
51
+
52
+ file_count += 1
53
+
54
+ if tar:
55
+ tar.close()
56
+
57
+ if __name__ == "__main__":
58
+ # Argument parser setup
59
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
60
+ parser.add_argument('--csv_file', type=str, required=True, help="Path to the CSV file")
61
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
62
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
63
+ help="Path to the parent dataset containing images")
64
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
65
+
66
+ # Parse the arguments
67
+ args = parser.parse_args()
68
+
69
+ # Call the function with the parsed arguments
70
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
71
+
72
+ # Usage example
73
+ json_file = '/home/muzammal/uzair_experiments/datasets/llava_med/llava_med_alignment_500k_filtered.json'
74
+ output_dir = '/home/muzammal/uzair_experiments/datasets/llava_med/llava_med_alignment_set_webdataset/'
75
+ parent_dataset_path = '/home/muzammal/uzair_experiments/datasets/llava_med/images/'
76
+ create_webdataset(json_file, output_dir, parent_dataset_path)
data_prepration_scripts/LLaVA-Med/llava_med_instruct_webdataset.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ import tarfile
4
+ import io
5
+ import argparse
6
+ from tqdm import tqdm
7
+
8
+ def create_webdataset(json_file_path, output_dir, parent_dataset_path, tar_size=1000):
9
+ os.makedirs(output_dir, exist_ok=True)
10
+
11
+ with open(json_file_path, "r") as f:
12
+ json_dict = json.load(f)
13
+ tar_index = 0
14
+ file_count = 0
15
+ tar = None
16
+ # One for loop for main caption
17
+ for single_key in json_dict.keys():
18
+
19
+ my_list = json_dict[single_key] # this is a list
20
+ for single_entry in tqdm(my_list):
21
+ # Read the image file
22
+ filename = single_entry["pair_id"] + ".jpg"
23
+ image_path = os.path.join(parent_dataset_path, filename)
24
+ try:
25
+ with open(image_path, 'rb') as img_file:
26
+ img_data = img_file.read()
27
+ except:
28
+ print(f"image not found: {image_path}, skipping... ")
29
+ continue
30
+
31
+ # label = ast.literal_eval(row[1])
32
+ all_caption = single_entry["fig_caption"] # GPT response...
33
+ if str(all_caption) == 'nan':
34
+ print(f"original caption not found: {image_path}, skipping... ")
35
+ continue
36
+ caption = all_caption.strip().strip("\n\n").strip("\n")
37
+ if file_count % tar_size == 0:
38
+ if tar:
39
+ tar.close()
40
+ tar_index += 1
41
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
42
+ tar = tarfile.open(tar_path, 'w')
43
+
44
+ # Create an in-memory tarfile
45
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
46
+ img_tarinfo.size = len(img_data)
47
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
48
+
49
+ # Add caption.txt to the tarfile
50
+ caption_data = caption.encode('utf-8')
51
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
52
+ caption_tarinfo.size = len(caption_data)
53
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
54
+
55
+ file_count += 1
56
+
57
+ # One for loop for inline mention as the captions...
58
+ for single_key in json_dict.keys():
59
+
60
+ my_list = json_dict[single_key] # this is a list
61
+ for single_entry in tqdm(my_list):
62
+ # Read the image file
63
+ filename = single_entry["pair_id"] + ".jpg"
64
+ image_path = os.path.join(parent_dataset_path, filename)
65
+ try:
66
+ with open(image_path, 'rb') as img_file:
67
+ img_data = img_file.read()
68
+ except:
69
+ print(f"image not found: {image_path}, skipping... ")
70
+ continue
71
+
72
+ if single_entry["in_text_mention"] is None:
73
+ print(f"Inline caption not found: {image_path}, skipping... ")
74
+ continue
75
+ all_caption = single_entry["in_text_mention"][0]['tokens'] # GPT response...
76
+ caption = all_caption.strip().strip("\n\n").strip("\n")
77
+ if file_count % tar_size == 0:
78
+ if tar:
79
+ tar.close()
80
+ tar_index += 1
81
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
82
+ tar = tarfile.open(tar_path, 'w')
83
+
84
+ # Create an in-memory tarfile
85
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
86
+ img_tarinfo.size = len(img_data)
87
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
88
+
89
+ # Add caption.txt to the tarfile
90
+ caption_data = caption.encode('utf-8')
91
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
92
+ caption_tarinfo.size = len(caption_data)
93
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
94
+
95
+ file_count += 1
96
+ if tar:
97
+ tar.close()
98
+
99
+
100
+ # Usage example
101
+ json_file = '/home/muzammal/uzair_experiments/datasets/llava_med/llava_med_instruct_fig_captions.json'
102
+ output_dir = '/home/muzammal/uzair_experiments/datasets/llava_med/llava_med_hq_60k_set_webdataset/'
103
+ parent_dataset_path = '/home/muzammal/uzair_experiments/datasets/llava_med/images/'
104
+ create_webdataset(json_file, output_dir, parent_dataset_path)
data_prepration_scripts/MIMIC-CXR/webdataset_mimic_cxr.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import pandas as pd
5
+ import ast
6
+ from tqdm import tqdm
7
+ import argparse
8
+
9
+ def create_webdataset(csv_file, output_dir, parent_dataset_path, tar_size=1000):
10
+ os.makedirs(output_dir, exist_ok=True)
11
+
12
+ with open(csv_file, newline='') as f:
13
+ reader = pd.read_csv(csv_file, delimiter=',')
14
+
15
+ tar_index = 0
16
+ file_count = 0
17
+ tar = None
18
+ total_skipped = 0
19
+ for row in tqdm(reader.values):
20
+ filename = ast.literal_eval(row[0])[0]
21
+ # Read the image file
22
+ image_path = os.path.join(parent_dataset_path, filename)
23
+ if not os.path.exists(image_path):
24
+ print(f"Image path {image_path} does not exist")
25
+ print(f"Skipping this iteration")
26
+ total_skipped += 1
27
+ continue
28
+ if file_count % tar_size == 0:
29
+ if tar:
30
+ tar.close()
31
+ tar_index += 1
32
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
33
+ tar = tarfile.open(tar_path, 'w')
34
+
35
+ label = ast.literal_eval(row[1])
36
+ all_caption = ast.literal_eval(row[2])
37
+ report = row[3]
38
+ if type(report) != str:
39
+ report = "noreportpresent"
40
+ caption = ''
41
+ # print(f"REPORT IS {report} \n")
42
+ for single_caption in all_caption: caption += single_caption.strip('.') + "._mimiccxr_"
43
+ caption = caption + "_mimiccxr_" + report
44
+ with open(image_path, 'rb') as img_file:
45
+ img_data = img_file.read()
46
+
47
+ # Create an in-memory tarfile
48
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
49
+ img_tarinfo.size = len(img_data)
50
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
51
+
52
+ # Add label.txt to the tarfile
53
+ label_data = label[0].encode('utf-8')
54
+ label_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.cls")
55
+ label_tarinfo.size = len(label_data)
56
+
57
+ # Add caption.txt to the tarfile
58
+ caption_data = caption.encode('utf-8')
59
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
60
+ caption_tarinfo.size = len(caption_data)
61
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
62
+
63
+ file_count += 1
64
+
65
+ if tar:
66
+ tar.close()
67
+
68
+ print(f"Total {total_skipped} files have been skipped because no image was found for that in our folder.")
69
+
70
+ if __name__ == "__main__":
71
+ # Argument parser setup
72
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
73
+ parser.add_argument('--csv_file', type=str, required=True, help="Path to the CSV file")
74
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
75
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
76
+ help="Path to the parent dataset containing images")
77
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
78
+
79
+ # Parse the arguments
80
+ args = parser.parse_args()
81
+
82
+ # Call the function with the parsed arguments
83
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
data_prepration_scripts/Openi/openi_webdataset.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import json
5
+ from tqdm.contrib import tzip
6
+ import argparse
7
+
8
+ def create_webdataset(orig_file_path, refined_file_path, output_dir, parent_dataset_path, tar_size=1000):
9
+ os.makedirs(output_dir, exist_ok=True)
10
+
11
+ with open(orig_file_path, "r") as f:
12
+ reader = json.load(f)['annotations']
13
+ reader_refined = json.load(open(refined_file_path, "r"))['refined_captions']
14
+ tar_index = 0
15
+ file_count = 0
16
+ tar = None
17
+
18
+ for full_caption, refined_caption_list in tzip(reader, reader_refined):
19
+ if file_count % tar_size == 0:
20
+ if tar:
21
+ tar.close()
22
+ tar_index += 1
23
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
24
+ tar = tarfile.open(tar_path, 'w')
25
+
26
+ filename = full_caption['image_id']
27
+ caption_orig = [full_caption['caption']]
28
+ caption_orig += refined_caption_list
29
+
30
+ all_caption = caption_orig
31
+ caption = ''
32
+ for single_caption in all_caption: caption += single_caption.strip('.') + "._openi_"
33
+ # Read the image file
34
+ image_path = os.path.join(parent_dataset_path, filename + ".png")
35
+ with open(image_path, 'rb') as img_file:
36
+ img_data = img_file.read()
37
+
38
+ # Create an in-memory tarfile
39
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
40
+ img_tarinfo.size = len(img_data)
41
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
42
+
43
+ # Add caption.txt to the tarfile
44
+ caption_data = caption.encode('utf-8')
45
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
46
+ caption_tarinfo.size = len(caption_data)
47
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
48
+
49
+ file_count += 1
50
+
51
+ if tar:
52
+ tar.close()
53
+
54
+
55
+ if __name__ == "__main__":
56
+ # Argument parser setup
57
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
58
+ parser.add_argument('--original_json_file_summarizations_path', type=str, required=True)
59
+ parser.add_argument('--gpt_text_descriptions_path', type=str, required=True, help="Path to the CSV file")
60
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
61
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
62
+ help="Path to the parent dataset containing images")
63
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
64
+
65
+ # Parse the arguments
66
+ args = parser.parse_args()
67
+
68
+ # Call the function with the parsed arguments
69
+ create_webdataset(args.original_json_file_summarizations_path, args.gpt_text_descriptions_path, args.output_dir,
70
+ args.parent_dataset_path)
data_prepration_scripts/PMC-OA/pmc_oa_webdataset.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ import tarfile
4
+ import io
5
+ from tqdm import tqdm
6
+ import argparse
7
+
8
+ def create_webdataset(csv_file, output_dir, parent_dataset_path, tar_size=1000):
9
+ os.makedirs(output_dir, exist_ok=True)
10
+
11
+ with open(csv_file, "r") as f:
12
+ json_list = list(f)
13
+ tar_index = 0
14
+ file_count = 0
15
+ tar = None
16
+
17
+ for row_raw in tqdm(json_list):
18
+ row = json.loads(row_raw)
19
+ if file_count % tar_size == 0:
20
+ if tar:
21
+ tar.close()
22
+ tar_index += 1
23
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
24
+ tar = tarfile.open(tar_path, 'w')
25
+
26
+ filename = row["image"]
27
+ # label = ast.literal_eval(row[1])
28
+ all_caption = row["caption"]
29
+ caption = all_caption.strip().strip("\n\n").strip("\n")
30
+ # Read the image file
31
+ image_path = os.path.join(parent_dataset_path, filename)
32
+ with open(image_path, 'rb') as img_file:
33
+ img_data = img_file.read()
34
+
35
+ # Create an in-memory tarfile
36
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
37
+ img_tarinfo.size = len(img_data)
38
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
39
+
40
+ # Add caption.txt to the tarfile
41
+ caption_data = caption.encode('utf-8')
42
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
43
+ caption_tarinfo.size = len(caption_data)
44
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
45
+
46
+ file_count += 1
47
+
48
+ if tar:
49
+ tar.close()
50
+
51
+ if __name__ == "__main__":
52
+ # Argument parser setup
53
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
54
+ parser.add_argument('--csv_file', type=str, required=True, help="Path to the CSV file")
55
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
56
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
57
+ help="Path to the parent dataset containing images")
58
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
59
+
60
+ # Parse the arguments
61
+ args = parser.parse_args()
62
+
63
+ # Call the function with the parsed arguments
64
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
data_prepration_scripts/Quilt-1M/quilt_1m_webdataset.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import pandas as pd
5
+ from tqdm import tqdm
6
+ import argparse
7
+
8
+ def create_webdataset(csv_file, output_dir, parent_dataset_path, tar_size=1000):
9
+ os.makedirs(output_dir, exist_ok=True)
10
+
11
+ with open(csv_file, newline='') as f:
12
+ reader = pd.read_csv(csv_file, delimiter=',')
13
+
14
+ tar_index = 0
15
+ file_count = 0
16
+ tar = None
17
+
18
+ for row in tqdm(reader.values):
19
+ filename = row[2]
20
+ # label = ast.literal_eval(row[1])
21
+ all_caption = row[1]
22
+ if str(all_caption) == 'nan':
23
+ continue
24
+ caption = all_caption.strip().strip("\n\n").strip("\n")
25
+ # Read the image file
26
+ image_path = os.path.join(parent_dataset_path, filename)
27
+ try:
28
+ with open(image_path, 'rb') as img_file:
29
+ img_data = img_file.read()
30
+ except:
31
+ print(f"image not found: {image_path} \n subset is {row[3]} ")
32
+ continue
33
+ if file_count % tar_size == 0:
34
+ if tar:
35
+ tar.close()
36
+ tar_index += 1
37
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
38
+ tar = tarfile.open(tar_path, 'w')
39
+
40
+
41
+ # Create an in-memory tarfile
42
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
43
+ img_tarinfo.size = len(img_data)
44
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
45
+
46
+ # Add caption.txt to the tarfile
47
+ caption_data = caption.encode('utf-8')
48
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
49
+ caption_tarinfo.size = len(caption_data)
50
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
51
+
52
+ file_count += 1
53
+
54
+ if tar:
55
+ tar.close()
56
+
57
+ if __name__ == "__main__":
58
+ # Argument parser setup
59
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
60
+ parser.add_argument('--csv_file', type=str, required=True, help="Path to the CSV file")
61
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
62
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
63
+ help="Path to the parent dataset containing images")
64
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
65
+
66
+ # Parse the arguments
67
+ args = parser.parse_args()
68
+
69
+ # Call the function with the parsed arguments
70
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
data_prepration_scripts/ROCOV2/roco_webdataset.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import pandas as pd
5
+ from tqdm import tqdm
6
+ import argparse
7
+
8
+ def create_webdataset(csv_file, output_dir, parent_dataset_path, tar_size=1000):
9
+ os.makedirs(output_dir, exist_ok=True)
10
+
11
+ with open(csv_file, newline='') as f:
12
+ reader = pd.read_csv(csv_file, delimiter=',')
13
+
14
+ tar_index = 0
15
+ file_count = 0
16
+ tar = None
17
+
18
+ for row in tqdm(reader.values):
19
+ if file_count % tar_size == 0:
20
+ if tar:
21
+ tar.close()
22
+ tar_index += 1
23
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
24
+ tar = tarfile.open(tar_path, 'w')
25
+
26
+ filename = row[0] + '.jpg'
27
+ # label = ast.literal_eval(row[1])
28
+ all_caption = row[1]
29
+ caption = all_caption.strip().strip("\n\n").strip("\n")
30
+ # Read the image file
31
+ image_path = os.path.join(parent_dataset_path, filename)
32
+ with open(image_path, 'rb') as img_file:
33
+ img_data = img_file.read()
34
+
35
+ # Create an in-memory tarfile
36
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
37
+ img_tarinfo.size = len(img_data)
38
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
39
+
40
+ # Add caption.txt to the tarfile
41
+ caption_data = caption.encode('utf-8')
42
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
43
+ caption_tarinfo.size = len(caption_data)
44
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
45
+
46
+ file_count += 1
47
+
48
+ if tar:
49
+ tar.close()
50
+
51
+
52
+ if __name__ == "__main__":
53
+ # Argument parser setup
54
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
55
+ parser.add_argument('--csv_file', type=str, required=True, help="Path to the CSV file")
56
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
57
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
58
+ help="Path to the parent dataset containing images")
59
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
60
+
61
+ # Parse the arguments
62
+ args = parser.parse_args()
63
+
64
+ # Call the function with the parsed arguments
65
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
data_prepration_scripts/RadImageNet/radimagenet_webdataset.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import pandas as pd
5
+ import ast
6
+ from tqdm import tqdm
7
+ import argparse
8
+
9
+ def create_webdataset(csv_file, output_dir, parent_dataset_path, tar_size=1000):
10
+ os.makedirs(output_dir, exist_ok=True)
11
+
12
+ with open(csv_file, newline='') as f:
13
+ reader = pd.read_csv(csv_file, delimiter=',')
14
+
15
+ tar_index = 0
16
+ file_count = 0
17
+ tar = None
18
+
19
+ for row in tqdm(reader.values):
20
+ if file_count % tar_size == 0:
21
+ if tar:
22
+ tar.close()
23
+ tar_index += 1
24
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
25
+ tar = tarfile.open(tar_path, 'w')
26
+
27
+ filename = ast.literal_eval(row[0])[0]
28
+ label = ast.literal_eval(row[1])
29
+ all_caption = ast.literal_eval(row[2])
30
+ caption = ''
31
+ for single_caption in all_caption: caption += single_caption + "._radimagenet_"
32
+ # Read the image file
33
+ image_path = os.path.join(parent_dataset_path, filename)
34
+ with open(image_path, 'rb') as img_file:
35
+ img_data = img_file.read()
36
+
37
+ # Create an in-memory tarfile
38
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
39
+ img_tarinfo.size = len(img_data)
40
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
41
+
42
+ # Add label.txt to the tarfile
43
+ label_data = label[0].encode('utf-8')
44
+ label_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.cls")
45
+ label_tarinfo.size = len(label_data)
46
+ # tar.addfile(label_tarinfo, io.BytesIO(label_data))
47
+
48
+ # Add caption.txt to the tarfile
49
+ caption_data = caption.encode('utf-8')
50
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
51
+ caption_tarinfo.size = len(caption_data)
52
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
53
+
54
+ file_count += 1
55
+
56
+ if tar:
57
+ tar.close()
58
+
59
+ if __name__ == "__main__":
60
+ # Argument parser setup
61
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
62
+ parser.add_argument('--csv_file', type=str, required=True, help="Path to the CSV file")
63
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
64
+ parser.add_argument('--parent_dataset_path', type=str, required=True,
65
+ help="Path to the parent dataset containing images")
66
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
67
+
68
+ # Parse the arguments
69
+ args = parser.parse_args()
70
+
71
+ # Call the function with the parsed arguments
72
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
data_prepration_scripts/Retinal-Datasets/retina_webdataset_part1.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import pandas as pd
5
+ import ast
6
+ from tqdm import tqdm
7
+ import argparse
8
+
9
+ banned_categories = ['myopia', 'cataract', 'macular hole', 'retinitis pigmentosa', "myopic", "myope", "myop", "retinitis"]
10
+
11
+ def create_webdataset(main_csv_directory, image_dir_path, output_dir, tar_size=1000):
12
+ os.makedirs(output_dir, exist_ok=True)
13
+ # Load both csv files
14
+ all_datasets = os.listdir(main_csv_directory)
15
+ tar_index = 0
16
+ file_count = 0
17
+ tar = None
18
+ for iDataset in tqdm(all_datasets):
19
+ print("Processing data: " + iDataset)
20
+ if iDataset == "06_DEN.csv" or iDataset == "39_MM_Retinal_dataset.csv" or \
21
+ iDataset == "28_OIA-DDR_revised.csv" or iDataset == '07_LAG_revised.csv' \
22
+ or iDataset == '01_EYEPACS_revised.csv':
23
+ continue
24
+ dataframe = pd.read_csv(main_csv_directory + iDataset)
25
+ selected_id_list = range(len(dataframe)) # 100%数据 100% data
26
+
27
+ for i in selected_id_list:
28
+ if file_count % tar_size == 0:
29
+ if tar:
30
+ tar.close()
31
+ tar_index += 1
32
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
33
+ tar = tarfile.open(tar_path, 'w')
34
+ data_i = dataframe.loc[i, :].to_dict() # image,attributes,categories Turn each line into a dictionary
35
+
36
+ image_file_name = data_i['filename']
37
+ all_caption = ast.literal_eval(data_i['captions'])
38
+ sentence_level_caption = [data_i['sentence_level_captions']]
39
+ all_caption += sentence_level_caption
40
+ # Now need to process the captions
41
+ if str(all_caption) == 'nan':
42
+ continue
43
+
44
+ caption = ''
45
+ for single_caption in all_caption: caption += single_caption.strip('.') + "._all_retina_merged_"
46
+ # Read the image file
47
+ image_path = os.path.join(image_dir_path, image_file_name)
48
+ try:
49
+ with open(image_path, 'rb') as img_file:
50
+ img_data = img_file.read()
51
+ except:
52
+ print(f"image not found: {image_path} \n subset is {image_file_name} ")
53
+ continue
54
+
55
+
56
+ # Create an in-memory tarfile
57
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
58
+ img_tarinfo.size = len(img_data)
59
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
60
+
61
+ # Add caption.txt to the tarfile
62
+ caption_data = caption.encode('utf-8')
63
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
64
+ caption_tarinfo.size = len(caption_data)
65
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
66
+
67
+ file_count += 1
68
+
69
+ if tar:
70
+ tar.close()
71
+
72
+ if __name__ == "__main__":
73
+ # Argument parser setup
74
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
75
+ parser.add_argument('--csv_files_directory', type=str, required=True, help="Path to the CSV files for all datasets")
76
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
77
+ parser.add_argument('--parent_datasets_path', type=str, required=True,
78
+ help="Path to the parent folder containing Retina Datasets folders")
79
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
80
+
81
+ # Parse the arguments
82
+ args = parser.parse_args()
83
+
84
+ # Call the function with the parsed arguments
85
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
86
+
data_prepration_scripts/Retinal-Datasets/retina_webdataset_part2.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import random
3
+ import tarfile
4
+ import io
5
+ import pandas as pd
6
+ from tqdm import tqdm
7
+ import argparse
8
+
9
+ banned_categories = ['myopia', 'cataract', 'macular hole', 'retinitis pigmentosa', "myopic", "myope", "myop", "retinitis"]
10
+
11
+ def create_webdataset(main_csv_directory, image_dir_path, output_dir, tar_size=1000):
12
+ os.makedirs(output_dir, exist_ok=True)
13
+ # Load both csv files
14
+ tar_index = 0
15
+ file_count = 0
16
+ tar = None
17
+ # Now lets do it for that vision language model
18
+ dataframe = pd.read_csv(main_csv_directory + "06_DEN.csv")
19
+ selected_id_list = range(len(dataframe)) # 100%数据 100% data
20
+
21
+ for i in tqdm(selected_id_list):
22
+ if file_count % tar_size == 0:
23
+ if tar:
24
+ tar.close()
25
+ tar_index += 1
26
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
27
+ tar = tarfile.open(tar_path, 'w')
28
+ data_i = dataframe.loc[i, :].to_dict() # image,attributes,categories Turn each line into a dictionary
29
+ data_i["categories"] = eval(data_i["categories"])
30
+ data_i["atributes"] = eval(data_i["atributes"])
31
+ all_categories = data_i["categories"]
32
+ final_caption = None
33
+ for single_category in all_categories:
34
+ # Filtering noisy captions...
35
+ if ("year" not in single_category.strip('/')) and ("//" not in single_category.strip('/')):
36
+ final_caption = "The fundus image of " + single_category
37
+ if file_count < 50:
38
+ print(final_caption)
39
+
40
+ if final_caption == None:
41
+ final_caption = random.sample(all_categories, 1)[0]
42
+ # print(final_caption)
43
+
44
+ image_file_name = data_i['image']
45
+ # Now need to process the captions
46
+ if str(final_caption) == 'nan':
47
+ continue
48
+
49
+ caption = final_caption
50
+ # Read the image file
51
+ image_path = os.path.join(image_dir_path, image_file_name)
52
+ try:
53
+ with open(image_path, 'rb') as img_file:
54
+ img_data = img_file.read()
55
+ except:
56
+ print(f"image not found: {image_path} \n subset is {image_file_name} ")
57
+ continue
58
+
59
+ # Create an in-memory tarfile
60
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
61
+ img_tarinfo.size = len(img_data)
62
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
63
+
64
+ # Add caption.txt to the tarfile
65
+ caption_data = caption.encode('utf-8')
66
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
67
+ caption_tarinfo.size = len(caption_data)
68
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
69
+
70
+ file_count += 1
71
+
72
+
73
+ if tar:
74
+ tar.close()
75
+
76
+ if __name__ == "__main__":
77
+ # Argument parser setup
78
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
79
+ parser.add_argument('--csv_files_directory', type=str, required=True, help="Path to the CSV files for all datasets")
80
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
81
+ parser.add_argument('--parent_datasets_path', type=str, required=True,
82
+ help="Path to the parent folder containing Retina Datasets folders")
83
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
84
+
85
+ # Parse the arguments
86
+ args = parser.parse_args()
87
+
88
+ # Call the function with the parsed arguments
89
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
90
+
91
+ if __name__ == "__main__":
92
+ # Argument parser setup
93
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
94
+ parser.add_argument('--csv_files_directory', type=str, required=True, help="Path to the CSV files for all datasets")
95
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
96
+ parser.add_argument('--parent_datasets_path', type=str, required=True,
97
+ help="Path to the parent folder containing Retina Datasets folders")
98
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
99
+
100
+ # Parse the arguments
101
+ args = parser.parse_args()
102
+
103
+ # Call the function with the parsed arguments
104
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
105
+
data_prepration_scripts/Retinal-Datasets/retina_webdataset_part3.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import tarfile
3
+ import io
4
+ import pandas as pd
5
+ from tqdm import tqdm
6
+ import argparse
7
+
8
+ banned_categories = ['myopia', 'cataract', 'macular hole', 'retinitis pigmentosa', "myopic", "myope", "myop", "retinitis"]
9
+
10
+ def create_webdataset(main_csv_directory, image_dir_path, output_dir, tar_size=1000):
11
+ os.makedirs(output_dir, exist_ok=True)
12
+ # Load both csv files
13
+ tar_index = 0
14
+ file_count = 0
15
+ tar = None
16
+ # Now lets do it for that vision language model
17
+ dataframe = pd.read_csv(main_csv_directory + "39_MM_Retinal_dataset.csv")
18
+ selected_id_list = range(len(dataframe)) # 100%数据 100% data
19
+
20
+ for i in tqdm(selected_id_list):
21
+ if file_count % tar_size == 0:
22
+ if tar:
23
+ tar.close()
24
+ tar_index += 1
25
+ tar_path = os.path.join(output_dir, f"dataset-{tar_index:06d}.tar")
26
+ tar = tarfile.open(tar_path, 'w')
27
+ sample_df = dataframe.loc[i, :].to_dict() # image,attributes,categories Turn each line into a dictionary
28
+ image_path = sample_df["image"]
29
+ caption = sample_df["caption"]
30
+ final_caption = caption
31
+ image_file_name = image_path
32
+ # Now need to process the captions
33
+ if str(final_caption) == 'nan':
34
+ continue
35
+
36
+ caption = final_caption
37
+ # Read the image file
38
+ image_path = os.path.join(image_dir_path, image_file_name)
39
+ try:
40
+ with open(image_path, 'rb') as img_file:
41
+ img_data = img_file.read()
42
+ except:
43
+ print(f"image not found: {image_path} \n subset is {image_file_name} ")
44
+ continue
45
+
46
+ # Create an in-memory tarfile
47
+ img_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.jpg")
48
+ img_tarinfo.size = len(img_data)
49
+ tar.addfile(img_tarinfo, io.BytesIO(img_data))
50
+
51
+ # Add caption.txt to the tarfile
52
+ caption_data = caption.encode('utf-8')
53
+ caption_tarinfo = tarfile.TarInfo(name=f"{file_count:06d}.txt")
54
+ caption_tarinfo.size = len(caption_data)
55
+ tar.addfile(caption_tarinfo, io.BytesIO(caption_data))
56
+
57
+ file_count += 1
58
+
59
+
60
+ if tar:
61
+ tar.close()
62
+
63
+
64
+ if __name__ == "__main__":
65
+ # Argument parser setup
66
+ parser = argparse.ArgumentParser(description="Create a WebDataset from CSV")
67
+ parser.add_argument('--csv_files_directory', type=str, required=True, help="Path to the CSV files for all datasets")
68
+ parser.add_argument('--output_dir', type=str, required=True, help="Directory to store the output tar files")
69
+ parser.add_argument('--parent_datasets_path', type=str, required=True,
70
+ help="Path to the parent folder containing Retina Datasets folders")
71
+ parser.add_argument('--tar_size', type=int, default=1000, help="Number of files per tar file")
72
+
73
+ # Parse the arguments
74
+ args = parser.parse_args()
75
+
76
+ # Call the function with the parsed arguments
77
+ create_webdataset(args.csv_file, args.output_dir, args.parent_dataset_path, args.tar_size)
getting_started_unimed_clip.ipynb ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "outputs": [],
7
+ "source": [
8
+ "# Switch path to root of project\n",
9
+ "import os\n",
10
+ "os.environ[\"CUDA_VISIBLE_DEVICES\"]=\"0\"\n",
11
+ "# Get the current working directory\n",
12
+ "current_dir = os.getcwd()\n",
13
+ "src_path = os.path.join(current_dir, 'src')\n",
14
+ "os.chdir(src_path)"
15
+ ],
16
+ "metadata": {
17
+ "collapsed": false,
18
+ "pycharm": {
19
+ "name": "#%%\n"
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "cell_type": "code",
25
+ "execution_count": null,
26
+ "outputs": [],
27
+ "source": [
28
+ "from open_clip import create_model_and_transforms, get_mean_std\n",
29
+ "from open_clip import HFTokenizer\n",
30
+ "from PIL import Image\n",
31
+ "import torch\n",
32
+ "from urllib.request import urlopen"
33
+ ],
34
+ "metadata": {
35
+ "collapsed": false,
36
+ "pycharm": {
37
+ "name": "#%%\n"
38
+ }
39
+ }
40
+ },
41
+ {
42
+ "cell_type": "code",
43
+ "execution_count": null,
44
+ "outputs": [],
45
+ "source": [
46
+ "# Define main parameters\n",
47
+ "model = 'ViT-L-14-336-quickgelu' # available pretrained weights ['ViT-L-14-336-quickgelu', 'ViT-B-16-quickgelu']\n",
48
+ "pretrained = \"./unimed_clip_vit_l14_base_text_encoder.pt\" # Path to pretrained weights\n",
49
+ "text_encoder_name = \"microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract\" # available pretrained weights [\"microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract\", \"microsoft/BiomedNLP-BiomedBERT-large-uncased-abstract\"]\n",
50
+ "mean, std = get_mean_std()\n",
51
+ "device='cuda'"
52
+ ],
53
+ "metadata": {
54
+ "collapsed": false,
55
+ "pycharm": {
56
+ "name": "#%%\n"
57
+ }
58
+ }
59
+ },
60
+ {
61
+ "cell_type": "code",
62
+ "execution_count": null,
63
+ "outputs": [],
64
+ "source": [
65
+ "model, _, preprocess = create_model_and_transforms(\n",
66
+ " model,\n",
67
+ " pretrained,\n",
68
+ " precision='amp',\n",
69
+ " device=device,\n",
70
+ " force_quick_gelu=True,\n",
71
+ " pretrained_image=False,\n",
72
+ " mean=mean, std=std,\n",
73
+ " inmem=True,\n",
74
+ " text_encoder_name=text_encoder_name,\n",
75
+ ")"
76
+ ],
77
+ "metadata": {
78
+ "collapsed": false,
79
+ "pycharm": {
80
+ "name": "#%%\n"
81
+ }
82
+ }
83
+ },
84
+ {
85
+ "cell_type": "code",
86
+ "execution_count": null,
87
+ "outputs": [],
88
+ "source": [
89
+ "tokenizer = HFTokenizer(\n",
90
+ " text_encoder_name,\n",
91
+ " context_length=256,\n",
92
+ " **{},\n",
93
+ ")"
94
+ ],
95
+ "metadata": {
96
+ "collapsed": false,
97
+ "pycharm": {
98
+ "name": "#%%\n"
99
+ }
100
+ }
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "execution_count": null,
105
+ "outputs": [],
106
+ "source": [
107
+ "# Zeroshot Inference"
108
+ ],
109
+ "metadata": {
110
+ "collapsed": false,
111
+ "pycharm": {
112
+ "name": "#%%\n"
113
+ }
114
+ }
115
+ },
116
+ {
117
+ "cell_type": "code",
118
+ "execution_count": null,
119
+ "outputs": [],
120
+ "source": [
121
+ "# Zero-shot image classification\n",
122
+ "template = 'this is a photo of '\n",
123
+ "labels = [\n",
124
+ " 'adenocarcinoma histopathology',\n",
125
+ " 'brain MRI',\n",
126
+ " 'covid line chart',\n",
127
+ " 'squamous cell carcinoma histopathology',\n",
128
+ " 'immunohistochemistry histopathology',\n",
129
+ " 'bone X-ray',\n",
130
+ " 'chest X-ray',\n",
131
+ " 'pie chart',\n",
132
+ " 'hematoxylin and eosin histopathology'\n",
133
+ "]"
134
+ ],
135
+ "metadata": {
136
+ "collapsed": false,
137
+ "pycharm": {
138
+ "name": "#%%\n"
139
+ }
140
+ }
141
+ },
142
+ {
143
+ "cell_type": "code",
144
+ "execution_count": null,
145
+ "outputs": [],
146
+ "source": [
147
+ "dataset_url = 'https://huggingface.co/microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224/resolve/main/example_data/biomed_image_classification_example_data/'\n",
148
+ "test_imgs = [\n",
149
+ " 'squamous_cell_carcinoma_histopathology.jpeg',\n",
150
+ " 'H_and_E_histopathology.jpg',\n",
151
+ " 'bone_X-ray.jpg',\n",
152
+ " 'adenocarcinoma_histopathology.jpg',\n",
153
+ " 'covid_line_chart.png',\n",
154
+ " 'IHC_histopathology.jpg',\n",
155
+ " 'chest_X-ray.jpg',\n",
156
+ " 'brain_MRI.jpg',\n",
157
+ " 'pie_chart.png'\n",
158
+ "]"
159
+ ],
160
+ "metadata": {
161
+ "collapsed": false,
162
+ "pycharm": {
163
+ "name": "#%%\n"
164
+ }
165
+ }
166
+ },
167
+ {
168
+ "cell_type": "code",
169
+ "execution_count": null,
170
+ "outputs": [],
171
+ "source": [
172
+ "images = torch.stack([preprocess(Image.open(urlopen(dataset_url + img))) for img in test_imgs]).to(device)\n",
173
+ "texts = [tokenizer(template + cls_text).to(next(model.parameters()).device, non_blocking=True) for cls_text in labels]\n",
174
+ "texts = torch.cat(texts, dim=0)\n",
175
+ "with torch.no_grad():\n",
176
+ " text_features = model.encode_text(texts)\n",
177
+ " text_features = text_features / text_features.norm(dim=-1, keepdim=True)\n",
178
+ " image_features = model.encode_image(images)\n",
179
+ " image_features = image_features / image_features.norm(dim=-1, keepdim=True)\n",
180
+ " logits = (image_features @ text_features.t()).detach().softmax(dim=-1)\n",
181
+ " sorted_indices = torch.argsort(logits, dim=-1, descending=True)\n",
182
+ "\n",
183
+ " logits = logits.cpu().numpy()\n",
184
+ " sorted_indices = sorted_indices.cpu().numpy()\n",
185
+ "\n",
186
+ "top_k = -1\n",
187
+ "\n",
188
+ "for i, img in enumerate(test_imgs):\n",
189
+ " pred = labels[sorted_indices[i][0]]\n",
190
+ "\n",
191
+ " top_k = len(labels) if top_k == -1 else top_k\n",
192
+ " print(img.split('/')[-1] + ':')\n",
193
+ " for j in range(top_k):\n",
194
+ " jth_index = sorted_indices[i][j]\n",
195
+ " print(f'{labels[jth_index]}: {logits[i][jth_index]}')\n",
196
+ " print('\\n')"
197
+ ],
198
+ "metadata": {
199
+ "collapsed": false,
200
+ "pycharm": {
201
+ "name": "#%%\n"
202
+ }
203
+ }
204
+ }
205
+ ],
206
+ "metadata": {
207
+ "kernelspec": {
208
+ "display_name": "Python 3",
209
+ "language": "python",
210
+ "name": "python3"
211
+ },
212
+ "language_info": {
213
+ "codemirror_mode": {
214
+ "name": "ipython",
215
+ "version": 2
216
+ },
217
+ "file_extension": ".py",
218
+ "mimetype": "text/x-python",
219
+ "name": "python",
220
+ "nbconvert_exporter": "python",
221
+ "pygments_lexer": "ipython2",
222
+ "version": "2.7.6"
223
+ }
224
+ },
225
+ "nbformat": 4,
226
+ "nbformat_minor": 0
227
+ }
local_data/08_ODIR200x3.csv ADDED
@@ -0,0 +1,601 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,image,atributes,categories
2
+ 0,08_ODIR-5K/preprocessed_images/0_right.jpg,[],['normal']
3
+ 1,08_ODIR-5K/preprocessed_images/0_left.jpg,[],['cataract']
4
+ 2,08_ODIR-5K/preprocessed_images/1_right.jpg,[],['normal']
5
+ 3,08_ODIR-5K/preprocessed_images/1_left.jpg,[],['normal']
6
+ 4,08_ODIR-5K/preprocessed_images/8_right.jpg,[],['normal']
7
+ 5,08_ODIR-5K/preprocessed_images/8_left.jpg,[],['normal']
8
+ 6,08_ODIR-5K/preprocessed_images/13_right.jpg,[],['pathologic myopia']
9
+ 7,08_ODIR-5K/preprocessed_images/13_left.jpg,[],['pathologic myopia']
10
+ 8,08_ODIR-5K/preprocessed_images/16_right.jpg,[],['pathologic myopia']
11
+ 9,08_ODIR-5K/preprocessed_images/16_left.jpg,[],['normal']
12
+ 10,08_ODIR-5K/preprocessed_images/18_right.jpg,[],['pathologic myopia']
13
+ 11,08_ODIR-5K/preprocessed_images/18_left.jpg,[],['pathologic myopia']
14
+ 12,08_ODIR-5K/preprocessed_images/24_right.jpg,[],['cataract']
15
+ 13,08_ODIR-5K/preprocessed_images/24_left.jpg,[],['normal']
16
+ 14,08_ODIR-5K/preprocessed_images/35_right.jpg,[],['normal']
17
+ 15,08_ODIR-5K/preprocessed_images/35_left.jpg,[],['pathologic myopia']
18
+ 16,08_ODIR-5K/preprocessed_images/84_right.jpg,[],['normal']
19
+ 17,08_ODIR-5K/preprocessed_images/84_left.jpg,[],['normal']
20
+ 18,08_ODIR-5K/preprocessed_images/103_right.jpg,[],['normal']
21
+ 19,08_ODIR-5K/preprocessed_images/103_left.jpg,[],['cataract']
22
+ 20,08_ODIR-5K/preprocessed_images/106_right.jpg,[],['pathologic myopia']
23
+ 21,08_ODIR-5K/preprocessed_images/106_left.jpg,[],['pathologic myopia']
24
+ 22,08_ODIR-5K/preprocessed_images/112_right.jpg,[],['cataract']
25
+ 23,08_ODIR-5K/preprocessed_images/112_left.jpg,[],['normal']
26
+ 24,08_ODIR-5K/preprocessed_images/144_right.jpg,[],['normal']
27
+ 25,08_ODIR-5K/preprocessed_images/144_left.jpg,[],['pathologic myopia']
28
+ 26,08_ODIR-5K/preprocessed_images/145_right.jpg,[],['pathologic myopia']
29
+ 27,08_ODIR-5K/preprocessed_images/145_left.jpg,[],['pathologic myopia']
30
+ 28,08_ODIR-5K/preprocessed_images/174_right.jpg,[],['normal']
31
+ 29,08_ODIR-5K/preprocessed_images/174_left.jpg,[],['pathologic myopia']
32
+ 30,08_ODIR-5K/preprocessed_images/191_right.jpg,[],['normal']
33
+ 31,08_ODIR-5K/preprocessed_images/191_left.jpg,[],['normal']
34
+ 32,08_ODIR-5K/preprocessed_images/214_right.jpg,[],['pathologic myopia']
35
+ 33,08_ODIR-5K/preprocessed_images/214_left.jpg,[],['normal']
36
+ 34,08_ODIR-5K/preprocessed_images/233_right.jpg,[],['pathologic myopia']
37
+ 35,08_ODIR-5K/preprocessed_images/233_left.jpg,[],['normal']
38
+ 36,08_ODIR-5K/preprocessed_images/294_right.jpg,[],['normal']
39
+ 37,08_ODIR-5K/preprocessed_images/294_left.jpg,[],['cataract']
40
+ 38,08_ODIR-5K/preprocessed_images/330_right.jpg,[],['normal']
41
+ 39,08_ODIR-5K/preprocessed_images/330_left.jpg,[],['cataract']
42
+ 40,08_ODIR-5K/preprocessed_images/354_right.jpg,[],['cataract']
43
+ 41,08_ODIR-5K/preprocessed_images/354_left.jpg,[],['normal']
44
+ 42,08_ODIR-5K/preprocessed_images/379_right.jpg,[],['normal']
45
+ 43,08_ODIR-5K/preprocessed_images/379_left.jpg,[],['pathologic myopia']
46
+ 44,08_ODIR-5K/preprocessed_images/382_right.jpg,[],['pathologic myopia']
47
+ 45,08_ODIR-5K/preprocessed_images/382_left.jpg,[],['pathologic myopia']
48
+ 46,08_ODIR-5K/preprocessed_images/390_right.jpg,[],['pathologic myopia']
49
+ 47,08_ODIR-5K/preprocessed_images/390_left.jpg,[],['normal']
50
+ 48,08_ODIR-5K/preprocessed_images/394_right.jpg,[],['normal']
51
+ 49,08_ODIR-5K/preprocessed_images/394_left.jpg,[],['normal']
52
+ 50,08_ODIR-5K/preprocessed_images/401_right.jpg,[],['pathologic myopia']
53
+ 51,08_ODIR-5K/preprocessed_images/401_left.jpg,[],['pathologic myopia']
54
+ 52,08_ODIR-5K/preprocessed_images/477_right.jpg,[],['cataract']
55
+ 53,08_ODIR-5K/preprocessed_images/477_left.jpg,[],['cataract']
56
+ 54,08_ODIR-5K/preprocessed_images/481_right.jpg,[],['normal']
57
+ 55,08_ODIR-5K/preprocessed_images/481_left.jpg,[],['pathologic myopia']
58
+ 56,08_ODIR-5K/preprocessed_images/504_right.jpg,[],['pathologic myopia']
59
+ 57,08_ODIR-5K/preprocessed_images/504_left.jpg,[],['pathologic myopia']
60
+ 58,08_ODIR-5K/preprocessed_images/525_right.jpg,[],['pathologic myopia']
61
+ 59,08_ODIR-5K/preprocessed_images/525_left.jpg,[],['pathologic myopia']
62
+ 60,08_ODIR-5K/preprocessed_images/530_right.jpg,[],['normal']
63
+ 61,08_ODIR-5K/preprocessed_images/530_left.jpg,[],['normal']
64
+ 62,08_ODIR-5K/preprocessed_images/553_right.jpg,[],['cataract']
65
+ 63,08_ODIR-5K/preprocessed_images/553_left.jpg,[],['cataract']
66
+ 64,08_ODIR-5K/preprocessed_images/560_right.jpg,[],['cataract']
67
+ 65,08_ODIR-5K/preprocessed_images/560_left.jpg,[],['cataract']
68
+ 66,08_ODIR-5K/preprocessed_images/695_right.jpg,[],['normal']
69
+ 67,08_ODIR-5K/preprocessed_images/695_left.jpg,[],['normal']
70
+ 68,08_ODIR-5K/preprocessed_images/726_right.jpg,[],['cataract']
71
+ 69,08_ODIR-5K/preprocessed_images/726_left.jpg,[],['cataract']
72
+ 70,08_ODIR-5K/preprocessed_images/737_right.jpg,[],['pathologic myopia']
73
+ 71,08_ODIR-5K/preprocessed_images/737_left.jpg,[],['normal']
74
+ 72,08_ODIR-5K/preprocessed_images/741_right.jpg,[],['normal']
75
+ 73,08_ODIR-5K/preprocessed_images/741_left.jpg,[],['pathologic myopia']
76
+ 74,08_ODIR-5K/preprocessed_images/771_right.jpg,[],['normal']
77
+ 75,08_ODIR-5K/preprocessed_images/771_left.jpg,[],['pathologic myopia']
78
+ 76,08_ODIR-5K/preprocessed_images/809_right.jpg,[],['normal']
79
+ 77,08_ODIR-5K/preprocessed_images/809_left.jpg,[],['cataract']
80
+ 78,08_ODIR-5K/preprocessed_images/820_right.jpg,[],['normal']
81
+ 79,08_ODIR-5K/preprocessed_images/820_left.jpg,[],['cataract']
82
+ 80,08_ODIR-5K/preprocessed_images/824_right.jpg,[],['normal']
83
+ 81,08_ODIR-5K/preprocessed_images/824_left.jpg,[],['cataract']
84
+ 82,08_ODIR-5K/preprocessed_images/832_right.jpg,[],['normal']
85
+ 83,08_ODIR-5K/preprocessed_images/832_left.jpg,[],['normal']
86
+ 84,08_ODIR-5K/preprocessed_images/908_right.jpg,[],['pathologic myopia']
87
+ 85,08_ODIR-5K/preprocessed_images/939_right.jpg,[],['normal']
88
+ 86,08_ODIR-5K/preprocessed_images/939_left.jpg,[],['normal']
89
+ 87,08_ODIR-5K/preprocessed_images/951_right.jpg,[],['normal']
90
+ 88,08_ODIR-5K/preprocessed_images/951_left.jpg,[],['normal']
91
+ 89,08_ODIR-5K/preprocessed_images/955_right.jpg,[],['cataract']
92
+ 90,08_ODIR-5K/preprocessed_images/999_right.jpg,[],['cataract']
93
+ 91,08_ODIR-5K/preprocessed_images/999_left.jpg,[],['cataract']
94
+ 92,08_ODIR-5K/preprocessed_images/1034_right.jpg,[],['normal']
95
+ 93,08_ODIR-5K/preprocessed_images/1034_left.jpg,[],['normal']
96
+ 94,08_ODIR-5K/preprocessed_images/1054_right.jpg,[],['normal']
97
+ 95,08_ODIR-5K/preprocessed_images/1054_left.jpg,[],['normal']
98
+ 96,08_ODIR-5K/preprocessed_images/1060_right.jpg,[],['normal']
99
+ 97,08_ODIR-5K/preprocessed_images/1060_left.jpg,[],['normal']
100
+ 98,08_ODIR-5K/preprocessed_images/1062_right.jpg,[],['cataract']
101
+ 99,08_ODIR-5K/preprocessed_images/1072_right.jpg,[],['normal']
102
+ 100,08_ODIR-5K/preprocessed_images/1072_left.jpg,[],['normal']
103
+ 101,08_ODIR-5K/preprocessed_images/1102_right.jpg,[],['cataract']
104
+ 102,08_ODIR-5K/preprocessed_images/1102_left.jpg,[],['cataract']
105
+ 103,08_ODIR-5K/preprocessed_images/1103_right.jpg,[],['pathologic myopia']
106
+ 104,08_ODIR-5K/preprocessed_images/1103_left.jpg,[],['pathologic myopia']
107
+ 105,08_ODIR-5K/preprocessed_images/1115_right.jpg,[],['normal']
108
+ 106,08_ODIR-5K/preprocessed_images/1115_left.jpg,[],['cataract']
109
+ 107,08_ODIR-5K/preprocessed_images/1126_right.jpg,[],['cataract']
110
+ 108,08_ODIR-5K/preprocessed_images/1126_left.jpg,[],['normal']
111
+ 109,08_ODIR-5K/preprocessed_images/1150_right.jpg,[],['pathologic myopia']
112
+ 110,08_ODIR-5K/preprocessed_images/1150_left.jpg,[],['pathologic myopia']
113
+ 111,08_ODIR-5K/preprocessed_images/1164_right.jpg,[],['normal']
114
+ 112,08_ODIR-5K/preprocessed_images/1164_left.jpg,[],['cataract']
115
+ 113,08_ODIR-5K/preprocessed_images/1253_right.jpg,[],['normal']
116
+ 114,08_ODIR-5K/preprocessed_images/1253_left.jpg,[],['normal']
117
+ 115,08_ODIR-5K/preprocessed_images/1349_right.jpg,[],['pathologic myopia']
118
+ 116,08_ODIR-5K/preprocessed_images/1349_left.jpg,[],['pathologic myopia']
119
+ 117,08_ODIR-5K/preprocessed_images/1435_right.jpg,[],['normal']
120
+ 118,08_ODIR-5K/preprocessed_images/1435_left.jpg,[],['cataract']
121
+ 119,08_ODIR-5K/preprocessed_images/1444_right.jpg,[],['normal']
122
+ 120,08_ODIR-5K/preprocessed_images/1444_left.jpg,[],['cataract']
123
+ 121,08_ODIR-5K/preprocessed_images/1452_right.jpg,[],['normal']
124
+ 122,08_ODIR-5K/preprocessed_images/1452_left.jpg,[],['cataract']
125
+ 123,08_ODIR-5K/preprocessed_images/1460_right.jpg,[],['cataract']
126
+ 124,08_ODIR-5K/preprocessed_images/1460_left.jpg,[],['normal']
127
+ 125,08_ODIR-5K/preprocessed_images/1468_right.jpg,[],['normal']
128
+ 126,08_ODIR-5K/preprocessed_images/1468_left.jpg,[],['cataract']
129
+ 127,08_ODIR-5K/preprocessed_images/1483_right.jpg,[],['cataract']
130
+ 128,08_ODIR-5K/preprocessed_images/1483_left.jpg,[],['cataract']
131
+ 129,08_ODIR-5K/preprocessed_images/1484_right.jpg,[],['cataract']
132
+ 130,08_ODIR-5K/preprocessed_images/1484_left.jpg,[],['cataract']
133
+ 131,08_ODIR-5K/preprocessed_images/1490_right.jpg,[],['cataract']
134
+ 132,08_ODIR-5K/preprocessed_images/1490_left.jpg,[],['normal']
135
+ 133,08_ODIR-5K/preprocessed_images/1513_right.jpg,[],['pathologic myopia']
136
+ 134,08_ODIR-5K/preprocessed_images/1513_left.jpg,[],['normal']
137
+ 135,08_ODIR-5K/preprocessed_images/1519_right.jpg,[],['pathologic myopia']
138
+ 136,08_ODIR-5K/preprocessed_images/1519_left.jpg,[],['normal']
139
+ 137,08_ODIR-5K/preprocessed_images/1523_right.jpg,[],['pathologic myopia']
140
+ 138,08_ODIR-5K/preprocessed_images/1523_left.jpg,[],['pathologic myopia']
141
+ 139,08_ODIR-5K/preprocessed_images/1526_right.jpg,[],['pathologic myopia']
142
+ 140,08_ODIR-5K/preprocessed_images/1526_left.jpg,[],['pathologic myopia']
143
+ 141,08_ODIR-5K/preprocessed_images/1527_right.jpg,[],['pathologic myopia']
144
+ 142,08_ODIR-5K/preprocessed_images/1527_left.jpg,[],['pathologic myopia']
145
+ 143,08_ODIR-5K/preprocessed_images/1529_right.jpg,[],['pathologic myopia']
146
+ 144,08_ODIR-5K/preprocessed_images/1529_left.jpg,[],['pathologic myopia']
147
+ 145,08_ODIR-5K/preprocessed_images/1530_right.jpg,[],['pathologic myopia']
148
+ 146,08_ODIR-5K/preprocessed_images/1530_left.jpg,[],['pathologic myopia']
149
+ 147,08_ODIR-5K/preprocessed_images/1531_right.jpg,[],['pathologic myopia']
150
+ 148,08_ODIR-5K/preprocessed_images/1531_left.jpg,[],['pathologic myopia']
151
+ 149,08_ODIR-5K/preprocessed_images/1532_right.jpg,[],['pathologic myopia']
152
+ 150,08_ODIR-5K/preprocessed_images/1532_left.jpg,[],['pathologic myopia']
153
+ 151,08_ODIR-5K/preprocessed_images/1533_right.jpg,[],['pathologic myopia']
154
+ 152,08_ODIR-5K/preprocessed_images/1533_left.jpg,[],['pathologic myopia']
155
+ 153,08_ODIR-5K/preprocessed_images/1534_right.jpg,[],['pathologic myopia']
156
+ 154,08_ODIR-5K/preprocessed_images/1534_left.jpg,[],['pathologic myopia']
157
+ 155,08_ODIR-5K/preprocessed_images/1535_right.jpg,[],['pathologic myopia']
158
+ 156,08_ODIR-5K/preprocessed_images/1535_left.jpg,[],['pathologic myopia']
159
+ 157,08_ODIR-5K/preprocessed_images/1537_right.jpg,[],['pathologic myopia']
160
+ 158,08_ODIR-5K/preprocessed_images/1537_left.jpg,[],['pathologic myopia']
161
+ 159,08_ODIR-5K/preprocessed_images/1538_right.jpg,[],['pathologic myopia']
162
+ 160,08_ODIR-5K/preprocessed_images/1538_left.jpg,[],['pathologic myopia']
163
+ 161,08_ODIR-5K/preprocessed_images/1539_right.jpg,[],['pathologic myopia']
164
+ 162,08_ODIR-5K/preprocessed_images/1539_left.jpg,[],['pathologic myopia']
165
+ 163,08_ODIR-5K/preprocessed_images/1540_right.jpg,[],['pathologic myopia']
166
+ 164,08_ODIR-5K/preprocessed_images/1541_right.jpg,[],['normal']
167
+ 165,08_ODIR-5K/preprocessed_images/1541_left.jpg,[],['pathologic myopia']
168
+ 166,08_ODIR-5K/preprocessed_images/1544_right.jpg,[],['pathologic myopia']
169
+ 167,08_ODIR-5K/preprocessed_images/1544_left.jpg,[],['pathologic myopia']
170
+ 168,08_ODIR-5K/preprocessed_images/1545_right.jpg,[],['pathologic myopia']
171
+ 169,08_ODIR-5K/preprocessed_images/1545_left.jpg,[],['pathologic myopia']
172
+ 170,08_ODIR-5K/preprocessed_images/1546_right.jpg,[],['pathologic myopia']
173
+ 171,08_ODIR-5K/preprocessed_images/1546_left.jpg,[],['pathologic myopia']
174
+ 172,08_ODIR-5K/preprocessed_images/1547_right.jpg,[],['pathologic myopia']
175
+ 173,08_ODIR-5K/preprocessed_images/1547_left.jpg,[],['pathologic myopia']
176
+ 174,08_ODIR-5K/preprocessed_images/1548_right.jpg,[],['pathologic myopia']
177
+ 175,08_ODIR-5K/preprocessed_images/1548_left.jpg,[],['pathologic myopia']
178
+ 176,08_ODIR-5K/preprocessed_images/1549_right.jpg,[],['pathologic myopia']
179
+ 177,08_ODIR-5K/preprocessed_images/1549_left.jpg,[],['pathologic myopia']
180
+ 178,08_ODIR-5K/preprocessed_images/1550_right.jpg,[],['pathologic myopia']
181
+ 179,08_ODIR-5K/preprocessed_images/1550_left.jpg,[],['pathologic myopia']
182
+ 180,08_ODIR-5K/preprocessed_images/1551_right.jpg,[],['pathologic myopia']
183
+ 181,08_ODIR-5K/preprocessed_images/1551_left.jpg,[],['pathologic myopia']
184
+ 182,08_ODIR-5K/preprocessed_images/1552_right.jpg,[],['pathologic myopia']
185
+ 183,08_ODIR-5K/preprocessed_images/1552_left.jpg,[],['pathologic myopia']
186
+ 184,08_ODIR-5K/preprocessed_images/1553_right.jpg,[],['pathologic myopia']
187
+ 185,08_ODIR-5K/preprocessed_images/1553_left.jpg,[],['pathologic myopia']
188
+ 186,08_ODIR-5K/preprocessed_images/1554_right.jpg,[],['pathologic myopia']
189
+ 187,08_ODIR-5K/preprocessed_images/1554_left.jpg,[],['pathologic myopia']
190
+ 188,08_ODIR-5K/preprocessed_images/1555_right.jpg,[],['pathologic myopia']
191
+ 189,08_ODIR-5K/preprocessed_images/1555_left.jpg,[],['pathologic myopia']
192
+ 190,08_ODIR-5K/preprocessed_images/1556_right.jpg,[],['normal']
193
+ 191,08_ODIR-5K/preprocessed_images/1556_left.jpg,[],['pathologic myopia']
194
+ 192,08_ODIR-5K/preprocessed_images/1558_right.jpg,[],['pathologic myopia']
195
+ 193,08_ODIR-5K/preprocessed_images/1558_left.jpg,[],['pathologic myopia']
196
+ 194,08_ODIR-5K/preprocessed_images/1561_right.jpg,[],['pathologic myopia']
197
+ 195,08_ODIR-5K/preprocessed_images/1561_left.jpg,[],['pathologic myopia']
198
+ 196,08_ODIR-5K/preprocessed_images/1562_right.jpg,[],['pathologic myopia']
199
+ 197,08_ODIR-5K/preprocessed_images/1562_left.jpg,[],['pathologic myopia']
200
+ 198,08_ODIR-5K/preprocessed_images/1563_right.jpg,[],['pathologic myopia']
201
+ 199,08_ODIR-5K/preprocessed_images/1563_left.jpg,[],['pathologic myopia']
202
+ 200,08_ODIR-5K/preprocessed_images/1564_right.jpg,[],['pathologic myopia']
203
+ 201,08_ODIR-5K/preprocessed_images/1564_left.jpg,[],['pathologic myopia']
204
+ 202,08_ODIR-5K/preprocessed_images/1565_right.jpg,[],['pathologic myopia']
205
+ 203,08_ODIR-5K/preprocessed_images/1565_left.jpg,[],['pathologic myopia']
206
+ 204,08_ODIR-5K/preprocessed_images/1568_right.jpg,[],['pathologic myopia']
207
+ 205,08_ODIR-5K/preprocessed_images/1568_left.jpg,[],['pathologic myopia']
208
+ 206,08_ODIR-5K/preprocessed_images/1569_right.jpg,[],['pathologic myopia']
209
+ 207,08_ODIR-5K/preprocessed_images/1569_left.jpg,[],['normal']
210
+ 208,08_ODIR-5K/preprocessed_images/1570_right.jpg,[],['pathologic myopia']
211
+ 209,08_ODIR-5K/preprocessed_images/1570_left.jpg,[],['pathologic myopia']
212
+ 210,08_ODIR-5K/preprocessed_images/1572_right.jpg,[],['pathologic myopia']
213
+ 211,08_ODIR-5K/preprocessed_images/1572_left.jpg,[],['pathologic myopia']
214
+ 212,08_ODIR-5K/preprocessed_images/1576_right.jpg,[],['pathologic myopia']
215
+ 213,08_ODIR-5K/preprocessed_images/1576_left.jpg,[],['pathologic myopia']
216
+ 214,08_ODIR-5K/preprocessed_images/1578_right.jpg,[],['pathologic myopia']
217
+ 215,08_ODIR-5K/preprocessed_images/1578_left.jpg,[],['pathologic myopia']
218
+ 216,08_ODIR-5K/preprocessed_images/1579_right.jpg,[],['pathologic myopia']
219
+ 217,08_ODIR-5K/preprocessed_images/1579_left.jpg,[],['pathologic myopia']
220
+ 218,08_ODIR-5K/preprocessed_images/1580_right.jpg,[],['pathologic myopia']
221
+ 219,08_ODIR-5K/preprocessed_images/1580_left.jpg,[],['pathologic myopia']
222
+ 220,08_ODIR-5K/preprocessed_images/1583_right.jpg,[],['pathologic myopia']
223
+ 221,08_ODIR-5K/preprocessed_images/1583_left.jpg,[],['pathologic myopia']
224
+ 222,08_ODIR-5K/preprocessed_images/1584_right.jpg,[],['pathologic myopia']
225
+ 223,08_ODIR-5K/preprocessed_images/1584_left.jpg,[],['pathologic myopia']
226
+ 224,08_ODIR-5K/preprocessed_images/1586_right.jpg,[],['pathologic myopia']
227
+ 225,08_ODIR-5K/preprocessed_images/1586_left.jpg,[],['pathologic myopia']
228
+ 226,08_ODIR-5K/preprocessed_images/1588_right.jpg,[],['pathologic myopia']
229
+ 227,08_ODIR-5K/preprocessed_images/1588_left.jpg,[],['pathologic myopia']
230
+ 228,08_ODIR-5K/preprocessed_images/1589_right.jpg,[],['pathologic myopia']
231
+ 229,08_ODIR-5K/preprocessed_images/1589_left.jpg,[],['pathologic myopia']
232
+ 230,08_ODIR-5K/preprocessed_images/1590_right.jpg,[],['pathologic myopia']
233
+ 231,08_ODIR-5K/preprocessed_images/1590_left.jpg,[],['normal']
234
+ 232,08_ODIR-5K/preprocessed_images/1593_right.jpg,[],['pathologic myopia']
235
+ 233,08_ODIR-5K/preprocessed_images/1593_left.jpg,[],['pathologic myopia']
236
+ 234,08_ODIR-5K/preprocessed_images/1594_right.jpg,[],['pathologic myopia']
237
+ 235,08_ODIR-5K/preprocessed_images/1594_left.jpg,[],['pathologic myopia']
238
+ 236,08_ODIR-5K/preprocessed_images/1599_right.jpg,[],['pathologic myopia']
239
+ 237,08_ODIR-5K/preprocessed_images/1599_left.jpg,[],['pathologic myopia']
240
+ 238,08_ODIR-5K/preprocessed_images/1600_right.jpg,[],['pathologic myopia']
241
+ 239,08_ODIR-5K/preprocessed_images/1600_left.jpg,[],['pathologic myopia']
242
+ 240,08_ODIR-5K/preprocessed_images/1601_right.jpg,[],['pathologic myopia']
243
+ 241,08_ODIR-5K/preprocessed_images/1601_left.jpg,[],['pathologic myopia']
244
+ 242,08_ODIR-5K/preprocessed_images/1602_right.jpg,[],['pathologic myopia']
245
+ 243,08_ODIR-5K/preprocessed_images/1602_left.jpg,[],['pathologic myopia']
246
+ 244,08_ODIR-5K/preprocessed_images/1603_right.jpg,[],['pathologic myopia']
247
+ 245,08_ODIR-5K/preprocessed_images/1603_left.jpg,[],['pathologic myopia']
248
+ 246,08_ODIR-5K/preprocessed_images/1605_right.jpg,[],['pathologic myopia']
249
+ 247,08_ODIR-5K/preprocessed_images/1605_left.jpg,[],['pathologic myopia']
250
+ 248,08_ODIR-5K/preprocessed_images/1606_right.jpg,[],['pathologic myopia']
251
+ 249,08_ODIR-5K/preprocessed_images/1606_left.jpg,[],['pathologic myopia']
252
+ 250,08_ODIR-5K/preprocessed_images/1607_right.jpg,[],['pathologic myopia']
253
+ 251,08_ODIR-5K/preprocessed_images/1607_left.jpg,[],['pathologic myopia']
254
+ 252,08_ODIR-5K/preprocessed_images/1610_right.jpg,[],['normal']
255
+ 253,08_ODIR-5K/preprocessed_images/1610_left.jpg,[],['pathologic myopia']
256
+ 254,08_ODIR-5K/preprocessed_images/1611_right.jpg,[],['normal']
257
+ 255,08_ODIR-5K/preprocessed_images/1611_left.jpg,[],['pathologic myopia']
258
+ 256,08_ODIR-5K/preprocessed_images/1612_right.jpg,[],['pathologic myopia']
259
+ 257,08_ODIR-5K/preprocessed_images/1612_left.jpg,[],['pathologic myopia']
260
+ 258,08_ODIR-5K/preprocessed_images/1613_right.jpg,[],['pathologic myopia']
261
+ 259,08_ODIR-5K/preprocessed_images/1613_left.jpg,[],['pathologic myopia']
262
+ 260,08_ODIR-5K/preprocessed_images/1615_right.jpg,[],['pathologic myopia']
263
+ 261,08_ODIR-5K/preprocessed_images/1615_left.jpg,[],['pathologic myopia']
264
+ 262,08_ODIR-5K/preprocessed_images/1616_right.jpg,[],['pathologic myopia']
265
+ 263,08_ODIR-5K/preprocessed_images/1616_left.jpg,[],['pathologic myopia']
266
+ 264,08_ODIR-5K/preprocessed_images/1617_right.jpg,[],['pathologic myopia']
267
+ 265,08_ODIR-5K/preprocessed_images/1617_left.jpg,[],['pathologic myopia']
268
+ 266,08_ODIR-5K/preprocessed_images/1618_right.jpg,[],['pathologic myopia']
269
+ 267,08_ODIR-5K/preprocessed_images/1618_left.jpg,[],['pathologic myopia']
270
+ 268,08_ODIR-5K/preprocessed_images/1619_right.jpg,[],['pathologic myopia']
271
+ 269,08_ODIR-5K/preprocessed_images/1619_left.jpg,[],['normal']
272
+ 270,08_ODIR-5K/preprocessed_images/1620_right.jpg,[],['pathologic myopia']
273
+ 271,08_ODIR-5K/preprocessed_images/1620_left.jpg,[],['normal']
274
+ 272,08_ODIR-5K/preprocessed_images/1621_right.jpg,[],['pathologic myopia']
275
+ 273,08_ODIR-5K/preprocessed_images/1621_left.jpg,[],['pathologic myopia']
276
+ 274,08_ODIR-5K/preprocessed_images/1623_right.jpg,[],['pathologic myopia']
277
+ 275,08_ODIR-5K/preprocessed_images/1623_left.jpg,[],['pathologic myopia']
278
+ 276,08_ODIR-5K/preprocessed_images/1624_right.jpg,[],['pathologic myopia']
279
+ 277,08_ODIR-5K/preprocessed_images/1624_left.jpg,[],['pathologic myopia']
280
+ 278,08_ODIR-5K/preprocessed_images/1629_right.jpg,[],['pathologic myopia']
281
+ 279,08_ODIR-5K/preprocessed_images/1629_left.jpg,[],['pathologic myopia']
282
+ 280,08_ODIR-5K/preprocessed_images/1630_right.jpg,[],['pathologic myopia']
283
+ 281,08_ODIR-5K/preprocessed_images/1630_left.jpg,[],['pathologic myopia']
284
+ 282,08_ODIR-5K/preprocessed_images/1647_right.jpg,[],['pathologic myopia']
285
+ 283,08_ODIR-5K/preprocessed_images/1647_left.jpg,[],['pathologic myopia']
286
+ 284,08_ODIR-5K/preprocessed_images/1663_right.jpg,[],['normal']
287
+ 285,08_ODIR-5K/preprocessed_images/1663_left.jpg,[],['pathologic myopia']
288
+ 286,08_ODIR-5K/preprocessed_images/1666_right.jpg,[],['pathologic myopia']
289
+ 287,08_ODIR-5K/preprocessed_images/1666_left.jpg,[],['normal']
290
+ 288,08_ODIR-5K/preprocessed_images/1686_right.jpg,[],['pathologic myopia']
291
+ 289,08_ODIR-5K/preprocessed_images/1686_left.jpg,[],['pathologic myopia']
292
+ 290,08_ODIR-5K/preprocessed_images/2095_right.jpg,[],['cataract']
293
+ 291,08_ODIR-5K/preprocessed_images/2095_left.jpg,[],['normal']
294
+ 292,08_ODIR-5K/preprocessed_images/2097_right.jpg,[],['cataract']
295
+ 293,08_ODIR-5K/preprocessed_images/2097_left.jpg,[],['normal']
296
+ 294,08_ODIR-5K/preprocessed_images/2098_right.jpg,[],['cataract']
297
+ 295,08_ODIR-5K/preprocessed_images/2098_left.jpg,[],['cataract']
298
+ 296,08_ODIR-5K/preprocessed_images/2101_right.jpg,[],['cataract']
299
+ 297,08_ODIR-5K/preprocessed_images/2101_left.jpg,[],['cataract']
300
+ 298,08_ODIR-5K/preprocessed_images/2104_right.jpg,[],['cataract']
301
+ 299,08_ODIR-5K/preprocessed_images/2104_left.jpg,[],['cataract']
302
+ 300,08_ODIR-5K/preprocessed_images/2105_right.jpg,[],['cataract']
303
+ 301,08_ODIR-5K/preprocessed_images/2105_left.jpg,[],['cataract']
304
+ 302,08_ODIR-5K/preprocessed_images/2106_right.jpg,[],['cataract']
305
+ 303,08_ODIR-5K/preprocessed_images/2106_left.jpg,[],['normal']
306
+ 304,08_ODIR-5K/preprocessed_images/2108_right.jpg,[],['cataract']
307
+ 305,08_ODIR-5K/preprocessed_images/2108_left.jpg,[],['cataract']
308
+ 306,08_ODIR-5K/preprocessed_images/2109_right.jpg,[],['cataract']
309
+ 307,08_ODIR-5K/preprocessed_images/2109_left.jpg,[],['cataract']
310
+ 308,08_ODIR-5K/preprocessed_images/2110_right.jpg,[],['cataract']
311
+ 309,08_ODIR-5K/preprocessed_images/2110_left.jpg,[],['cataract']
312
+ 310,08_ODIR-5K/preprocessed_images/2112_right.jpg,[],['cataract']
313
+ 311,08_ODIR-5K/preprocessed_images/2112_left.jpg,[],['normal']
314
+ 312,08_ODIR-5K/preprocessed_images/2113_right.jpg,[],['cataract']
315
+ 313,08_ODIR-5K/preprocessed_images/2113_left.jpg,[],['cataract']
316
+ 314,08_ODIR-5K/preprocessed_images/2114_right.jpg,[],['cataract']
317
+ 315,08_ODIR-5K/preprocessed_images/2114_left.jpg,[],['cataract']
318
+ 316,08_ODIR-5K/preprocessed_images/2116_right.jpg,[],['cataract']
319
+ 317,08_ODIR-5K/preprocessed_images/2116_left.jpg,[],['cataract']
320
+ 318,08_ODIR-5K/preprocessed_images/2119_right.jpg,[],['cataract']
321
+ 319,08_ODIR-5K/preprocessed_images/2119_left.jpg,[],['normal']
322
+ 320,08_ODIR-5K/preprocessed_images/2120_right.jpg,[],['cataract']
323
+ 321,08_ODIR-5K/preprocessed_images/2120_left.jpg,[],['cataract']
324
+ 322,08_ODIR-5K/preprocessed_images/2121_right.jpg,[],['normal']
325
+ 323,08_ODIR-5K/preprocessed_images/2121_left.jpg,[],['cataract']
326
+ 324,08_ODIR-5K/preprocessed_images/2122_right.jpg,[],['cataract']
327
+ 325,08_ODIR-5K/preprocessed_images/2122_left.jpg,[],['cataract']
328
+ 326,08_ODIR-5K/preprocessed_images/2125_right.jpg,[],['normal']
329
+ 327,08_ODIR-5K/preprocessed_images/2125_left.jpg,[],['cataract']
330
+ 328,08_ODIR-5K/preprocessed_images/2126_right.jpg,[],['cataract']
331
+ 329,08_ODIR-5K/preprocessed_images/2126_left.jpg,[],['cataract']
332
+ 330,08_ODIR-5K/preprocessed_images/2127_right.jpg,[],['cataract']
333
+ 331,08_ODIR-5K/preprocessed_images/2127_left.jpg,[],['cataract']
334
+ 332,08_ODIR-5K/preprocessed_images/2128_right.jpg,[],['cataract']
335
+ 333,08_ODIR-5K/preprocessed_images/2128_left.jpg,[],['cataract']
336
+ 334,08_ODIR-5K/preprocessed_images/2129_right.jpg,[],['cataract']
337
+ 335,08_ODIR-5K/preprocessed_images/2129_left.jpg,[],['cataract']
338
+ 336,08_ODIR-5K/preprocessed_images/2130_right.jpg,[],['cataract']
339
+ 337,08_ODIR-5K/preprocessed_images/2130_left.jpg,[],['cataract']
340
+ 338,08_ODIR-5K/preprocessed_images/2132_right.jpg,[],['normal']
341
+ 339,08_ODIR-5K/preprocessed_images/2132_left.jpg,[],['cataract']
342
+ 340,08_ODIR-5K/preprocessed_images/2133_right.jpg,[],['cataract']
343
+ 341,08_ODIR-5K/preprocessed_images/2133_left.jpg,[],['cataract']
344
+ 342,08_ODIR-5K/preprocessed_images/2134_right.jpg,[],['cataract']
345
+ 343,08_ODIR-5K/preprocessed_images/2134_left.jpg,[],['cataract']
346
+ 344,08_ODIR-5K/preprocessed_images/2135_right.jpg,[],['cataract']
347
+ 345,08_ODIR-5K/preprocessed_images/2135_left.jpg,[],['cataract']
348
+ 346,08_ODIR-5K/preprocessed_images/2136_right.jpg,[],['normal']
349
+ 347,08_ODIR-5K/preprocessed_images/2136_left.jpg,[],['cataract']
350
+ 348,08_ODIR-5K/preprocessed_images/2137_right.jpg,[],['cataract']
351
+ 349,08_ODIR-5K/preprocessed_images/2137_left.jpg,[],['cataract']
352
+ 350,08_ODIR-5K/preprocessed_images/2138_right.jpg,[],['cataract']
353
+ 351,08_ODIR-5K/preprocessed_images/2138_left.jpg,[],['cataract']
354
+ 352,08_ODIR-5K/preprocessed_images/2139_right.jpg,[],['cataract']
355
+ 353,08_ODIR-5K/preprocessed_images/2140_right.jpg,[],['cataract']
356
+ 354,08_ODIR-5K/preprocessed_images/2140_left.jpg,[],['cataract']
357
+ 355,08_ODIR-5K/preprocessed_images/2142_right.jpg,[],['cataract']
358
+ 356,08_ODIR-5K/preprocessed_images/2142_left.jpg,[],['cataract']
359
+ 357,08_ODIR-5K/preprocessed_images/2143_right.jpg,[],['cataract']
360
+ 358,08_ODIR-5K/preprocessed_images/2143_left.jpg,[],['normal']
361
+ 359,08_ODIR-5K/preprocessed_images/2144_right.jpg,[],['cataract']
362
+ 360,08_ODIR-5K/preprocessed_images/2144_left.jpg,[],['cataract']
363
+ 361,08_ODIR-5K/preprocessed_images/2146_right.jpg,[],['cataract']
364
+ 362,08_ODIR-5K/preprocessed_images/2146_left.jpg,[],['cataract']
365
+ 363,08_ODIR-5K/preprocessed_images/2149_right.jpg,[],['cataract']
366
+ 364,08_ODIR-5K/preprocessed_images/2149_left.jpg,[],['normal']
367
+ 365,08_ODIR-5K/preprocessed_images/2150_right.jpg,[],['cataract']
368
+ 366,08_ODIR-5K/preprocessed_images/2150_left.jpg,[],['cataract']
369
+ 367,08_ODIR-5K/preprocessed_images/2151_right.jpg,[],['cataract']
370
+ 368,08_ODIR-5K/preprocessed_images/2151_left.jpg,[],['cataract']
371
+ 369,08_ODIR-5K/preprocessed_images/2152_right.jpg,[],['normal']
372
+ 370,08_ODIR-5K/preprocessed_images/2152_left.jpg,[],['cataract']
373
+ 371,08_ODIR-5K/preprocessed_images/2153_right.jpg,[],['cataract']
374
+ 372,08_ODIR-5K/preprocessed_images/2153_left.jpg,[],['cataract']
375
+ 373,08_ODIR-5K/preprocessed_images/2154_right.jpg,[],['normal']
376
+ 374,08_ODIR-5K/preprocessed_images/2154_left.jpg,[],['cataract']
377
+ 375,08_ODIR-5K/preprocessed_images/2155_right.jpg,[],['cataract']
378
+ 376,08_ODIR-5K/preprocessed_images/2155_left.jpg,[],['cataract']
379
+ 377,08_ODIR-5K/preprocessed_images/2157_right.jpg,[],['cataract']
380
+ 378,08_ODIR-5K/preprocessed_images/2157_left.jpg,[],['cataract']
381
+ 379,08_ODIR-5K/preprocessed_images/2158_right.jpg,[],['cataract']
382
+ 380,08_ODIR-5K/preprocessed_images/2158_left.jpg,[],['cataract']
383
+ 381,08_ODIR-5K/preprocessed_images/2160_right.jpg,[],['cataract']
384
+ 382,08_ODIR-5K/preprocessed_images/2160_left.jpg,[],['normal']
385
+ 383,08_ODIR-5K/preprocessed_images/2162_right.jpg,[],['cataract']
386
+ 384,08_ODIR-5K/preprocessed_images/2162_left.jpg,[],['normal']
387
+ 385,08_ODIR-5K/preprocessed_images/2163_right.jpg,[],['cataract']
388
+ 386,08_ODIR-5K/preprocessed_images/2163_left.jpg,[],['cataract']
389
+ 387,08_ODIR-5K/preprocessed_images/2167_right.jpg,[],['cataract']
390
+ 388,08_ODIR-5K/preprocessed_images/2167_left.jpg,[],['cataract']
391
+ 389,08_ODIR-5K/preprocessed_images/2169_right.jpg,[],['cataract']
392
+ 390,08_ODIR-5K/preprocessed_images/2169_left.jpg,[],['cataract']
393
+ 391,08_ODIR-5K/preprocessed_images/2170_right.jpg,[],['cataract']
394
+ 392,08_ODIR-5K/preprocessed_images/2170_left.jpg,[],['cataract']
395
+ 393,08_ODIR-5K/preprocessed_images/2171_right.jpg,[],['normal']
396
+ 394,08_ODIR-5K/preprocessed_images/2171_left.jpg,[],['cataract']
397
+ 395,08_ODIR-5K/preprocessed_images/2172_right.jpg,[],['normal']
398
+ 396,08_ODIR-5K/preprocessed_images/2172_left.jpg,[],['cataract']
399
+ 397,08_ODIR-5K/preprocessed_images/2174_right.jpg,[],['cataract']
400
+ 398,08_ODIR-5K/preprocessed_images/2174_left.jpg,[],['normal']
401
+ 399,08_ODIR-5K/preprocessed_images/2175_right.jpg,[],['normal']
402
+ 400,08_ODIR-5K/preprocessed_images/2175_left.jpg,[],['cataract']
403
+ 401,08_ODIR-5K/preprocessed_images/2176_right.jpg,[],['cataract']
404
+ 402,08_ODIR-5K/preprocessed_images/2176_left.jpg,[],['cataract']
405
+ 403,08_ODIR-5K/preprocessed_images/2177_right.jpg,[],['cataract']
406
+ 404,08_ODIR-5K/preprocessed_images/2177_left.jpg,[],['normal']
407
+ 405,08_ODIR-5K/preprocessed_images/2178_right.jpg,[],['cataract']
408
+ 406,08_ODIR-5K/preprocessed_images/2178_left.jpg,[],['cataract']
409
+ 407,08_ODIR-5K/preprocessed_images/2179_right.jpg,[],['cataract']
410
+ 408,08_ODIR-5K/preprocessed_images/2179_left.jpg,[],['cataract']
411
+ 409,08_ODIR-5K/preprocessed_images/2180_right.jpg,[],['cataract']
412
+ 410,08_ODIR-5K/preprocessed_images/2180_left.jpg,[],['cataract']
413
+ 411,08_ODIR-5K/preprocessed_images/2181_right.jpg,[],['cataract']
414
+ 412,08_ODIR-5K/preprocessed_images/2181_left.jpg,[],['cataract']
415
+ 413,08_ODIR-5K/preprocessed_images/2182_right.jpg,[],['cataract']
416
+ 414,08_ODIR-5K/preprocessed_images/2182_left.jpg,[],['cataract']
417
+ 415,08_ODIR-5K/preprocessed_images/2183_right.jpg,[],['cataract']
418
+ 416,08_ODIR-5K/preprocessed_images/2183_left.jpg,[],['cataract']
419
+ 417,08_ODIR-5K/preprocessed_images/2184_right.jpg,[],['cataract']
420
+ 418,08_ODIR-5K/preprocessed_images/2184_left.jpg,[],['cataract']
421
+ 419,08_ODIR-5K/preprocessed_images/2187_right.jpg,[],['cataract']
422
+ 420,08_ODIR-5K/preprocessed_images/2187_left.jpg,[],['normal']
423
+ 421,08_ODIR-5K/preprocessed_images/2189_right.jpg,[],['cataract']
424
+ 422,08_ODIR-5K/preprocessed_images/2189_left.jpg,[],['cataract']
425
+ 423,08_ODIR-5K/preprocessed_images/2190_right.jpg,[],['cataract']
426
+ 424,08_ODIR-5K/preprocessed_images/2190_left.jpg,[],['normal']
427
+ 425,08_ODIR-5K/preprocessed_images/2191_right.jpg,[],['cataract']
428
+ 426,08_ODIR-5K/preprocessed_images/2191_left.jpg,[],['normal']
429
+ 427,08_ODIR-5K/preprocessed_images/2192_right.jpg,[],['cataract']
430
+ 428,08_ODIR-5K/preprocessed_images/2192_left.jpg,[],['cataract']
431
+ 429,08_ODIR-5K/preprocessed_images/2193_right.jpg,[],['cataract']
432
+ 430,08_ODIR-5K/preprocessed_images/2193_left.jpg,[],['normal']
433
+ 431,08_ODIR-5K/preprocessed_images/2194_right.jpg,[],['cataract']
434
+ 432,08_ODIR-5K/preprocessed_images/2194_left.jpg,[],['cataract']
435
+ 433,08_ODIR-5K/preprocessed_images/2195_right.jpg,[],['cataract']
436
+ 434,08_ODIR-5K/preprocessed_images/2195_left.jpg,[],['cataract']
437
+ 435,08_ODIR-5K/preprocessed_images/2196_right.jpg,[],['cataract']
438
+ 436,08_ODIR-5K/preprocessed_images/2196_left.jpg,[],['normal']
439
+ 437,08_ODIR-5K/preprocessed_images/2197_right.jpg,[],['cataract']
440
+ 438,08_ODIR-5K/preprocessed_images/2197_left.jpg,[],['normal']
441
+ 439,08_ODIR-5K/preprocessed_images/2198_right.jpg,[],['cataract']
442
+ 440,08_ODIR-5K/preprocessed_images/2198_left.jpg,[],['cataract']
443
+ 441,08_ODIR-5K/preprocessed_images/2203_right.jpg,[],['cataract']
444
+ 442,08_ODIR-5K/preprocessed_images/2203_left.jpg,[],['cataract']
445
+ 443,08_ODIR-5K/preprocessed_images/2205_right.jpg,[],['cataract']
446
+ 444,08_ODIR-5K/preprocessed_images/2205_left.jpg,[],['normal']
447
+ 445,08_ODIR-5K/preprocessed_images/2206_right.jpg,[],['cataract']
448
+ 446,08_ODIR-5K/preprocessed_images/2206_left.jpg,[],['cataract']
449
+ 447,08_ODIR-5K/preprocessed_images/2207_right.jpg,[],['cataract']
450
+ 448,08_ODIR-5K/preprocessed_images/2207_left.jpg,[],['cataract']
451
+ 449,08_ODIR-5K/preprocessed_images/2208_right.jpg,[],['cataract']
452
+ 450,08_ODIR-5K/preprocessed_images/2208_left.jpg,[],['normal']
453
+ 451,08_ODIR-5K/preprocessed_images/2209_right.jpg,[],['cataract']
454
+ 452,08_ODIR-5K/preprocessed_images/2209_left.jpg,[],['cataract']
455
+ 453,08_ODIR-5K/preprocessed_images/2210_right.jpg,[],['cataract']
456
+ 454,08_ODIR-5K/preprocessed_images/2210_left.jpg,[],['cataract']
457
+ 455,08_ODIR-5K/preprocessed_images/2211_right.jpg,[],['cataract']
458
+ 456,08_ODIR-5K/preprocessed_images/2211_left.jpg,[],['cataract']
459
+ 457,08_ODIR-5K/preprocessed_images/2212_right.jpg,[],['cataract']
460
+ 458,08_ODIR-5K/preprocessed_images/2212_left.jpg,[],['cataract']
461
+ 459,08_ODIR-5K/preprocessed_images/2213_right.jpg,[],['cataract']
462
+ 460,08_ODIR-5K/preprocessed_images/2213_left.jpg,[],['cataract']
463
+ 461,08_ODIR-5K/preprocessed_images/2215_right.jpg,[],['normal']
464
+ 462,08_ODIR-5K/preprocessed_images/2215_left.jpg,[],['cataract']
465
+ 463,08_ODIR-5K/preprocessed_images/2216_right.jpg,[],['cataract']
466
+ 464,08_ODIR-5K/preprocessed_images/2216_left.jpg,[],['cataract']
467
+ 465,08_ODIR-5K/preprocessed_images/2217_right.jpg,[],['cataract']
468
+ 466,08_ODIR-5K/preprocessed_images/2217_left.jpg,[],['cataract']
469
+ 467,08_ODIR-5K/preprocessed_images/2218_right.jpg,[],['cataract']
470
+ 468,08_ODIR-5K/preprocessed_images/2218_left.jpg,[],['normal']
471
+ 469,08_ODIR-5K/preprocessed_images/2219_right.jpg,[],['cataract']
472
+ 470,08_ODIR-5K/preprocessed_images/2219_left.jpg,[],['cataract']
473
+ 471,08_ODIR-5K/preprocessed_images/2221_right.jpg,[],['cataract']
474
+ 472,08_ODIR-5K/preprocessed_images/2221_left.jpg,[],['cataract']
475
+ 473,08_ODIR-5K/preprocessed_images/2223_right.jpg,[],['cataract']
476
+ 474,08_ODIR-5K/preprocessed_images/2223_left.jpg,[],['cataract']
477
+ 475,08_ODIR-5K/preprocessed_images/2225_right.jpg,[],['cataract']
478
+ 476,08_ODIR-5K/preprocessed_images/2225_left.jpg,[],['cataract']
479
+ 477,08_ODIR-5K/preprocessed_images/2227_right.jpg,[],['cataract']
480
+ 478,08_ODIR-5K/preprocessed_images/2227_left.jpg,[],['cataract']
481
+ 479,08_ODIR-5K/preprocessed_images/2231_right.jpg,[],['cataract']
482
+ 480,08_ODIR-5K/preprocessed_images/2232_right.jpg,[],['cataract']
483
+ 481,08_ODIR-5K/preprocessed_images/2232_left.jpg,[],['cataract']
484
+ 482,08_ODIR-5K/preprocessed_images/2233_right.jpg,[],['cataract']
485
+ 483,08_ODIR-5K/preprocessed_images/2235_right.jpg,[],['normal']
486
+ 484,08_ODIR-5K/preprocessed_images/2237_left.jpg,[],['normal']
487
+ 485,08_ODIR-5K/preprocessed_images/2329_right.jpg,[],['normal']
488
+ 486,08_ODIR-5K/preprocessed_images/2329_left.jpg,[],['normal']
489
+ 487,08_ODIR-5K/preprocessed_images/2330_right.jpg,[],['normal']
490
+ 488,08_ODIR-5K/preprocessed_images/2330_left.jpg,[],['normal']
491
+ 489,08_ODIR-5K/preprocessed_images/2331_right.jpg,[],['normal']
492
+ 490,08_ODIR-5K/preprocessed_images/2331_left.jpg,[],['normal']
493
+ 491,08_ODIR-5K/preprocessed_images/2332_right.jpg,[],['normal']
494
+ 492,08_ODIR-5K/preprocessed_images/2332_left.jpg,[],['normal']
495
+ 493,08_ODIR-5K/preprocessed_images/2333_right.jpg,[],['normal']
496
+ 494,08_ODIR-5K/preprocessed_images/2333_left.jpg,[],['normal']
497
+ 495,08_ODIR-5K/preprocessed_images/2334_right.jpg,[],['normal']
498
+ 496,08_ODIR-5K/preprocessed_images/2334_left.jpg,[],['normal']
499
+ 497,08_ODIR-5K/preprocessed_images/2335_right.jpg,[],['normal']
500
+ 498,08_ODIR-5K/preprocessed_images/2335_left.jpg,[],['normal']
501
+ 499,08_ODIR-5K/preprocessed_images/2336_right.jpg,[],['normal']
502
+ 500,08_ODIR-5K/preprocessed_images/2336_left.jpg,[],['normal']
503
+ 501,08_ODIR-5K/preprocessed_images/2337_right.jpg,[],['normal']
504
+ 502,08_ODIR-5K/preprocessed_images/2337_left.jpg,[],['normal']
505
+ 503,08_ODIR-5K/preprocessed_images/2338_right.jpg,[],['normal']
506
+ 504,08_ODIR-5K/preprocessed_images/2338_left.jpg,[],['normal']
507
+ 505,08_ODIR-5K/preprocessed_images/2339_right.jpg,[],['normal']
508
+ 506,08_ODIR-5K/preprocessed_images/2339_left.jpg,[],['normal']
509
+ 507,08_ODIR-5K/preprocessed_images/2340_right.jpg,[],['normal']
510
+ 508,08_ODIR-5K/preprocessed_images/2340_left.jpg,[],['normal']
511
+ 509,08_ODIR-5K/preprocessed_images/2341_right.jpg,[],['normal']
512
+ 510,08_ODIR-5K/preprocessed_images/2341_left.jpg,[],['normal']
513
+ 511,08_ODIR-5K/preprocessed_images/2342_right.jpg,[],['normal']
514
+ 512,08_ODIR-5K/preprocessed_images/2342_left.jpg,[],['normal']
515
+ 513,08_ODIR-5K/preprocessed_images/2343_right.jpg,[],['normal']
516
+ 514,08_ODIR-5K/preprocessed_images/2343_left.jpg,[],['normal']
517
+ 515,08_ODIR-5K/preprocessed_images/2345_right.jpg,[],['normal']
518
+ 516,08_ODIR-5K/preprocessed_images/2345_left.jpg,[],['normal']
519
+ 517,08_ODIR-5K/preprocessed_images/2346_right.jpg,[],['normal']
520
+ 518,08_ODIR-5K/preprocessed_images/2346_left.jpg,[],['normal']
521
+ 519,08_ODIR-5K/preprocessed_images/2347_right.jpg,[],['normal']
522
+ 520,08_ODIR-5K/preprocessed_images/2347_left.jpg,[],['normal']
523
+ 521,08_ODIR-5K/preprocessed_images/2348_right.jpg,[],['normal']
524
+ 522,08_ODIR-5K/preprocessed_images/2348_left.jpg,[],['normal']
525
+ 523,08_ODIR-5K/preprocessed_images/2349_right.jpg,[],['normal']
526
+ 524,08_ODIR-5K/preprocessed_images/2349_left.jpg,[],['normal']
527
+ 525,08_ODIR-5K/preprocessed_images/2351_right.jpg,[],['normal']
528
+ 526,08_ODIR-5K/preprocessed_images/2351_left.jpg,[],['normal']
529
+ 527,08_ODIR-5K/preprocessed_images/2352_right.jpg,[],['normal']
530
+ 528,08_ODIR-5K/preprocessed_images/2352_left.jpg,[],['normal']
531
+ 529,08_ODIR-5K/preprocessed_images/2353_right.jpg,[],['normal']
532
+ 530,08_ODIR-5K/preprocessed_images/2353_left.jpg,[],['normal']
533
+ 531,08_ODIR-5K/preprocessed_images/2354_right.jpg,[],['normal']
534
+ 532,08_ODIR-5K/preprocessed_images/2354_left.jpg,[],['normal']
535
+ 533,08_ODIR-5K/preprocessed_images/2355_right.jpg,[],['normal']
536
+ 534,08_ODIR-5K/preprocessed_images/2355_left.jpg,[],['normal']
537
+ 535,08_ODIR-5K/preprocessed_images/2356_right.jpg,[],['normal']
538
+ 536,08_ODIR-5K/preprocessed_images/2356_left.jpg,[],['normal']
539
+ 537,08_ODIR-5K/preprocessed_images/2357_right.jpg,[],['normal']
540
+ 538,08_ODIR-5K/preprocessed_images/2357_left.jpg,[],['normal']
541
+ 539,08_ODIR-5K/preprocessed_images/2359_right.jpg,[],['normal']
542
+ 540,08_ODIR-5K/preprocessed_images/2359_left.jpg,[],['normal']
543
+ 541,08_ODIR-5K/preprocessed_images/2360_right.jpg,[],['normal']
544
+ 542,08_ODIR-5K/preprocessed_images/2360_left.jpg,[],['normal']
545
+ 543,08_ODIR-5K/preprocessed_images/2361_right.jpg,[],['normal']
546
+ 544,08_ODIR-5K/preprocessed_images/2361_left.jpg,[],['normal']
547
+ 545,08_ODIR-5K/preprocessed_images/2362_right.jpg,[],['normal']
548
+ 546,08_ODIR-5K/preprocessed_images/2362_left.jpg,[],['normal']
549
+ 547,08_ODIR-5K/preprocessed_images/2363_right.jpg,[],['normal']
550
+ 548,08_ODIR-5K/preprocessed_images/2363_left.jpg,[],['normal']
551
+ 549,08_ODIR-5K/preprocessed_images/2364_right.jpg,[],['normal']
552
+ 550,08_ODIR-5K/preprocessed_images/2364_left.jpg,[],['normal']
553
+ 551,08_ODIR-5K/preprocessed_images/2365_right.jpg,[],['normal']
554
+ 552,08_ODIR-5K/preprocessed_images/2365_left.jpg,[],['normal']
555
+ 553,08_ODIR-5K/preprocessed_images/2366_right.jpg,[],['normal']
556
+ 554,08_ODIR-5K/preprocessed_images/2366_left.jpg,[],['normal']
557
+ 555,08_ODIR-5K/preprocessed_images/2367_right.jpg,[],['normal']
558
+ 556,08_ODIR-5K/preprocessed_images/2367_left.jpg,[],['normal']
559
+ 557,08_ODIR-5K/preprocessed_images/2368_right.jpg,[],['normal']
560
+ 558,08_ODIR-5K/preprocessed_images/2368_left.jpg,[],['normal']
561
+ 559,08_ODIR-5K/preprocessed_images/2369_right.jpg,[],['normal']
562
+ 560,08_ODIR-5K/preprocessed_images/2369_left.jpg,[],['normal']
563
+ 561,08_ODIR-5K/preprocessed_images/2370_right.jpg,[],['normal']
564
+ 562,08_ODIR-5K/preprocessed_images/2370_left.jpg,[],['normal']
565
+ 563,08_ODIR-5K/preprocessed_images/2371_right.jpg,[],['normal']
566
+ 564,08_ODIR-5K/preprocessed_images/2371_left.jpg,[],['normal']
567
+ 565,08_ODIR-5K/preprocessed_images/2372_right.jpg,[],['normal']
568
+ 566,08_ODIR-5K/preprocessed_images/2372_left.jpg,[],['normal']
569
+ 567,08_ODIR-5K/preprocessed_images/2373_right.jpg,[],['normal']
570
+ 568,08_ODIR-5K/preprocessed_images/2373_left.jpg,[],['normal']
571
+ 569,08_ODIR-5K/preprocessed_images/2374_right.jpg,[],['normal']
572
+ 570,08_ODIR-5K/preprocessed_images/2374_left.jpg,[],['normal']
573
+ 571,08_ODIR-5K/preprocessed_images/2375_right.jpg,[],['normal']
574
+ 572,08_ODIR-5K/preprocessed_images/2375_left.jpg,[],['normal']
575
+ 573,08_ODIR-5K/preprocessed_images/2376_right.jpg,[],['normal']
576
+ 574,08_ODIR-5K/preprocessed_images/2376_left.jpg,[],['normal']
577
+ 575,08_ODIR-5K/preprocessed_images/2378_right.jpg,[],['normal']
578
+ 576,08_ODIR-5K/preprocessed_images/2378_left.jpg,[],['normal']
579
+ 577,08_ODIR-5K/preprocessed_images/2379_right.jpg,[],['normal']
580
+ 578,08_ODIR-5K/preprocessed_images/2379_left.jpg,[],['normal']
581
+ 579,08_ODIR-5K/preprocessed_images/2380_right.jpg,[],['normal']
582
+ 580,08_ODIR-5K/preprocessed_images/13_right.jpg,[],['pathologic myopia']
583
+ 581,08_ODIR-5K/preprocessed_images/13_left.jpg,[],['pathologic myopia']
584
+ 582,08_ODIR-5K/preprocessed_images/16_right.jpg,[],['pathologic myopia']
585
+ 583,08_ODIR-5K/preprocessed_images/18_right.jpg,[],['pathologic myopia']
586
+ 584,08_ODIR-5K/preprocessed_images/18_left.jpg,[],['pathologic myopia']
587
+ 585,08_ODIR-5K/preprocessed_images/35_left.jpg,[],['pathologic myopia']
588
+ 586,08_ODIR-5K/preprocessed_images/39_left.jpg,[],['pathologic myopia']
589
+ 587,08_ODIR-5K/preprocessed_images/106_right.jpg,[],['pathologic myopia']
590
+ 588,08_ODIR-5K/preprocessed_images/106_left.jpg,[],['pathologic myopia']
591
+ 589,08_ODIR-5K/preprocessed_images/144_left.jpg,[],['pathologic myopia']
592
+ 590,08_ODIR-5K/preprocessed_images/145_right.jpg,[],['pathologic myopia']
593
+ 591,08_ODIR-5K/preprocessed_images/145_left.jpg,[],['pathologic myopia']
594
+ 592,08_ODIR-5K/preprocessed_images/174_left.jpg,[],['pathologic myopia']
595
+ 593,08_ODIR-5K/preprocessed_images/214_right.jpg,[],['pathologic myopia']
596
+ 594,08_ODIR-5K/preprocessed_images/233_right.jpg,[],['pathologic myopia']
597
+ 595,08_ODIR-5K/preprocessed_images/379_left.jpg,[],['pathologic myopia']
598
+ 596,08_ODIR-5K/preprocessed_images/382_right.jpg,[],['pathologic myopia']
599
+ 597,08_ODIR-5K/preprocessed_images/382_left.jpg,[],['pathologic myopia']
600
+ 598,08_ODIR-5K/preprocessed_images/390_right.jpg,[],['pathologic myopia']
601
+ 599,08_ODIR-5K/preprocessed_images/401_right.jpg,[],['pathologic myopia']
local_data/13_FIVES.csv ADDED
@@ -0,0 +1,801 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,image,atributes,categories
2
+ 0,fives_retina/train/Original/139_A.png,[],['age related macular degeneration']
3
+ 1,fives_retina/train/Original/193_D.png,[],['diabetic retinopathy']
4
+ 2,fives_retina/train/Original/146_A.png,[],['age related macular degeneration']
5
+ 3,fives_retina/train/Original/329_G.png,[],['glaucoma']
6
+ 4,fives_retina/train/Original/3_A.png,[],['age related macular degeneration']
7
+ 5,fives_retina/train/Original/97_A.png,[],['age related macular degeneration']
8
+ 6,fives_retina/train/Original/361_G.png,[],['glaucoma']
9
+ 7,fives_retina/train/Original/299_D.png,[],['diabetic retinopathy']
10
+ 8,fives_retina/train/Original/378_G.png,[],['glaucoma']
11
+ 9,fives_retina/train/Original/96_A.png,[],['age related macular degeneration']
12
+ 10,fives_retina/train/Original/138_A.png,[],['age related macular degeneration']
13
+ 11,fives_retina/train/Original/536_N.png,[],['normal']
14
+ 12,fives_retina/train/Original/347_G.png,[],['glaucoma']
15
+ 13,fives_retina/train/Original/213_D.png,[],['diabetic retinopathy']
16
+ 14,fives_retina/train/Original/86_A.png,[],['age related macular degeneration']
17
+ 15,fives_retina/train/Original/437_G.png,[],['glaucoma']
18
+ 16,fives_retina/train/Original/429_G.png,[],['glaucoma']
19
+ 17,fives_retina/train/Original/534_N.png,[],['normal']
20
+ 18,fives_retina/train/Original/235_D.png,[],['diabetic retinopathy']
21
+ 19,fives_retina/train/Original/352_G.png,[],['glaucoma']
22
+ 20,fives_retina/train/Original/24_A.png,[],['age related macular degeneration']
23
+ 21,fives_retina/train/Original/135_A.png,[],['age related macular degeneration']
24
+ 22,fives_retina/train/Original/117_A.png,[],['age related macular degeneration']
25
+ 23,fives_retina/train/Original/401_G.png,[],['glaucoma']
26
+ 24,fives_retina/train/Original/476_N.png,[],['normal']
27
+ 25,fives_retina/train/Original/189_D.png,[],['diabetic retinopathy']
28
+ 26,fives_retina/train/Original/77_A.png,[],['age related macular degeneration']
29
+ 27,fives_retina/train/Original/120_A.png,[],['age related macular degeneration']
30
+ 28,fives_retina/train/Original/428_G.png,[],['glaucoma']
31
+ 29,fives_retina/train/Original/89_A.png,[],['age related macular degeneration']
32
+ 30,fives_retina/train/Original/9_A.png,[],['age related macular degeneration']
33
+ 31,fives_retina/train/Original/561_N.png,[],['normal']
34
+ 32,fives_retina/train/Original/449_G.png,[],['glaucoma']
35
+ 33,fives_retina/train/Original/508_N.png,[],['normal']
36
+ 34,fives_retina/train/Original/362_G.png,[],['glaucoma']
37
+ 35,fives_retina/train/Original/448_G.png,[],['glaucoma']
38
+ 36,fives_retina/train/Original/531_N.png,[],['normal']
39
+ 37,fives_retina/train/Original/8_A.png,[],['age related macular degeneration']
40
+ 38,fives_retina/train/Original/376_G.png,[],['glaucoma']
41
+ 39,fives_retina/train/Original/423_G.png,[],['glaucoma']
42
+ 40,fives_retina/train/Original/590_N.png,[],['normal']
43
+ 41,fives_retina/train/Original/462_N.png,[],['normal']
44
+ 42,fives_retina/train/Original/496_N.png,[],['normal']
45
+ 43,fives_retina/train/Original/207_D.png,[],['diabetic retinopathy']
46
+ 44,fives_retina/train/Original/475_N.png,[],['normal']
47
+ 45,fives_retina/train/Original/295_D.png,[],['diabetic retinopathy']
48
+ 46,fives_retina/train/Original/445_G.png,[],['glaucoma']
49
+ 47,fives_retina/train/Original/576_N.png,[],['normal']
50
+ 48,fives_retina/train/Original/257_D.png,[],['diabetic retinopathy']
51
+ 49,fives_retina/train/Original/470_N.png,[],['normal']
52
+ 50,fives_retina/train/Original/252_D.png,[],['diabetic retinopathy']
53
+ 51,fives_retina/train/Original/48_A.png,[],['age related macular degeneration']
54
+ 52,fives_retina/train/Original/390_G.png,[],['glaucoma']
55
+ 53,fives_retina/train/Original/372_G.png,[],['glaucoma']
56
+ 54,fives_retina/train/Original/479_N.png,[],['normal']
57
+ 55,fives_retina/train/Original/320_G.png,[],['glaucoma']
58
+ 56,fives_retina/train/Original/394_G.png,[],['glaucoma']
59
+ 57,fives_retina/train/Original/358_G.png,[],['glaucoma']
60
+ 58,fives_retina/train/Original/144_A.png,[],['age related macular degeneration']
61
+ 59,fives_retina/train/Original/586_N.png,[],['normal']
62
+ 60,fives_retina/train/Original/364_G.png,[],['glaucoma']
63
+ 61,fives_retina/train/Original/456_N.png,[],['normal']
64
+ 62,fives_retina/train/Original/219_D.png,[],['diabetic retinopathy']
65
+ 63,fives_retina/train/Original/230_D.png,[],['diabetic retinopathy']
66
+ 64,fives_retina/train/Original/345_G.png,[],['glaucoma']
67
+ 65,fives_retina/train/Original/579_N.png,[],['normal']
68
+ 66,fives_retina/train/Original/338_G.png,[],['glaucoma']
69
+ 67,fives_retina/train/Original/156_D.png,[],['diabetic retinopathy']
70
+ 68,fives_retina/train/Original/272_D.png,[],['diabetic retinopathy']
71
+ 69,fives_retina/train/Original/526_N.png,[],['normal']
72
+ 70,fives_retina/train/Original/261_D.png,[],['diabetic retinopathy']
73
+ 71,fives_retina/train/Original/18_A.png,[],['age related macular degeneration']
74
+ 72,fives_retina/train/Original/71_A.png,[],['age related macular degeneration']
75
+ 73,fives_retina/train/Original/350_G.png,[],['glaucoma']
76
+ 74,fives_retina/train/Original/564_N.png,[],['normal']
77
+ 75,fives_retina/train/Original/184_D.png,[],['diabetic retinopathy']
78
+ 76,fives_retina/train/Original/495_N.png,[],['normal']
79
+ 77,fives_retina/train/Original/540_N.png,[],['normal']
80
+ 78,fives_retina/train/Original/176_D.png,[],['diabetic retinopathy']
81
+ 79,fives_retina/train/Original/270_D.png,[],['diabetic retinopathy']
82
+ 80,fives_retina/train/Original/468_N.png,[],['normal']
83
+ 81,fives_retina/train/Original/181_D.png,[],['diabetic retinopathy']
84
+ 82,fives_retina/train/Original/260_D.png,[],['diabetic retinopathy']
85
+ 83,fives_retina/train/Original/205_D.png,[],['diabetic retinopathy']
86
+ 84,fives_retina/train/Original/37_A.png,[],['age related macular degeneration']
87
+ 85,fives_retina/train/Original/284_D.png,[],['diabetic retinopathy']
88
+ 86,fives_retina/train/Original/582_N.png,[],['normal']
89
+ 87,fives_retina/train/Original/99_A.png,[],['age related macular degeneration']
90
+ 88,fives_retina/train/Original/240_D.png,[],['diabetic retinopathy']
91
+ 89,fives_retina/train/Original/366_G.png,[],['glaucoma']
92
+ 90,fives_retina/train/Original/380_G.png,[],['glaucoma']
93
+ 91,fives_retina/train/Original/528_N.png,[],['normal']
94
+ 92,fives_retina/train/Original/35_A.png,[],['age related macular degeneration']
95
+ 93,fives_retina/train/Original/90_A.png,[],['age related macular degeneration']
96
+ 94,fives_retina/train/Original/182_D.png,[],['diabetic retinopathy']
97
+ 95,fives_retina/train/Original/516_N.png,[],['normal']
98
+ 96,fives_retina/train/Original/420_G.png,[],['glaucoma']
99
+ 97,fives_retina/train/Original/509_N.png,[],['normal']
100
+ 98,fives_retina/train/Original/503_N.png,[],['normal']
101
+ 99,fives_retina/train/Original/51_A.png,[],['age related macular degeneration']
102
+ 100,fives_retina/train/Original/517_N.png,[],['normal']
103
+ 101,fives_retina/train/Original/36_A.png,[],['age related macular degeneration']
104
+ 102,fives_retina/train/Original/229_D.png,[],['diabetic retinopathy']
105
+ 103,fives_retina/train/Original/430_G.png,[],['glaucoma']
106
+ 104,fives_retina/train/Original/370_G.png,[],['glaucoma']
107
+ 105,fives_retina/train/Original/94_A.png,[],['age related macular degeneration']
108
+ 106,fives_retina/train/Original/485_N.png,[],['normal']
109
+ 107,fives_retina/train/Original/149_A.png,[],['age related macular degeneration']
110
+ 108,fives_retina/train/Original/55_A.png,[],['age related macular degeneration']
111
+ 109,fives_retina/train/Original/123_A.png,[],['age related macular degeneration']
112
+ 110,fives_retina/train/Original/40_A.png,[],['age related macular degeneration']
113
+ 111,fives_retina/train/Original/537_N.png,[],['normal']
114
+ 112,fives_retina/train/Original/173_D.png,[],['diabetic retinopathy']
115
+ 113,fives_retina/train/Original/481_N.png,[],['normal']
116
+ 114,fives_retina/train/Original/131_A.png,[],['age related macular degeneration']
117
+ 115,fives_retina/train/Original/23_A.png,[],['age related macular degeneration']
118
+ 116,fives_retina/train/Original/141_A.png,[],['age related macular degeneration']
119
+ 117,fives_retina/train/Original/487_N.png,[],['normal']
120
+ 118,fives_retina/train/Original/554_N.png,[],['normal']
121
+ 119,fives_retina/train/Original/346_G.png,[],['glaucoma']
122
+ 120,fives_retina/train/Original/552_N.png,[],['normal']
123
+ 121,fives_retina/train/Original/87_A.png,[],['age related macular degeneration']
124
+ 122,fives_retina/train/Original/4_A.png,[],['age related macular degeneration']
125
+ 123,fives_retina/train/Original/559_N.png,[],['normal']
126
+ 124,fives_retina/train/Original/7_A.png,[],['age related macular degeneration']
127
+ 125,fives_retina/train/Original/593_N.png,[],['normal']
128
+ 126,fives_retina/train/Original/326_G.png,[],['glaucoma']
129
+ 127,fives_retina/train/Original/298_D.png,[],['diabetic retinopathy']
130
+ 128,fives_retina/train/Original/243_D.png,[],['diabetic retinopathy']
131
+ 129,fives_retina/train/Original/507_N.png,[],['normal']
132
+ 130,fives_retina/train/Original/497_N.png,[],['normal']
133
+ 131,fives_retina/train/Original/391_G.png,[],['glaucoma']
134
+ 132,fives_retina/train/Original/575_N.png,[],['normal']
135
+ 133,fives_retina/train/Original/274_D.png,[],['diabetic retinopathy']
136
+ 134,fives_retina/train/Original/399_G.png,[],['glaucoma']
137
+ 135,fives_retina/train/Original/533_N.png,[],['normal']
138
+ 136,fives_retina/train/Original/285_D.png,[],['diabetic retinopathy']
139
+ 137,fives_retina/train/Original/489_N.png,[],['normal']
140
+ 138,fives_retina/train/Original/147_A.png,[],['age related macular degeneration']
141
+ 139,fives_retina/train/Original/332_G.png,[],['glaucoma']
142
+ 140,fives_retina/train/Original/418_G.png,[],['glaucoma']
143
+ 141,fives_retina/train/Original/404_G.png,[],['glaucoma']
144
+ 142,fives_retina/train/Original/467_N.png,[],['normal']
145
+ 143,fives_retina/train/Original/64_A.png,[],['age related macular degeneration']
146
+ 144,fives_retina/train/Original/563_N.png,[],['normal']
147
+ 145,fives_retina/train/Original/340_G.png,[],['glaucoma']
148
+ 146,fives_retina/train/Original/30_A.png,[],['age related macular degeneration']
149
+ 147,fives_retina/train/Original/520_N.png,[],['normal']
150
+ 148,fives_retina/train/Original/175_D.png,[],['diabetic retinopathy']
151
+ 149,fives_retina/train/Original/58_A.png,[],['age related macular degeneration']
152
+ 150,fives_retina/train/Original/494_N.png,[],['normal']
153
+ 151,fives_retina/train/Original/227_D.png,[],['diabetic retinopathy']
154
+ 152,fives_retina/train/Original/162_D.png,[],['diabetic retinopathy']
155
+ 153,fives_retina/train/Original/150_A.png,[],['age related macular degeneration']
156
+ 154,fives_retina/train/Original/377_G.png,[],['glaucoma']
157
+ 155,fives_retina/train/Original/98_A.png,[],['age related macular degeneration']
158
+ 156,fives_retina/train/Original/385_G.png,[],['glaucoma']
159
+ 157,fives_retina/train/Original/59_A.png,[],['age related macular degeneration']
160
+ 158,fives_retina/train/Original/91_A.png,[],['age related macular degeneration']
161
+ 159,fives_retina/train/Original/192_D.png,[],['diabetic retinopathy']
162
+ 160,fives_retina/train/Original/38_A.png,[],['age related macular degeneration']
163
+ 161,fives_retina/train/Original/486_N.png,[],['normal']
164
+ 162,fives_retina/train/Original/568_N.png,[],['normal']
165
+ 163,fives_retina/train/Original/281_D.png,[],['diabetic retinopathy']
166
+ 164,fives_retina/train/Original/194_D.png,[],['diabetic retinopathy']
167
+ 165,fives_retina/train/Original/501_N.png,[],['normal']
168
+ 166,fives_retina/train/Original/291_D.png,[],['diabetic retinopathy']
169
+ 167,fives_retina/train/Original/178_D.png,[],['diabetic retinopathy']
170
+ 168,fives_retina/train/Original/588_N.png,[],['normal']
171
+ 169,fives_retina/train/Original/256_D.png,[],['diabetic retinopathy']
172
+ 170,fives_retina/train/Original/311_G.png,[],['glaucoma']
173
+ 171,fives_retina/train/Original/572_N.png,[],['normal']
174
+ 172,fives_retina/train/Original/196_D.png,[],['diabetic retinopathy']
175
+ 173,fives_retina/train/Original/239_D.png,[],['diabetic retinopathy']
176
+ 174,fives_retina/train/Original/553_N.png,[],['normal']
177
+ 175,fives_retina/train/Original/502_N.png,[],['normal']
178
+ 176,fives_retina/train/Original/5_A.png,[],['age related macular degeneration']
179
+ 177,fives_retina/train/Original/324_G.png,[],['glaucoma']
180
+ 178,fives_retina/train/Original/165_D.png,[],['diabetic retinopathy']
181
+ 179,fives_retina/train/Original/43_A.png,[],['age related macular degeneration']
182
+ 180,fives_retina/train/Original/212_D.png,[],['diabetic retinopathy']
183
+ 181,fives_retina/train/Original/143_A.png,[],['age related macular degeneration']
184
+ 182,fives_retina/train/Original/434_G.png,[],['glaucoma']
185
+ 183,fives_retina/train/Original/152_D.png,[],['diabetic retinopathy']
186
+ 184,fives_retina/train/Original/413_G.png,[],['glaucoma']
187
+ 185,fives_retina/train/Original/136_A.png,[],['age related macular degeneration']
188
+ 186,fives_retina/train/Original/483_N.png,[],['normal']
189
+ 187,fives_retina/train/Original/168_D.png,[],['diabetic retinopathy']
190
+ 188,fives_retina/train/Original/218_D.png,[],['diabetic retinopathy']
191
+ 189,fives_retina/train/Original/339_G.png,[],['glaucoma']
192
+ 190,fives_retina/train/Original/241_D.png,[],['diabetic retinopathy']
193
+ 191,fives_retina/train/Original/68_A.png,[],['age related macular degeneration']
194
+ 192,fives_retina/train/Original/354_G.png,[],['glaucoma']
195
+ 193,fives_retina/train/Original/515_N.png,[],['normal']
196
+ 194,fives_retina/train/Original/145_A.png,[],['age related macular degeneration']
197
+ 195,fives_retina/train/Original/337_G.png,[],['glaucoma']
198
+ 196,fives_retina/train/Original/381_G.png,[],['glaucoma']
199
+ 197,fives_retina/train/Original/191_D.png,[],['diabetic retinopathy']
200
+ 198,fives_retina/train/Original/511_N.png,[],['normal']
201
+ 199,fives_retina/train/Original/327_G.png,[],['glaucoma']
202
+ 200,fives_retina/train/Original/454_N.png,[],['normal']
203
+ 201,fives_retina/train/Original/523_N.png,[],['normal']
204
+ 202,fives_retina/train/Original/532_N.png,[],['normal']
205
+ 203,fives_retina/train/Original/221_D.png,[],['diabetic retinopathy']
206
+ 204,fives_retina/train/Original/125_A.png,[],['age related macular degeneration']
207
+ 205,fives_retina/train/Original/78_A.png,[],['age related macular degeneration']
208
+ 206,fives_retina/train/Original/126_A.png,[],['age related macular degeneration']
209
+ 207,fives_retina/train/Original/480_N.png,[],['normal']
210
+ 208,fives_retina/train/Original/180_D.png,[],['diabetic retinopathy']
211
+ 209,fives_retina/train/Original/341_G.png,[],['glaucoma']
212
+ 210,fives_retina/train/Original/539_N.png,[],['normal']
213
+ 211,fives_retina/train/Original/47_A.png,[],['age related macular degeneration']
214
+ 212,fives_retina/train/Original/353_G.png,[],['glaucoma']
215
+ 213,fives_retina/train/Original/277_D.png,[],['diabetic retinopathy']
216
+ 214,fives_retina/train/Original/204_D.png,[],['diabetic retinopathy']
217
+ 215,fives_retina/train/Original/160_D.png,[],['diabetic retinopathy']
218
+ 216,fives_retina/train/Original/414_G.png,[],['glaucoma']
219
+ 217,fives_retina/train/Original/546_N.png,[],['normal']
220
+ 218,fives_retina/train/Original/464_N.png,[],['normal']
221
+ 219,fives_retina/train/Original/542_N.png,[],['normal']
222
+ 220,fives_retina/train/Original/22_A.png,[],['age related macular degeneration']
223
+ 221,fives_retina/train/Original/57_A.png,[],['age related macular degeneration']
224
+ 222,fives_retina/train/Original/121_A.png,[],['age related macular degeneration']
225
+ 223,fives_retina/train/Original/166_D.png,[],['diabetic retinopathy']
226
+ 224,fives_retina/train/Original/259_D.png,[],['diabetic retinopathy']
227
+ 225,fives_retina/train/Original/313_G.png,[],['glaucoma']
228
+ 226,fives_retina/train/Original/174_D.png,[],['diabetic retinopathy']
229
+ 227,fives_retina/train/Original/1_A.png,[],['age related macular degeneration']
230
+ 228,fives_retina/train/Original/551_N.png,[],['normal']
231
+ 229,fives_retina/train/Original/50_A.png,[],['age related macular degeneration']
232
+ 230,fives_retina/train/Original/379_G.png,[],['glaucoma']
233
+ 231,fives_retina/train/Original/122_A.png,[],['age related macular degeneration']
234
+ 232,fives_retina/train/Original/493_N.png,[],['normal']
235
+ 233,fives_retina/train/Original/548_N.png,[],['normal']
236
+ 234,fives_retina/train/Original/109_A.png,[],['age related macular degeneration']
237
+ 235,fives_retina/train/Original/518_N.png,[],['normal']
238
+ 236,fives_retina/train/Original/231_D.png,[],['diabetic retinopathy']
239
+ 237,fives_retina/train/Original/183_D.png,[],['diabetic retinopathy']
240
+ 238,fives_retina/train/Original/421_G.png,[],['glaucoma']
241
+ 239,fives_retina/train/Original/81_A.png,[],['age related macular degeneration']
242
+ 240,fives_retina/train/Original/398_G.png,[],['glaucoma']
243
+ 241,fives_retina/train/Original/280_D.png,[],['diabetic retinopathy']
244
+ 242,fives_retina/train/Original/524_N.png,[],['normal']
245
+ 243,fives_retina/train/Original/305_G.png,[],['glaucoma']
246
+ 244,fives_retina/train/Original/471_N.png,[],['normal']
247
+ 245,fives_retina/train/Original/75_A.png,[],['age related macular degeneration']
248
+ 246,fives_retina/train/Original/54_A.png,[],['age related macular degeneration']
249
+ 247,fives_retina/train/Original/83_A.png,[],['age related macular degeneration']
250
+ 248,fives_retina/train/Original/484_N.png,[],['normal']
251
+ 249,fives_retina/train/Original/514_N.png,[],['normal']
252
+ 250,fives_retina/train/Original/415_G.png,[],['glaucoma']
253
+ 251,fives_retina/train/Original/153_D.png,[],['diabetic retinopathy']
254
+ 252,fives_retina/train/Original/41_A.png,[],['age related macular degeneration']
255
+ 253,fives_retina/train/Original/451_N.png,[],['normal']
256
+ 254,fives_retina/train/Original/186_D.png,[],['diabetic retinopathy']
257
+ 255,fives_retina/train/Original/583_N.png,[],['normal']
258
+ 256,fives_retina/train/Original/488_N.png,[],['normal']
259
+ 257,fives_retina/train/Original/142_A.png,[],['age related macular degeneration']
260
+ 258,fives_retina/train/Original/116_A.png,[],['age related macular degeneration']
261
+ 259,fives_retina/train/Original/72_A.png,[],['age related macular degeneration']
262
+ 260,fives_retina/train/Original/288_D.png,[],['diabetic retinopathy']
263
+ 261,fives_retina/train/Original/375_G.png,[],['glaucoma']
264
+ 262,fives_retina/train/Original/236_D.png,[],['diabetic retinopathy']
265
+ 263,fives_retina/train/Original/14_A.png,[],['age related macular degeneration']
266
+ 264,fives_retina/train/Original/108_A.png,[],['age related macular degeneration']
267
+ 265,fives_retina/train/Original/124_A.png,[],['age related macular degeneration']
268
+ 266,fives_retina/train/Original/315_G.png,[],['glaucoma']
269
+ 267,fives_retina/train/Original/294_D.png,[],['diabetic retinopathy']
270
+ 268,fives_retina/train/Original/13_A.png,[],['age related macular degeneration']
271
+ 269,fives_retina/train/Original/88_A.png,[],['age related macular degeneration']
272
+ 270,fives_retina/train/Original/76_A.png,[],['age related macular degeneration']
273
+ 271,fives_retina/train/Original/458_N.png,[],['normal']
274
+ 272,fives_retina/train/Original/512_N.png,[],['normal']
275
+ 273,fives_retina/train/Original/558_N.png,[],['normal']
276
+ 274,fives_retina/train/Original/459_N.png,[],['normal']
277
+ 275,fives_retina/train/Original/308_G.png,[],['glaucoma']
278
+ 276,fives_retina/train/Original/132_A.png,[],['age related macular degeneration']
279
+ 277,fives_retina/train/Original/334_G.png,[],['glaucoma']
280
+ 278,fives_retina/train/Original/102_A.png,[],['age related macular degeneration']
281
+ 279,fives_retina/train/Original/465_N.png,[],['normal']
282
+ 280,fives_retina/train/Original/594_N.png,[],['normal']
283
+ 281,fives_retina/train/Original/478_N.png,[],['normal']
284
+ 282,fives_retina/train/Original/290_D.png,[],['diabetic retinopathy']
285
+ 283,fives_retina/train/Original/359_G.png,[],['glaucoma']
286
+ 284,fives_retina/train/Original/384_G.png,[],['glaucoma']
287
+ 285,fives_retina/train/Original/65_A.png,[],['age related macular degeneration']
288
+ 286,fives_retina/train/Original/439_G.png,[],['glaucoma']
289
+ 287,fives_retina/train/Original/450_G.png,[],['glaucoma']
290
+ 288,fives_retina/train/Original/129_A.png,[],['age related macular degeneration']
291
+ 289,fives_retina/train/Original/73_A.png,[],['age related macular degeneration']
292
+ 290,fives_retina/train/Original/578_N.png,[],['normal']
293
+ 291,fives_retina/train/Original/573_N.png,[],['normal']
294
+ 292,fives_retina/train/Original/276_D.png,[],['diabetic retinopathy']
295
+ 293,fives_retina/train/Original/251_D.png,[],['diabetic retinopathy']
296
+ 294,fives_retina/train/Original/419_G.png,[],['glaucoma']
297
+ 295,fives_retina/train/Original/422_G.png,[],['glaucoma']
298
+ 296,fives_retina/train/Original/278_D.png,[],['diabetic retinopathy']
299
+ 297,fives_retina/train/Original/265_D.png,[],['diabetic retinopathy']
300
+ 298,fives_retina/train/Original/19_A.png,[],['age related macular degeneration']
301
+ 299,fives_retina/train/Original/177_D.png,[],['diabetic retinopathy']
302
+ 300,fives_retina/train/Original/69_A.png,[],['age related macular degeneration']
303
+ 301,fives_retina/train/Original/119_A.png,[],['age related macular degeneration']
304
+ 302,fives_retina/train/Original/333_G.png,[],['glaucoma']
305
+ 303,fives_retina/train/Original/248_D.png,[],['diabetic retinopathy']
306
+ 304,fives_retina/train/Original/80_A.png,[],['age related macular degeneration']
307
+ 305,fives_retina/train/Original/360_G.png,[],['glaucoma']
308
+ 306,fives_retina/train/Original/107_A.png,[],['age related macular degeneration']
309
+ 307,fives_retina/train/Original/469_N.png,[],['normal']
310
+ 308,fives_retina/train/Original/267_D.png,[],['diabetic retinopathy']
311
+ 309,fives_retina/train/Original/541_N.png,[],['normal']
312
+ 310,fives_retina/train/Original/198_D.png,[],['diabetic retinopathy']
313
+ 311,fives_retina/train/Original/171_D.png,[],['diabetic retinopathy']
314
+ 312,fives_retina/train/Original/70_A.png,[],['age related macular degeneration']
315
+ 313,fives_retina/train/Original/100_A.png,[],['age related macular degeneration']
316
+ 314,fives_retina/train/Original/45_A.png,[],['age related macular degeneration']
317
+ 315,fives_retina/train/Original/190_D.png,[],['diabetic retinopathy']
318
+ 316,fives_retina/train/Original/110_A.png,[],['age related macular degeneration']
319
+ 317,fives_retina/train/Original/169_D.png,[],['diabetic retinopathy']
320
+ 318,fives_retina/train/Original/599_N.png,[],['normal']
321
+ 319,fives_retina/train/Original/356_G.png,[],['glaucoma']
322
+ 320,fives_retina/train/Original/530_N.png,[],['normal']
323
+ 321,fives_retina/train/Original/155_D.png,[],['diabetic retinopathy']
324
+ 322,fives_retina/train/Original/237_D.png,[],['diabetic retinopathy']
325
+ 323,fives_retina/train/Original/426_G.png,[],['glaucoma']
326
+ 324,fives_retina/train/Original/61_A.png,[],['age related macular degeneration']
327
+ 325,fives_retina/train/Original/200_D.png,[],['diabetic retinopathy']
328
+ 326,fives_retina/train/Original/314_G.png,[],['glaucoma']
329
+ 327,fives_retina/train/Original/319_G.png,[],['glaucoma']
330
+ 328,fives_retina/train/Original/570_N.png,[],['normal']
331
+ 329,fives_retina/train/Original/397_G.png,[],['glaucoma']
332
+ 330,fives_retina/train/Original/457_N.png,[],['normal']
333
+ 331,fives_retina/train/Original/304_G.png,[],['glaucoma']
334
+ 332,fives_retina/train/Original/444_G.png,[],['glaucoma']
335
+ 333,fives_retina/train/Original/442_G.png,[],['glaucoma']
336
+ 334,fives_retina/train/Original/555_N.png,[],['normal']
337
+ 335,fives_retina/train/Original/29_A.png,[],['age related macular degeneration']
338
+ 336,fives_retina/train/Original/473_N.png,[],['normal']
339
+ 337,fives_retina/train/Original/297_D.png,[],['diabetic retinopathy']
340
+ 338,fives_retina/train/Original/154_D.png,[],['diabetic retinopathy']
341
+ 339,fives_retina/train/Original/101_A.png,[],['age related macular degeneration']
342
+ 340,fives_retina/train/Original/130_A.png,[],['age related macular degeneration']
343
+ 341,fives_retina/train/Original/405_G.png,[],['glaucoma']
344
+ 342,fives_retina/train/Original/492_N.png,[],['normal']
345
+ 343,fives_retina/train/Original/574_N.png,[],['normal']
346
+ 344,fives_retina/train/Original/490_N.png,[],['normal']
347
+ 345,fives_retina/train/Original/571_N.png,[],['normal']
348
+ 346,fives_retina/train/Original/301_G.png,[],['glaucoma']
349
+ 347,fives_retina/train/Original/289_D.png,[],['diabetic retinopathy']
350
+ 348,fives_retina/train/Original/63_A.png,[],['age related macular degeneration']
351
+ 349,fives_retina/train/Original/408_G.png,[],['glaucoma']
352
+ 350,fives_retina/train/Original/238_D.png,[],['diabetic retinopathy']
353
+ 351,fives_retina/train/Original/371_G.png,[],['glaucoma']
354
+ 352,fives_retina/train/Original/82_A.png,[],['age related macular degeneration']
355
+ 353,fives_retina/train/Original/368_G.png,[],['glaucoma']
356
+ 354,fives_retina/train/Original/374_G.png,[],['glaucoma']
357
+ 355,fives_retina/train/Original/323_G.png,[],['glaucoma']
358
+ 356,fives_retina/train/Original/225_D.png,[],['diabetic retinopathy']
359
+ 357,fives_retina/train/Original/477_N.png,[],['normal']
360
+ 358,fives_retina/train/Original/2_A.png,[],['age related macular degeneration']
361
+ 359,fives_retina/train/Original/127_A.png,[],['age related macular degeneration']
362
+ 360,fives_retina/train/Original/113_A.png,[],['age related macular degeneration']
363
+ 361,fives_retina/train/Original/211_D.png,[],['diabetic retinopathy']
364
+ 362,fives_retina/train/Original/137_A.png,[],['age related macular degeneration']
365
+ 363,fives_retina/train/Original/208_D.png,[],['diabetic retinopathy']
366
+ 364,fives_retina/train/Original/163_D.png,[],['diabetic retinopathy']
367
+ 365,fives_retina/train/Original/206_D.png,[],['diabetic retinopathy']
368
+ 366,fives_retina/train/Original/440_G.png,[],['glaucoma']
369
+ 367,fives_retina/train/Original/74_A.png,[],['age related macular degeneration']
370
+ 368,fives_retina/train/Original/425_G.png,[],['glaucoma']
371
+ 369,fives_retina/train/Original/275_D.png,[],['diabetic retinopathy']
372
+ 370,fives_retina/train/Original/62_A.png,[],['age related macular degeneration']
373
+ 371,fives_retina/train/Original/567_N.png,[],['normal']
374
+ 372,fives_retina/train/Original/53_A.png,[],['age related macular degeneration']
375
+ 373,fives_retina/train/Original/56_A.png,[],['age related macular degeneration']
376
+ 374,fives_retina/train/Original/27_A.png,[],['age related macular degeneration']
377
+ 375,fives_retina/train/Original/26_A.png,[],['age related macular degeneration']
378
+ 376,fives_retina/train/Original/565_N.png,[],['normal']
379
+ 377,fives_retina/train/Original/220_D.png,[],['diabetic retinopathy']
380
+ 378,fives_retina/train/Original/226_D.png,[],['diabetic retinopathy']
381
+ 379,fives_retina/train/Original/233_D.png,[],['diabetic retinopathy']
382
+ 380,fives_retina/train/Original/447_G.png,[],['glaucoma']
383
+ 381,fives_retina/train/Original/202_D.png,[],['diabetic retinopathy']
384
+ 382,fives_retina/train/Original/106_A.png,[],['age related macular degeneration']
385
+ 383,fives_retina/train/Original/255_D.png,[],['diabetic retinopathy']
386
+ 384,fives_retina/train/Original/264_D.png,[],['diabetic retinopathy']
387
+ 385,fives_retina/train/Original/577_N.png,[],['normal']
388
+ 386,fives_retina/train/Original/342_G.png,[],['glaucoma']
389
+ 387,fives_retina/train/Original/111_A.png,[],['age related macular degeneration']
390
+ 388,fives_retina/train/Original/10_A.png,[],['age related macular degeneration']
391
+ 389,fives_retina/train/Original/6_A.png,[],['age related macular degeneration']
392
+ 390,fives_retina/train/Original/336_G.png,[],['glaucoma']
393
+ 391,fives_retina/train/Original/547_N.png,[],['normal']
394
+ 392,fives_retina/train/Original/34_A.png,[],['age related macular degeneration']
395
+ 393,fives_retina/train/Original/93_A.png,[],['age related macular degeneration']
396
+ 394,fives_retina/train/Original/49_A.png,[],['age related macular degeneration']
397
+ 395,fives_retina/train/Original/365_G.png,[],['glaucoma']
398
+ 396,fives_retina/train/Original/21_A.png,[],['age related macular degeneration']
399
+ 397,fives_retina/train/Original/543_N.png,[],['normal']
400
+ 398,fives_retina/train/Original/148_A.png,[],['age related macular degeneration']
401
+ 399,fives_retina/train/Original/351_G.png,[],['glaucoma']
402
+ 400,fives_retina/train/Original/292_D.png,[],['diabetic retinopathy']
403
+ 401,fives_retina/train/Original/263_D.png,[],['diabetic retinopathy']
404
+ 402,fives_retina/train/Original/112_A.png,[],['age related macular degeneration']
405
+ 403,fives_retina/train/Original/435_G.png,[],['glaucoma']
406
+ 404,fives_retina/train/Original/460_N.png,[],['normal']
407
+ 405,fives_retina/train/Original/187_D.png,[],['diabetic retinopathy']
408
+ 406,fives_retina/train/Original/386_G.png,[],['glaucoma']
409
+ 407,fives_retina/train/Original/151_D.png,[],['diabetic retinopathy']
410
+ 408,fives_retina/train/Original/268_D.png,[],['diabetic retinopathy']
411
+ 409,fives_retina/train/Original/506_N.png,[],['normal']
412
+ 410,fives_retina/train/Original/282_D.png,[],['diabetic retinopathy']
413
+ 411,fives_retina/train/Original/269_D.png,[],['diabetic retinopathy']
414
+ 412,fives_retina/train/Original/410_G.png,[],['glaucoma']
415
+ 413,fives_retina/train/Original/441_G.png,[],['glaucoma']
416
+ 414,fives_retina/train/Original/16_A.png,[],['age related macular degeneration']
417
+ 415,fives_retina/train/Original/32_A.png,[],['age related macular degeneration']
418
+ 416,fives_retina/train/Original/302_G.png,[],['glaucoma']
419
+ 417,fives_retina/train/Original/396_G.png,[],['glaucoma']
420
+ 418,fives_retina/train/Original/170_D.png,[],['diabetic retinopathy']
421
+ 419,fives_retina/train/Original/322_G.png,[],['glaucoma']
422
+ 420,fives_retina/train/Original/92_A.png,[],['age related macular degeneration']
423
+ 421,fives_retina/train/Original/556_N.png,[],['normal']
424
+ 422,fives_retina/train/Original/79_A.png,[],['age related macular degeneration']
425
+ 423,fives_retina/train/Original/25_A.png,[],['age related macular degeneration']
426
+ 424,fives_retina/train/Original/436_G.png,[],['glaucoma']
427
+ 425,fives_retina/train/Original/245_D.png,[],['diabetic retinopathy']
428
+ 426,fives_retina/train/Original/214_D.png,[],['diabetic retinopathy']
429
+ 427,fives_retina/train/Original/452_N.png,[],['normal']
430
+ 428,fives_retina/train/Original/330_G.png,[],['glaucoma']
431
+ 429,fives_retina/train/Original/201_D.png,[],['diabetic retinopathy']
432
+ 430,fives_retina/train/Original/203_D.png,[],['diabetic retinopathy']
433
+ 431,fives_retina/train/Original/161_D.png,[],['diabetic retinopathy']
434
+ 432,fives_retina/train/Original/505_N.png,[],['normal']
435
+ 433,fives_retina/train/Original/557_N.png,[],['normal']
436
+ 434,fives_retina/train/Original/140_A.png,[],['age related macular degeneration']
437
+ 435,fives_retina/train/Original/566_N.png,[],['normal']
438
+ 436,fives_retina/train/Original/453_N.png,[],['normal']
439
+ 437,fives_retina/train/Original/427_G.png,[],['glaucoma']
440
+ 438,fives_retina/train/Original/580_N.png,[],['normal']
441
+ 439,fives_retina/train/Original/409_G.png,[],['glaucoma']
442
+ 440,fives_retina/train/Original/402_G.png,[],['glaucoma']
443
+ 441,fives_retina/train/Original/393_G.png,[],['glaucoma']
444
+ 442,fives_retina/train/Original/17_A.png,[],['age related macular degeneration']
445
+ 443,fives_retina/train/Original/400_G.png,[],['glaucoma']
446
+ 444,fives_retina/train/Original/254_D.png,[],['diabetic retinopathy']
447
+ 445,fives_retina/train/Original/115_A.png,[],['age related macular degeneration']
448
+ 446,fives_retina/train/Original/585_N.png,[],['normal']
449
+ 447,fives_retina/train/Original/389_G.png,[],['glaucoma']
450
+ 448,fives_retina/train/Original/521_N.png,[],['normal']
451
+ 449,fives_retina/train/Original/179_D.png,[],['diabetic retinopathy']
452
+ 450,fives_retina/train/Original/266_D.png,[],['diabetic retinopathy']
453
+ 451,fives_retina/train/Original/303_G.png,[],['glaucoma']
454
+ 452,fives_retina/train/Original/262_D.png,[],['diabetic retinopathy']
455
+ 453,fives_retina/train/Original/20_A.png,[],['age related macular degeneration']
456
+ 454,fives_retina/train/Original/172_D.png,[],['diabetic retinopathy']
457
+ 455,fives_retina/train/Original/504_N.png,[],['normal']
458
+ 456,fives_retina/train/Original/312_G.png,[],['glaucoma']
459
+ 457,fives_retina/train/Original/188_D.png,[],['diabetic retinopathy']
460
+ 458,fives_retina/train/Original/438_G.png,[],['glaucoma']
461
+ 459,fives_retina/train/Original/412_G.png,[],['glaucoma']
462
+ 460,fives_retina/train/Original/66_A.png,[],['age related macular degeneration']
463
+ 461,fives_retina/train/Original/222_D.png,[],['diabetic retinopathy']
464
+ 462,fives_retina/train/Original/310_G.png,[],['glaucoma']
465
+ 463,fives_retina/train/Original/134_A.png,[],['age related macular degeneration']
466
+ 464,fives_retina/train/Original/584_N.png,[],['normal']
467
+ 465,fives_retina/train/Original/242_D.png,[],['diabetic retinopathy']
468
+ 466,fives_retina/train/Original/466_N.png,[],['normal']
469
+ 467,fives_retina/train/Original/592_N.png,[],['normal']
470
+ 468,fives_retina/train/Original/84_A.png,[],['age related macular degeneration']
471
+ 469,fives_retina/train/Original/114_A.png,[],['age related macular degeneration']
472
+ 470,fives_retina/train/Original/387_G.png,[],['glaucoma']
473
+ 471,fives_retina/train/Original/217_D.png,[],['diabetic retinopathy']
474
+ 472,fives_retina/train/Original/42_A.png,[],['age related macular degeneration']
475
+ 473,fives_retina/train/Original/461_N.png,[],['normal']
476
+ 474,fives_retina/train/Original/587_N.png,[],['normal']
477
+ 475,fives_retina/train/Original/463_N.png,[],['normal']
478
+ 476,fives_retina/train/Original/395_G.png,[],['glaucoma']
479
+ 477,fives_retina/train/Original/28_A.png,[],['age related macular degeneration']
480
+ 478,fives_retina/train/Original/33_A.png,[],['age related macular degeneration']
481
+ 479,fives_retina/train/Original/482_N.png,[],['normal']
482
+ 480,fives_retina/train/Original/271_D.png,[],['diabetic retinopathy']
483
+ 481,fives_retina/train/Original/407_G.png,[],['glaucoma']
484
+ 482,fives_retina/train/Original/224_D.png,[],['diabetic retinopathy']
485
+ 483,fives_retina/train/Original/249_D.png,[],['diabetic retinopathy']
486
+ 484,fives_retina/train/Original/598_N.png,[],['normal']
487
+ 485,fives_retina/train/Original/273_D.png,[],['diabetic retinopathy']
488
+ 486,fives_retina/train/Original/357_G.png,[],['glaucoma']
489
+ 487,fives_retina/train/Original/433_G.png,[],['glaucoma']
490
+ 488,fives_retina/train/Original/424_G.png,[],['glaucoma']
491
+ 489,fives_retina/train/Original/39_A.png,[],['age related macular degeneration']
492
+ 490,fives_retina/train/Original/529_N.png,[],['normal']
493
+ 491,fives_retina/train/Original/388_G.png,[],['glaucoma']
494
+ 492,fives_retina/train/Original/216_D.png,[],['diabetic retinopathy']
495
+ 493,fives_retina/train/Original/287_D.png,[],['diabetic retinopathy']
496
+ 494,fives_retina/train/Original/331_G.png,[],['glaucoma']
497
+ 495,fives_retina/train/Original/367_G.png,[],['glaucoma']
498
+ 496,fives_retina/train/Original/510_N.png,[],['normal']
499
+ 497,fives_retina/train/Original/133_A.png,[],['age related macular degeneration']
500
+ 498,fives_retina/train/Original/215_D.png,[],['diabetic retinopathy']
501
+ 499,fives_retina/train/Original/569_N.png,[],['normal']
502
+ 500,fives_retina/train/Original/431_G.png,[],['glaucoma']
503
+ 501,fives_retina/train/Original/522_N.png,[],['normal']
504
+ 502,fives_retina/train/Original/545_N.png,[],['normal']
505
+ 503,fives_retina/train/Original/369_G.png,[],['glaucoma']
506
+ 504,fives_retina/train/Original/328_G.png,[],['glaucoma']
507
+ 505,fives_retina/train/Original/250_D.png,[],['diabetic retinopathy']
508
+ 506,fives_retina/train/Original/549_N.png,[],['normal']
509
+ 507,fives_retina/train/Original/195_D.png,[],['diabetic retinopathy']
510
+ 508,fives_retina/train/Original/95_A.png,[],['age related macular degeneration']
511
+ 509,fives_retina/train/Original/197_D.png,[],['diabetic retinopathy']
512
+ 510,fives_retina/train/Original/597_N.png,[],['normal']
513
+ 511,fives_retina/train/Original/286_D.png,[],['diabetic retinopathy']
514
+ 512,fives_retina/train/Original/513_N.png,[],['normal']
515
+ 513,fives_retina/train/Original/383_G.png,[],['glaucoma']
516
+ 514,fives_retina/train/Original/246_D.png,[],['diabetic retinopathy']
517
+ 515,fives_retina/train/Original/283_D.png,[],['diabetic retinopathy']
518
+ 516,fives_retina/train/Original/527_N.png,[],['normal']
519
+ 517,fives_retina/train/Original/15_A.png,[],['age related macular degeneration']
520
+ 518,fives_retina/train/Original/432_G.png,[],['glaucoma']
521
+ 519,fives_retina/train/Original/562_N.png,[],['normal']
522
+ 520,fives_retina/train/Original/12_A.png,[],['age related macular degeneration']
523
+ 521,fives_retina/train/Original/105_A.png,[],['age related macular degeneration']
524
+ 522,fives_retina/train/Original/309_G.png,[],['glaucoma']
525
+ 523,fives_retina/train/Original/348_G.png,[],['glaucoma']
526
+ 524,fives_retina/train/Original/128_A.png,[],['age related macular degeneration']
527
+ 525,fives_retina/train/Original/11_A.png,[],['age related macular degeneration']
528
+ 526,fives_retina/train/Original/158_D.png,[],['diabetic retinopathy']
529
+ 527,fives_retina/train/Original/544_N.png,[],['normal']
530
+ 528,fives_retina/train/Original/596_N.png,[],['normal']
531
+ 529,fives_retina/train/Original/167_D.png,[],['diabetic retinopathy']
532
+ 530,fives_retina/train/Original/406_G.png,[],['glaucoma']
533
+ 531,fives_retina/train/Original/525_N.png,[],['normal']
534
+ 532,fives_retina/train/Original/279_D.png,[],['diabetic retinopathy']
535
+ 533,fives_retina/train/Original/500_N.png,[],['normal']
536
+ 534,fives_retina/train/Original/491_N.png,[],['normal']
537
+ 535,fives_retina/train/Original/589_N.png,[],['normal']
538
+ 536,fives_retina/train/Original/349_G.png,[],['glaucoma']
539
+ 537,fives_retina/train/Original/307_G.png,[],['glaucoma']
540
+ 538,fives_retina/train/Original/210_D.png,[],['diabetic retinopathy']
541
+ 539,fives_retina/train/Original/538_N.png,[],['normal']
542
+ 540,fives_retina/train/Original/104_A.png,[],['age related macular degeneration']
543
+ 541,fives_retina/train/Original/455_N.png,[],['normal']
544
+ 542,fives_retina/train/Original/31_A.png,[],['age related macular degeneration']
545
+ 543,fives_retina/train/Original/600_N.png,[],['normal']
546
+ 544,fives_retina/train/Original/46_A.png,[],['age related macular degeneration']
547
+ 545,fives_retina/train/Original/318_G.png,[],['glaucoma']
548
+ 546,fives_retina/train/Original/416_G.png,[],['glaucoma']
549
+ 547,fives_retina/train/Original/392_G.png,[],['glaucoma']
550
+ 548,fives_retina/train/Original/550_N.png,[],['normal']
551
+ 549,fives_retina/train/Original/595_N.png,[],['normal']
552
+ 550,fives_retina/train/Original/85_A.png,[],['age related macular degeneration']
553
+ 551,fives_retina/train/Original/317_G.png,[],['glaucoma']
554
+ 552,fives_retina/train/Original/335_G.png,[],['glaucoma']
555
+ 553,fives_retina/train/Original/560_N.png,[],['normal']
556
+ 554,fives_retina/train/Original/306_G.png,[],['glaucoma']
557
+ 555,fives_retina/train/Original/472_N.png,[],['normal']
558
+ 556,fives_retina/train/Original/343_G.png,[],['glaucoma']
559
+ 557,fives_retina/train/Original/247_D.png,[],['diabetic retinopathy']
560
+ 558,fives_retina/train/Original/321_G.png,[],['glaucoma']
561
+ 559,fives_retina/train/Original/591_N.png,[],['normal']
562
+ 560,fives_retina/train/Original/44_A.png,[],['age related macular degeneration']
563
+ 561,fives_retina/train/Original/253_D.png,[],['diabetic retinopathy']
564
+ 562,fives_retina/train/Original/474_N.png,[],['normal']
565
+ 563,fives_retina/train/Original/223_D.png,[],['diabetic retinopathy']
566
+ 564,fives_retina/train/Original/157_D.png,[],['diabetic retinopathy']
567
+ 565,fives_retina/train/Original/52_A.png,[],['age related macular degeneration']
568
+ 566,fives_retina/train/Original/103_A.png,[],['age related macular degeneration']
569
+ 567,fives_retina/train/Original/159_D.png,[],['diabetic retinopathy']
570
+ 568,fives_retina/train/Original/344_G.png,[],['glaucoma']
571
+ 569,fives_retina/train/Original/209_D.png,[],['diabetic retinopathy']
572
+ 570,fives_retina/train/Original/185_D.png,[],['diabetic retinopathy']
573
+ 571,fives_retina/train/Original/446_G.png,[],['glaucoma']
574
+ 572,fives_retina/train/Original/325_G.png,[],['glaucoma']
575
+ 573,fives_retina/train/Original/411_G.png,[],['glaucoma']
576
+ 574,fives_retina/train/Original/382_G.png,[],['glaucoma']
577
+ 575,fives_retina/train/Original/581_N.png,[],['normal']
578
+ 576,fives_retina/train/Original/228_D.png,[],['diabetic retinopathy']
579
+ 577,fives_retina/train/Original/363_G.png,[],['glaucoma']
580
+ 578,fives_retina/train/Original/258_D.png,[],['diabetic retinopathy']
581
+ 579,fives_retina/train/Original/293_D.png,[],['diabetic retinopathy']
582
+ 580,fives_retina/train/Original/443_G.png,[],['glaucoma']
583
+ 581,fives_retina/train/Original/234_D.png,[],['diabetic retinopathy']
584
+ 582,fives_retina/train/Original/403_G.png,[],['glaucoma']
585
+ 583,fives_retina/train/Original/164_D.png,[],['diabetic retinopathy']
586
+ 584,fives_retina/train/Original/316_G.png,[],['glaucoma']
587
+ 585,fives_retina/train/Original/498_N.png,[],['normal']
588
+ 586,fives_retina/train/Original/199_D.png,[],['diabetic retinopathy']
589
+ 587,fives_retina/train/Original/118_A.png,[],['age related macular degeneration']
590
+ 588,fives_retina/train/Original/417_G.png,[],['glaucoma']
591
+ 589,fives_retina/train/Original/60_A.png,[],['age related macular degeneration']
592
+ 590,fives_retina/train/Original/373_G.png,[],['glaucoma']
593
+ 591,fives_retina/train/Original/244_D.png,[],['diabetic retinopathy']
594
+ 592,fives_retina/train/Original/519_N.png,[],['normal']
595
+ 593,fives_retina/train/Original/355_G.png,[],['glaucoma']
596
+ 594,fives_retina/train/Original/67_A.png,[],['age related macular degeneration']
597
+ 595,fives_retina/train/Original/499_N.png,[],['normal']
598
+ 596,fives_retina/train/Original/232_D.png,[],['diabetic retinopathy']
599
+ 597,fives_retina/train/Original/296_D.png,[],['diabetic retinopathy']
600
+ 598,fives_retina/train/Original/535_N.png,[],['normal']
601
+ 599,fives_retina/train/Original/300_D.png,[],['diabetic retinopathy']
602
+ 600,fives_retina/test/Original/117_G.png,[],['glaucoma']
603
+ 601,fives_retina/test/Original/3_A.png,[],['age related macular degeneration']
604
+ 602,fives_retina/test/Original/138_G.png,[],['glaucoma']
605
+ 603,fives_retina/test/Original/58_D.png,[],['diabetic retinopathy']
606
+ 604,fives_retina/test/Original/112_G.png,[],['glaucoma']
607
+ 605,fives_retina/test/Original/114_G.png,[],['glaucoma']
608
+ 606,fives_retina/test/Original/188_N.png,[],['normal']
609
+ 607,fives_retina/test/Original/24_A.png,[],['age related macular degeneration']
610
+ 608,fives_retina/test/Original/79_D.png,[],['diabetic retinopathy']
611
+ 609,fives_retina/test/Original/69_D.png,[],['diabetic retinopathy']
612
+ 610,fives_retina/test/Original/9_A.png,[],['age related macular degeneration']
613
+ 611,fives_retina/test/Original/103_G.png,[],['glaucoma']
614
+ 612,fives_retina/test/Original/8_A.png,[],['age related macular degeneration']
615
+ 613,fives_retina/test/Original/48_A.png,[],['age related macular degeneration']
616
+ 614,fives_retina/test/Original/155_N.png,[],['normal']
617
+ 615,fives_retina/test/Original/78_D.png,[],['diabetic retinopathy']
618
+ 616,fives_retina/test/Original/127_G.png,[],['glaucoma']
619
+ 617,fives_retina/test/Original/165_N.png,[],['normal']
620
+ 618,fives_retina/test/Original/194_N.png,[],['normal']
621
+ 619,fives_retina/test/Original/190_N.png,[],['normal']
622
+ 620,fives_retina/test/Original/168_N.png,[],['normal']
623
+ 621,fives_retina/test/Original/183_N.png,[],['normal']
624
+ 622,fives_retina/test/Original/18_A.png,[],['age related macular degeneration']
625
+ 623,fives_retina/test/Original/158_N.png,[],['normal']
626
+ 624,fives_retina/test/Original/55_D.png,[],['diabetic retinopathy']
627
+ 625,fives_retina/test/Original/179_N.png,[],['normal']
628
+ 626,fives_retina/test/Original/129_G.png,[],['glaucoma']
629
+ 627,fives_retina/test/Original/37_A.png,[],['age related macular degeneration']
630
+ 628,fives_retina/test/Original/35_A.png,[],['age related macular degeneration']
631
+ 629,fives_retina/test/Original/161_N.png,[],['normal']
632
+ 630,fives_retina/test/Original/99_D.png,[],['diabetic retinopathy']
633
+ 631,fives_retina/test/Original/36_A.png,[],['age related macular degeneration']
634
+ 632,fives_retina/test/Original/71_D.png,[],['diabetic retinopathy']
635
+ 633,fives_retina/test/Original/139_G.png,[],['glaucoma']
636
+ 634,fives_retina/test/Original/149_G.png,[],['glaucoma']
637
+ 635,fives_retina/test/Original/40_A.png,[],['age related macular degeneration']
638
+ 636,fives_retina/test/Original/118_G.png,[],['glaucoma']
639
+ 637,fives_retina/test/Original/23_A.png,[],['age related macular degeneration']
640
+ 638,fives_retina/test/Original/4_A.png,[],['age related macular degeneration']
641
+ 639,fives_retina/test/Original/7_A.png,[],['age related macular degeneration']
642
+ 640,fives_retina/test/Original/65_D.png,[],['diabetic retinopathy']
643
+ 641,fives_retina/test/Original/141_G.png,[],['glaucoma']
644
+ 642,fives_retina/test/Original/172_N.png,[],['normal']
645
+ 643,fives_retina/test/Original/70_D.png,[],['diabetic retinopathy']
646
+ 644,fives_retina/test/Original/196_N.png,[],['normal']
647
+ 645,fives_retina/test/Original/128_G.png,[],['glaucoma']
648
+ 646,fives_retina/test/Original/101_G.png,[],['glaucoma']
649
+ 647,fives_retina/test/Original/30_A.png,[],['age related macular degeneration']
650
+ 648,fives_retina/test/Original/63_D.png,[],['diabetic retinopathy']
651
+ 649,fives_retina/test/Original/100_D.png,[],['diabetic retinopathy']
652
+ 650,fives_retina/test/Original/169_N.png,[],['normal']
653
+ 651,fives_retina/test/Original/150_G.png,[],['glaucoma']
654
+ 652,fives_retina/test/Original/52_D.png,[],['diabetic retinopathy']
655
+ 653,fives_retina/test/Original/154_N.png,[],['normal']
656
+ 654,fives_retina/test/Original/38_A.png,[],['age related macular degeneration']
657
+ 655,fives_retina/test/Original/171_N.png,[],['normal']
658
+ 656,fives_retina/test/Original/200_N.png,[],['normal']
659
+ 657,fives_retina/test/Original/135_G.png,[],['glaucoma']
660
+ 658,fives_retina/test/Original/160_N.png,[],['normal']
661
+ 659,fives_retina/test/Original/5_A.png,[],['age related macular degeneration']
662
+ 660,fives_retina/test/Original/140_G.png,[],['glaucoma']
663
+ 661,fives_retina/test/Original/43_A.png,[],['age related macular degeneration']
664
+ 662,fives_retina/test/Original/120_G.png,[],['glaucoma']
665
+ 663,fives_retina/test/Original/110_G.png,[],['glaucoma']
666
+ 664,fives_retina/test/Original/178_N.png,[],['normal']
667
+ 665,fives_retina/test/Original/93_D.png,[],['diabetic retinopathy']
668
+ 666,fives_retina/test/Original/198_N.png,[],['normal']
669
+ 667,fives_retina/test/Original/56_D.png,[],['diabetic retinopathy']
670
+ 668,fives_retina/test/Original/98_D.png,[],['diabetic retinopathy']
671
+ 669,fives_retina/test/Original/95_D.png,[],['diabetic retinopathy']
672
+ 670,fives_retina/test/Original/159_N.png,[],['normal']
673
+ 671,fives_retina/test/Original/175_N.png,[],['normal']
674
+ 672,fives_retina/test/Original/47_A.png,[],['age related macular degeneration']
675
+ 673,fives_retina/test/Original/180_N.png,[],['normal']
676
+ 674,fives_retina/test/Original/22_A.png,[],['age related macular degeneration']
677
+ 675,fives_retina/test/Original/106_G.png,[],['glaucoma']
678
+ 676,fives_retina/test/Original/84_D.png,[],['diabetic retinopathy']
679
+ 677,fives_retina/test/Original/1_A.png,[],['age related macular degeneration']
680
+ 678,fives_retina/test/Original/50_A.png,[],['age related macular degeneration']
681
+ 679,fives_retina/test/Original/54_D.png,[],['diabetic retinopathy']
682
+ 680,fives_retina/test/Original/60_D.png,[],['diabetic retinopathy']
683
+ 681,fives_retina/test/Original/132_G.png,[],['glaucoma']
684
+ 682,fives_retina/test/Original/67_D.png,[],['diabetic retinopathy']
685
+ 683,fives_retina/test/Original/195_N.png,[],['normal']
686
+ 684,fives_retina/test/Original/64_D.png,[],['diabetic retinopathy']
687
+ 685,fives_retina/test/Original/182_N.png,[],['normal']
688
+ 686,fives_retina/test/Original/41_A.png,[],['age related macular degeneration']
689
+ 687,fives_retina/test/Original/156_N.png,[],['normal']
690
+ 688,fives_retina/test/Original/72_D.png,[],['diabetic retinopathy']
691
+ 689,fives_retina/test/Original/14_A.png,[],['age related macular degeneration']
692
+ 690,fives_retina/test/Original/13_A.png,[],['age related macular degeneration']
693
+ 691,fives_retina/test/Original/148_G.png,[],['glaucoma']
694
+ 692,fives_retina/test/Original/62_D.png,[],['diabetic retinopathy']
695
+ 693,fives_retina/test/Original/57_D.png,[],['diabetic retinopathy']
696
+ 694,fives_retina/test/Original/136_G.png,[],['glaucoma']
697
+ 695,fives_retina/test/Original/143_G.png,[],['glaucoma']
698
+ 696,fives_retina/test/Original/96_D.png,[],['diabetic retinopathy']
699
+ 697,fives_retina/test/Original/170_N.png,[],['normal']
700
+ 698,fives_retina/test/Original/68_D.png,[],['diabetic retinopathy']
701
+ 699,fives_retina/test/Original/122_G.png,[],['glaucoma']
702
+ 700,fives_retina/test/Original/77_D.png,[],['diabetic retinopathy']
703
+ 701,fives_retina/test/Original/19_A.png,[],['age related macular degeneration']
704
+ 702,fives_retina/test/Original/108_G.png,[],['glaucoma']
705
+ 703,fives_retina/test/Original/193_N.png,[],['normal']
706
+ 704,fives_retina/test/Original/176_N.png,[],['normal']
707
+ 705,fives_retina/test/Original/199_N.png,[],['normal']
708
+ 706,fives_retina/test/Original/174_N.png,[],['normal']
709
+ 707,fives_retina/test/Original/45_A.png,[],['age related macular degeneration']
710
+ 708,fives_retina/test/Original/81_D.png,[],['diabetic retinopathy']
711
+ 709,fives_retina/test/Original/124_G.png,[],['glaucoma']
712
+ 710,fives_retina/test/Original/185_N.png,[],['normal']
713
+ 711,fives_retina/test/Original/94_D.png,[],['diabetic retinopathy']
714
+ 712,fives_retina/test/Original/86_D.png,[],['diabetic retinopathy']
715
+ 713,fives_retina/test/Original/89_D.png,[],['diabetic retinopathy']
716
+ 714,fives_retina/test/Original/163_N.png,[],['normal']
717
+ 715,fives_retina/test/Original/173_N.png,[],['normal']
718
+ 716,fives_retina/test/Original/162_N.png,[],['normal']
719
+ 717,fives_retina/test/Original/29_A.png,[],['age related macular degeneration']
720
+ 718,fives_retina/test/Original/115_G.png,[],['glaucoma']
721
+ 719,fives_retina/test/Original/189_N.png,[],['normal']
722
+ 720,fives_retina/test/Original/119_G.png,[],['glaucoma']
723
+ 721,fives_retina/test/Original/82_D.png,[],['diabetic retinopathy']
724
+ 722,fives_retina/test/Original/83_D.png,[],['diabetic retinopathy']
725
+ 723,fives_retina/test/Original/131_G.png,[],['glaucoma']
726
+ 724,fives_retina/test/Original/144_G.png,[],['glaucoma']
727
+ 725,fives_retina/test/Original/2_A.png,[],['age related macular degeneration']
728
+ 726,fives_retina/test/Original/85_D.png,[],['diabetic retinopathy']
729
+ 727,fives_retina/test/Original/152_N.png,[],['normal']
730
+ 728,fives_retina/test/Original/90_D.png,[],['diabetic retinopathy']
731
+ 729,fives_retina/test/Original/27_A.png,[],['age related macular degeneration']
732
+ 730,fives_retina/test/Original/87_D.png,[],['diabetic retinopathy']
733
+ 731,fives_retina/test/Original/97_D.png,[],['diabetic retinopathy']
734
+ 732,fives_retina/test/Original/26_A.png,[],['age related macular degeneration']
735
+ 733,fives_retina/test/Original/186_N.png,[],['normal']
736
+ 734,fives_retina/test/Original/177_N.png,[],['normal']
737
+ 735,fives_retina/test/Original/142_G.png,[],['glaucoma']
738
+ 736,fives_retina/test/Original/109_G.png,[],['glaucoma']
739
+ 737,fives_retina/test/Original/76_D.png,[],['diabetic retinopathy']
740
+ 738,fives_retina/test/Original/10_A.png,[],['age related macular degeneration']
741
+ 739,fives_retina/test/Original/6_A.png,[],['age related macular degeneration']
742
+ 740,fives_retina/test/Original/116_G.png,[],['glaucoma']
743
+ 741,fives_retina/test/Original/126_G.png,[],['glaucoma']
744
+ 742,fives_retina/test/Original/34_A.png,[],['age related macular degeneration']
745
+ 743,fives_retina/test/Original/49_A.png,[],['age related macular degeneration']
746
+ 744,fives_retina/test/Original/21_A.png,[],['age related macular degeneration']
747
+ 745,fives_retina/test/Original/102_G.png,[],['glaucoma']
748
+ 746,fives_retina/test/Original/151_N.png,[],['normal']
749
+ 747,fives_retina/test/Original/16_A.png,[],['age related macular degeneration']
750
+ 748,fives_retina/test/Original/32_A.png,[],['age related macular degeneration']
751
+ 749,fives_retina/test/Original/51_D.png,[],['diabetic retinopathy']
752
+ 750,fives_retina/test/Original/197_N.png,[],['normal']
753
+ 751,fives_retina/test/Original/66_D.png,[],['diabetic retinopathy']
754
+ 752,fives_retina/test/Original/184_N.png,[],['normal']
755
+ 753,fives_retina/test/Original/25_A.png,[],['age related macular degeneration']
756
+ 754,fives_retina/test/Original/157_N.png,[],['normal']
757
+ 755,fives_retina/test/Original/164_N.png,[],['normal']
758
+ 756,fives_retina/test/Original/130_G.png,[],['glaucoma']
759
+ 757,fives_retina/test/Original/17_A.png,[],['age related macular degeneration']
760
+ 758,fives_retina/test/Original/123_G.png,[],['glaucoma']
761
+ 759,fives_retina/test/Original/147_G.png,[],['glaucoma']
762
+ 760,fives_retina/test/Original/20_A.png,[],['age related macular degeneration']
763
+ 761,fives_retina/test/Original/111_G.png,[],['glaucoma']
764
+ 762,fives_retina/test/Original/53_D.png,[],['diabetic retinopathy']
765
+ 763,fives_retina/test/Original/191_N.png,[],['normal']
766
+ 764,fives_retina/test/Original/104_G.png,[],['glaucoma']
767
+ 765,fives_retina/test/Original/146_G.png,[],['glaucoma']
768
+ 766,fives_retina/test/Original/42_A.png,[],['age related macular degeneration']
769
+ 767,fives_retina/test/Original/28_A.png,[],['age related macular degeneration']
770
+ 768,fives_retina/test/Original/33_A.png,[],['age related macular degeneration']
771
+ 769,fives_retina/test/Original/133_G.png,[],['glaucoma']
772
+ 770,fives_retina/test/Original/153_N.png,[],['normal']
773
+ 771,fives_retina/test/Original/39_A.png,[],['age related macular degeneration']
774
+ 772,fives_retina/test/Original/74_D.png,[],['diabetic retinopathy']
775
+ 773,fives_retina/test/Original/137_G.png,[],['glaucoma']
776
+ 774,fives_retina/test/Original/73_D.png,[],['diabetic retinopathy']
777
+ 775,fives_retina/test/Original/166_N.png,[],['normal']
778
+ 776,fives_retina/test/Original/134_G.png,[],['glaucoma']
779
+ 777,fives_retina/test/Original/167_N.png,[],['normal']
780
+ 778,fives_retina/test/Original/15_A.png,[],['age related macular degeneration']
781
+ 779,fives_retina/test/Original/91_D.png,[],['diabetic retinopathy']
782
+ 780,fives_retina/test/Original/12_A.png,[],['age related macular degeneration']
783
+ 781,fives_retina/test/Original/145_G.png,[],['glaucoma']
784
+ 782,fives_retina/test/Original/75_D.png,[],['diabetic retinopathy']
785
+ 783,fives_retina/test/Original/11_A.png,[],['age related macular degeneration']
786
+ 784,fives_retina/test/Original/107_G.png,[],['glaucoma']
787
+ 785,fives_retina/test/Original/80_D.png,[],['diabetic retinopathy']
788
+ 786,fives_retina/test/Original/192_N.png,[],['normal']
789
+ 787,fives_retina/test/Original/187_N.png,[],['normal']
790
+ 788,fives_retina/test/Original/31_A.png,[],['age related macular degeneration']
791
+ 789,fives_retina/test/Original/59_D.png,[],['diabetic retinopathy']
792
+ 790,fives_retina/test/Original/46_A.png,[],['age related macular degeneration']
793
+ 791,fives_retina/test/Original/125_G.png,[],['glaucoma']
794
+ 792,fives_retina/test/Original/181_N.png,[],['normal']
795
+ 793,fives_retina/test/Original/105_G.png,[],['glaucoma']
796
+ 794,fives_retina/test/Original/44_A.png,[],['age related macular degeneration']
797
+ 795,fives_retina/test/Original/61_D.png,[],['diabetic retinopathy']
798
+ 796,fives_retina/test/Original/88_D.png,[],['diabetic retinopathy']
799
+ 797,fives_retina/test/Original/121_G.png,[],['glaucoma']
800
+ 798,fives_retina/test/Original/113_G.png,[],['glaucoma']
801
+ 799,fives_retina/test/Original/92_D.png,[],['diabetic retinopathy']
local_data/25_REFUGE.csv ADDED
@@ -0,0 +1,401 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,image,atributes,categories
2
+ 0,REFUGE-Training400/g0001.jpg,[],['glaucoma']
3
+ 1,REFUGE-Training400/g0002.jpg,[],['glaucoma']
4
+ 2,REFUGE-Training400/g0003.jpg,[],['glaucoma']
5
+ 3,REFUGE-Training400/g0004.jpg,[],['glaucoma']
6
+ 4,REFUGE-Training400/g0005.jpg,[],['glaucoma']
7
+ 5,REFUGE-Training400/g0006.jpg,[],['glaucoma']
8
+ 6,REFUGE-Training400/g0007.jpg,[],['glaucoma']
9
+ 7,REFUGE-Training400/g0008.jpg,[],['glaucoma']
10
+ 8,REFUGE-Training400/g0009.jpg,[],['glaucoma']
11
+ 9,REFUGE-Training400/g0010.jpg,[],['glaucoma']
12
+ 10,REFUGE-Training400/g0011.jpg,[],['glaucoma']
13
+ 11,REFUGE-Training400/g0012.jpg,[],['glaucoma']
14
+ 12,REFUGE-Training400/g0013.jpg,[],['glaucoma']
15
+ 13,REFUGE-Training400/g0014.jpg,[],['glaucoma']
16
+ 14,REFUGE-Training400/g0015.jpg,[],['glaucoma']
17
+ 15,REFUGE-Training400/g0016.jpg,[],['glaucoma']
18
+ 16,REFUGE-Training400/g0017.jpg,[],['glaucoma']
19
+ 17,REFUGE-Training400/g0018.jpg,[],['glaucoma']
20
+ 18,REFUGE-Training400/g0019.jpg,[],['glaucoma']
21
+ 19,REFUGE-Training400/g0020.jpg,[],['glaucoma']
22
+ 20,REFUGE-Training400/g0021.jpg,[],['glaucoma']
23
+ 21,REFUGE-Training400/g0022.jpg,[],['glaucoma']
24
+ 22,REFUGE-Training400/g0023.jpg,[],['glaucoma']
25
+ 23,REFUGE-Training400/g0024.jpg,[],['glaucoma']
26
+ 24,REFUGE-Training400/g0025.jpg,[],['glaucoma']
27
+ 25,REFUGE-Training400/g0026.jpg,[],['glaucoma']
28
+ 26,REFUGE-Training400/g0027.jpg,[],['glaucoma']
29
+ 27,REFUGE-Training400/g0028.jpg,[],['glaucoma']
30
+ 28,REFUGE-Training400/g0029.jpg,[],['glaucoma']
31
+ 29,REFUGE-Training400/g0030.jpg,[],['glaucoma']
32
+ 30,REFUGE-Training400/g0031.jpg,[],['glaucoma']
33
+ 31,REFUGE-Training400/g0032.jpg,[],['glaucoma']
34
+ 32,REFUGE-Training400/g0033.jpg,[],['glaucoma']
35
+ 33,REFUGE-Training400/g0034.jpg,[],['glaucoma']
36
+ 34,REFUGE-Training400/g0035.jpg,[],['glaucoma']
37
+ 35,REFUGE-Training400/g0036.jpg,[],['glaucoma']
38
+ 36,REFUGE-Training400/g0037.jpg,[],['glaucoma']
39
+ 37,REFUGE-Training400/g0038.jpg,[],['glaucoma']
40
+ 38,REFUGE-Training400/g0039.jpg,[],['glaucoma']
41
+ 39,REFUGE-Training400/g0040.jpg,[],['glaucoma']
42
+ 40,REFUGE-Training400/n0001.jpg,[],['no glaucoma']
43
+ 41,REFUGE-Training400/n0002.jpg,[],['no glaucoma']
44
+ 42,REFUGE-Training400/n0003.jpg,[],['no glaucoma']
45
+ 43,REFUGE-Training400/n0004.jpg,[],['no glaucoma']
46
+ 44,REFUGE-Training400/n0005.jpg,[],['no glaucoma']
47
+ 45,REFUGE-Training400/n0006.jpg,[],['no glaucoma']
48
+ 46,REFUGE-Training400/n0007.jpg,[],['no glaucoma']
49
+ 47,REFUGE-Training400/n0008.jpg,[],['no glaucoma']
50
+ 48,REFUGE-Training400/n0009.jpg,[],['no glaucoma']
51
+ 49,REFUGE-Training400/n0010.jpg,[],['no glaucoma']
52
+ 50,REFUGE-Training400/n0011.jpg,[],['no glaucoma']
53
+ 51,REFUGE-Training400/n0012.jpg,[],['no glaucoma']
54
+ 52,REFUGE-Training400/n0013.jpg,[],['no glaucoma']
55
+ 53,REFUGE-Training400/n0014.jpg,[],['no glaucoma']
56
+ 54,REFUGE-Training400/n0015.jpg,[],['no glaucoma']
57
+ 55,REFUGE-Training400/n0016.jpg,[],['no glaucoma']
58
+ 56,REFUGE-Training400/n0017.jpg,[],['no glaucoma']
59
+ 57,REFUGE-Training400/n0018.jpg,[],['no glaucoma']
60
+ 58,REFUGE-Training400/n0019.jpg,[],['no glaucoma']
61
+ 59,REFUGE-Training400/n0020.jpg,[],['no glaucoma']
62
+ 60,REFUGE-Training400/n0021.jpg,[],['no glaucoma']
63
+ 61,REFUGE-Training400/n0022.jpg,[],['no glaucoma']
64
+ 62,REFUGE-Training400/n0023.jpg,[],['no glaucoma']
65
+ 63,REFUGE-Training400/n0024.jpg,[],['no glaucoma']
66
+ 64,REFUGE-Training400/n0025.jpg,[],['no glaucoma']
67
+ 65,REFUGE-Training400/n0026.jpg,[],['no glaucoma']
68
+ 66,REFUGE-Training400/n0027.jpg,[],['no glaucoma']
69
+ 67,REFUGE-Training400/n0028.jpg,[],['no glaucoma']
70
+ 68,REFUGE-Training400/n0029.jpg,[],['no glaucoma']
71
+ 69,REFUGE-Training400/n0030.jpg,[],['no glaucoma']
72
+ 70,REFUGE-Training400/n0031.jpg,[],['no glaucoma']
73
+ 71,REFUGE-Training400/n0032.jpg,[],['no glaucoma']
74
+ 72,REFUGE-Training400/n0033.jpg,[],['no glaucoma']
75
+ 73,REFUGE-Training400/n0034.jpg,[],['no glaucoma']
76
+ 74,REFUGE-Training400/n0035.jpg,[],['no glaucoma']
77
+ 75,REFUGE-Training400/n0036.jpg,[],['no glaucoma']
78
+ 76,REFUGE-Training400/n0037.jpg,[],['no glaucoma']
79
+ 77,REFUGE-Training400/n0038.jpg,[],['no glaucoma']
80
+ 78,REFUGE-Training400/n0039.jpg,[],['no glaucoma']
81
+ 79,REFUGE-Training400/n0040.jpg,[],['no glaucoma']
82
+ 80,REFUGE-Training400/n0041.jpg,[],['no glaucoma']
83
+ 81,REFUGE-Training400/n0042.jpg,[],['no glaucoma']
84
+ 82,REFUGE-Training400/n0043.jpg,[],['no glaucoma']
85
+ 83,REFUGE-Training400/n0044.jpg,[],['no glaucoma']
86
+ 84,REFUGE-Training400/n0045.jpg,[],['no glaucoma']
87
+ 85,REFUGE-Training400/n0046.jpg,[],['no glaucoma']
88
+ 86,REFUGE-Training400/n0047.jpg,[],['no glaucoma']
89
+ 87,REFUGE-Training400/n0048.jpg,[],['no glaucoma']
90
+ 88,REFUGE-Training400/n0049.jpg,[],['no glaucoma']
91
+ 89,REFUGE-Training400/n0050.jpg,[],['no glaucoma']
92
+ 90,REFUGE-Training400/n0051.jpg,[],['no glaucoma']
93
+ 91,REFUGE-Training400/n0052.jpg,[],['no glaucoma']
94
+ 92,REFUGE-Training400/n0053.jpg,[],['no glaucoma']
95
+ 93,REFUGE-Training400/n0054.jpg,[],['no glaucoma']
96
+ 94,REFUGE-Training400/n0055.jpg,[],['no glaucoma']
97
+ 95,REFUGE-Training400/n0056.jpg,[],['no glaucoma']
98
+ 96,REFUGE-Training400/n0057.jpg,[],['no glaucoma']
99
+ 97,REFUGE-Training400/n0058.jpg,[],['no glaucoma']
100
+ 98,REFUGE-Training400/n0059.jpg,[],['no glaucoma']
101
+ 99,REFUGE-Training400/n0060.jpg,[],['no glaucoma']
102
+ 100,REFUGE-Training400/n0061.jpg,[],['no glaucoma']
103
+ 101,REFUGE-Training400/n0062.jpg,[],['no glaucoma']
104
+ 102,REFUGE-Training400/n0063.jpg,[],['no glaucoma']
105
+ 103,REFUGE-Training400/n0064.jpg,[],['no glaucoma']
106
+ 104,REFUGE-Training400/n0065.jpg,[],['no glaucoma']
107
+ 105,REFUGE-Training400/n0066.jpg,[],['no glaucoma']
108
+ 106,REFUGE-Training400/n0067.jpg,[],['no glaucoma']
109
+ 107,REFUGE-Training400/n0068.jpg,[],['no glaucoma']
110
+ 108,REFUGE-Training400/n0069.jpg,[],['no glaucoma']
111
+ 109,REFUGE-Training400/n0070.jpg,[],['no glaucoma']
112
+ 110,REFUGE-Training400/n0071.jpg,[],['no glaucoma']
113
+ 111,REFUGE-Training400/n0072.jpg,[],['no glaucoma']
114
+ 112,REFUGE-Training400/n0073.jpg,[],['no glaucoma']
115
+ 113,REFUGE-Training400/n0074.jpg,[],['no glaucoma']
116
+ 114,REFUGE-Training400/n0075.jpg,[],['no glaucoma']
117
+ 115,REFUGE-Training400/n0076.jpg,[],['no glaucoma']
118
+ 116,REFUGE-Training400/n0077.jpg,[],['no glaucoma']
119
+ 117,REFUGE-Training400/n0078.jpg,[],['no glaucoma']
120
+ 118,REFUGE-Training400/n0079.jpg,[],['no glaucoma']
121
+ 119,REFUGE-Training400/n0080.jpg,[],['no glaucoma']
122
+ 120,REFUGE-Training400/n0081.jpg,[],['no glaucoma']
123
+ 121,REFUGE-Training400/n0082.jpg,[],['no glaucoma']
124
+ 122,REFUGE-Training400/n0083.jpg,[],['no glaucoma']
125
+ 123,REFUGE-Training400/n0084.jpg,[],['no glaucoma']
126
+ 124,REFUGE-Training400/n0085.jpg,[],['no glaucoma']
127
+ 125,REFUGE-Training400/n0086.jpg,[],['no glaucoma']
128
+ 126,REFUGE-Training400/n0087.jpg,[],['no glaucoma']
129
+ 127,REFUGE-Training400/n0088.jpg,[],['no glaucoma']
130
+ 128,REFUGE-Training400/n0089.jpg,[],['no glaucoma']
131
+ 129,REFUGE-Training400/n0090.jpg,[],['no glaucoma']
132
+ 130,REFUGE-Training400/n0091.jpg,[],['no glaucoma']
133
+ 131,REFUGE-Training400/n0092.jpg,[],['no glaucoma']
134
+ 132,REFUGE-Training400/n0093.jpg,[],['no glaucoma']
135
+ 133,REFUGE-Training400/n0094.jpg,[],['no glaucoma']
136
+ 134,REFUGE-Training400/n0095.jpg,[],['no glaucoma']
137
+ 135,REFUGE-Training400/n0096.jpg,[],['no glaucoma']
138
+ 136,REFUGE-Training400/n0097.jpg,[],['no glaucoma']
139
+ 137,REFUGE-Training400/n0098.jpg,[],['no glaucoma']
140
+ 138,REFUGE-Training400/n0099.jpg,[],['no glaucoma']
141
+ 139,REFUGE-Training400/n0100.jpg,[],['no glaucoma']
142
+ 140,REFUGE-Training400/n0101.jpg,[],['no glaucoma']
143
+ 141,REFUGE-Training400/n0102.jpg,[],['no glaucoma']
144
+ 142,REFUGE-Training400/n0103.jpg,[],['no glaucoma']
145
+ 143,REFUGE-Training400/n0104.jpg,[],['no glaucoma']
146
+ 144,REFUGE-Training400/n0105.jpg,[],['no glaucoma']
147
+ 145,REFUGE-Training400/n0106.jpg,[],['no glaucoma']
148
+ 146,REFUGE-Training400/n0107.jpg,[],['no glaucoma']
149
+ 147,REFUGE-Training400/n0108.jpg,[],['no glaucoma']
150
+ 148,REFUGE-Training400/n0109.jpg,[],['no glaucoma']
151
+ 149,REFUGE-Training400/n0110.jpg,[],['no glaucoma']
152
+ 150,REFUGE-Training400/n0111.jpg,[],['no glaucoma']
153
+ 151,REFUGE-Training400/n0112.jpg,[],['no glaucoma']
154
+ 152,REFUGE-Training400/n0113.jpg,[],['no glaucoma']
155
+ 153,REFUGE-Training400/n0114.jpg,[],['no glaucoma']
156
+ 154,REFUGE-Training400/n0115.jpg,[],['no glaucoma']
157
+ 155,REFUGE-Training400/n0116.jpg,[],['no glaucoma']
158
+ 156,REFUGE-Training400/n0117.jpg,[],['no glaucoma']
159
+ 157,REFUGE-Training400/n0118.jpg,[],['no glaucoma']
160
+ 158,REFUGE-Training400/n0119.jpg,[],['no glaucoma']
161
+ 159,REFUGE-Training400/n0120.jpg,[],['no glaucoma']
162
+ 160,REFUGE-Training400/n0121.jpg,[],['no glaucoma']
163
+ 161,REFUGE-Training400/n0122.jpg,[],['no glaucoma']
164
+ 162,REFUGE-Training400/n0123.jpg,[],['no glaucoma']
165
+ 163,REFUGE-Training400/n0124.jpg,[],['no glaucoma']
166
+ 164,REFUGE-Training400/n0125.jpg,[],['no glaucoma']
167
+ 165,REFUGE-Training400/n0126.jpg,[],['no glaucoma']
168
+ 166,REFUGE-Training400/n0127.jpg,[],['no glaucoma']
169
+ 167,REFUGE-Training400/n0128.jpg,[],['no glaucoma']
170
+ 168,REFUGE-Training400/n0129.jpg,[],['no glaucoma']
171
+ 169,REFUGE-Training400/n0130.jpg,[],['no glaucoma']
172
+ 170,REFUGE-Training400/n0131.jpg,[],['no glaucoma']
173
+ 171,REFUGE-Training400/n0132.jpg,[],['no glaucoma']
174
+ 172,REFUGE-Training400/n0133.jpg,[],['no glaucoma']
175
+ 173,REFUGE-Training400/n0134.jpg,[],['no glaucoma']
176
+ 174,REFUGE-Training400/n0135.jpg,[],['no glaucoma']
177
+ 175,REFUGE-Training400/n0136.jpg,[],['no glaucoma']
178
+ 176,REFUGE-Training400/n0137.jpg,[],['no glaucoma']
179
+ 177,REFUGE-Training400/n0138.jpg,[],['no glaucoma']
180
+ 178,REFUGE-Training400/n0139.jpg,[],['no glaucoma']
181
+ 179,REFUGE-Training400/n0140.jpg,[],['no glaucoma']
182
+ 180,REFUGE-Training400/n0141.jpg,[],['no glaucoma']
183
+ 181,REFUGE-Training400/n0142.jpg,[],['no glaucoma']
184
+ 182,REFUGE-Training400/n0143.jpg,[],['no glaucoma']
185
+ 183,REFUGE-Training400/n0144.jpg,[],['no glaucoma']
186
+ 184,REFUGE-Training400/n0145.jpg,[],['no glaucoma']
187
+ 185,REFUGE-Training400/n0146.jpg,[],['no glaucoma']
188
+ 186,REFUGE-Training400/n0147.jpg,[],['no glaucoma']
189
+ 187,REFUGE-Training400/n0148.jpg,[],['no glaucoma']
190
+ 188,REFUGE-Training400/n0149.jpg,[],['no glaucoma']
191
+ 189,REFUGE-Training400/n0150.jpg,[],['no glaucoma']
192
+ 190,REFUGE-Training400/n0151.jpg,[],['no glaucoma']
193
+ 191,REFUGE-Training400/n0152.jpg,[],['no glaucoma']
194
+ 192,REFUGE-Training400/n0153.jpg,[],['no glaucoma']
195
+ 193,REFUGE-Training400/n0154.jpg,[],['no glaucoma']
196
+ 194,REFUGE-Training400/n0155.jpg,[],['no glaucoma']
197
+ 195,REFUGE-Training400/n0156.jpg,[],['no glaucoma']
198
+ 196,REFUGE-Training400/n0157.jpg,[],['no glaucoma']
199
+ 197,REFUGE-Training400/n0158.jpg,[],['no glaucoma']
200
+ 198,REFUGE-Training400/n0159.jpg,[],['no glaucoma']
201
+ 199,REFUGE-Training400/n0160.jpg,[],['no glaucoma']
202
+ 200,REFUGE-Training400/n0161.jpg,[],['no glaucoma']
203
+ 201,REFUGE-Training400/n0162.jpg,[],['no glaucoma']
204
+ 202,REFUGE-Training400/n0163.jpg,[],['no glaucoma']
205
+ 203,REFUGE-Training400/n0164.jpg,[],['no glaucoma']
206
+ 204,REFUGE-Training400/n0165.jpg,[],['no glaucoma']
207
+ 205,REFUGE-Training400/n0166.jpg,[],['no glaucoma']
208
+ 206,REFUGE-Training400/n0167.jpg,[],['no glaucoma']
209
+ 207,REFUGE-Training400/n0168.jpg,[],['no glaucoma']
210
+ 208,REFUGE-Training400/n0169.jpg,[],['no glaucoma']
211
+ 209,REFUGE-Training400/n0170.jpg,[],['no glaucoma']
212
+ 210,REFUGE-Training400/n0171.jpg,[],['no glaucoma']
213
+ 211,REFUGE-Training400/n0172.jpg,[],['no glaucoma']
214
+ 212,REFUGE-Training400/n0173.jpg,[],['no glaucoma']
215
+ 213,REFUGE-Training400/n0174.jpg,[],['no glaucoma']
216
+ 214,REFUGE-Training400/n0175.jpg,[],['no glaucoma']
217
+ 215,REFUGE-Training400/n0176.jpg,[],['no glaucoma']
218
+ 216,REFUGE-Training400/n0177.jpg,[],['no glaucoma']
219
+ 217,REFUGE-Training400/n0178.jpg,[],['no glaucoma']
220
+ 218,REFUGE-Training400/n0179.jpg,[],['no glaucoma']
221
+ 219,REFUGE-Training400/n0180.jpg,[],['no glaucoma']
222
+ 220,REFUGE-Training400/n0181.jpg,[],['no glaucoma']
223
+ 221,REFUGE-Training400/n0182.jpg,[],['no glaucoma']
224
+ 222,REFUGE-Training400/n0183.jpg,[],['no glaucoma']
225
+ 223,REFUGE-Training400/n0184.jpg,[],['no glaucoma']
226
+ 224,REFUGE-Training400/n0185.jpg,[],['no glaucoma']
227
+ 225,REFUGE-Training400/n0186.jpg,[],['no glaucoma']
228
+ 226,REFUGE-Training400/n0187.jpg,[],['no glaucoma']
229
+ 227,REFUGE-Training400/n0188.jpg,[],['no glaucoma']
230
+ 228,REFUGE-Training400/n0189.jpg,[],['no glaucoma']
231
+ 229,REFUGE-Training400/n0190.jpg,[],['no glaucoma']
232
+ 230,REFUGE-Training400/n0191.jpg,[],['no glaucoma']
233
+ 231,REFUGE-Training400/n0192.jpg,[],['no glaucoma']
234
+ 232,REFUGE-Training400/n0193.jpg,[],['no glaucoma']
235
+ 233,REFUGE-Training400/n0194.jpg,[],['no glaucoma']
236
+ 234,REFUGE-Training400/n0195.jpg,[],['no glaucoma']
237
+ 235,REFUGE-Training400/n0196.jpg,[],['no glaucoma']
238
+ 236,REFUGE-Training400/n0197.jpg,[],['no glaucoma']
239
+ 237,REFUGE-Training400/n0198.jpg,[],['no glaucoma']
240
+ 238,REFUGE-Training400/n0199.jpg,[],['no glaucoma']
241
+ 239,REFUGE-Training400/n0200.jpg,[],['no glaucoma']
242
+ 240,REFUGE-Training400/n0201.jpg,[],['no glaucoma']
243
+ 241,REFUGE-Training400/n0202.jpg,[],['no glaucoma']
244
+ 242,REFUGE-Training400/n0203.jpg,[],['no glaucoma']
245
+ 243,REFUGE-Training400/n0204.jpg,[],['no glaucoma']
246
+ 244,REFUGE-Training400/n0205.jpg,[],['no glaucoma']
247
+ 245,REFUGE-Training400/n0206.jpg,[],['no glaucoma']
248
+ 246,REFUGE-Training400/n0207.jpg,[],['no glaucoma']
249
+ 247,REFUGE-Training400/n0208.jpg,[],['no glaucoma']
250
+ 248,REFUGE-Training400/n0209.jpg,[],['no glaucoma']
251
+ 249,REFUGE-Training400/n0210.jpg,[],['no glaucoma']
252
+ 250,REFUGE-Training400/n0211.jpg,[],['no glaucoma']
253
+ 251,REFUGE-Training400/n0212.jpg,[],['no glaucoma']
254
+ 252,REFUGE-Training400/n0213.jpg,[],['no glaucoma']
255
+ 253,REFUGE-Training400/n0214.jpg,[],['no glaucoma']
256
+ 254,REFUGE-Training400/n0215.jpg,[],['no glaucoma']
257
+ 255,REFUGE-Training400/n0216.jpg,[],['no glaucoma']
258
+ 256,REFUGE-Training400/n0217.jpg,[],['no glaucoma']
259
+ 257,REFUGE-Training400/n0218.jpg,[],['no glaucoma']
260
+ 258,REFUGE-Training400/n0219.jpg,[],['no glaucoma']
261
+ 259,REFUGE-Training400/n0220.jpg,[],['no glaucoma']
262
+ 260,REFUGE-Training400/n0221.jpg,[],['no glaucoma']
263
+ 261,REFUGE-Training400/n0222.jpg,[],['no glaucoma']
264
+ 262,REFUGE-Training400/n0223.jpg,[],['no glaucoma']
265
+ 263,REFUGE-Training400/n0224.jpg,[],['no glaucoma']
266
+ 264,REFUGE-Training400/n0225.jpg,[],['no glaucoma']
267
+ 265,REFUGE-Training400/n0226.jpg,[],['no glaucoma']
268
+ 266,REFUGE-Training400/n0227.jpg,[],['no glaucoma']
269
+ 267,REFUGE-Training400/n0228.jpg,[],['no glaucoma']
270
+ 268,REFUGE-Training400/n0229.jpg,[],['no glaucoma']
271
+ 269,REFUGE-Training400/n0230.jpg,[],['no glaucoma']
272
+ 270,REFUGE-Training400/n0231.jpg,[],['no glaucoma']
273
+ 271,REFUGE-Training400/n0232.jpg,[],['no glaucoma']
274
+ 272,REFUGE-Training400/n0233.jpg,[],['no glaucoma']
275
+ 273,REFUGE-Training400/n0234.jpg,[],['no glaucoma']
276
+ 274,REFUGE-Training400/n0235.jpg,[],['no glaucoma']
277
+ 275,REFUGE-Training400/n0236.jpg,[],['no glaucoma']
278
+ 276,REFUGE-Training400/n0237.jpg,[],['no glaucoma']
279
+ 277,REFUGE-Training400/n0238.jpg,[],['no glaucoma']
280
+ 278,REFUGE-Training400/n0239.jpg,[],['no glaucoma']
281
+ 279,REFUGE-Training400/n0240.jpg,[],['no glaucoma']
282
+ 280,REFUGE-Training400/n0241.jpg,[],['no glaucoma']
283
+ 281,REFUGE-Training400/n0242.jpg,[],['no glaucoma']
284
+ 282,REFUGE-Training400/n0243.jpg,[],['no glaucoma']
285
+ 283,REFUGE-Training400/n0244.jpg,[],['no glaucoma']
286
+ 284,REFUGE-Training400/n0245.jpg,[],['no glaucoma']
287
+ 285,REFUGE-Training400/n0246.jpg,[],['no glaucoma']
288
+ 286,REFUGE-Training400/n0247.jpg,[],['no glaucoma']
289
+ 287,REFUGE-Training400/n0248.jpg,[],['no glaucoma']
290
+ 288,REFUGE-Training400/n0249.jpg,[],['no glaucoma']
291
+ 289,REFUGE-Training400/n0250.jpg,[],['no glaucoma']
292
+ 290,REFUGE-Training400/n0251.jpg,[],['no glaucoma']
293
+ 291,REFUGE-Training400/n0252.jpg,[],['no glaucoma']
294
+ 292,REFUGE-Training400/n0253.jpg,[],['no glaucoma']
295
+ 293,REFUGE-Training400/n0254.jpg,[],['no glaucoma']
296
+ 294,REFUGE-Training400/n0255.jpg,[],['no glaucoma']
297
+ 295,REFUGE-Training400/n0256.jpg,[],['no glaucoma']
298
+ 296,REFUGE-Training400/n0257.jpg,[],['no glaucoma']
299
+ 297,REFUGE-Training400/n0258.jpg,[],['no glaucoma']
300
+ 298,REFUGE-Training400/n0259.jpg,[],['no glaucoma']
301
+ 299,REFUGE-Training400/n0260.jpg,[],['no glaucoma']
302
+ 300,REFUGE-Training400/n0261.jpg,[],['no glaucoma']
303
+ 301,REFUGE-Training400/n0262.jpg,[],['no glaucoma']
304
+ 302,REFUGE-Training400/n0263.jpg,[],['no glaucoma']
305
+ 303,REFUGE-Training400/n0264.jpg,[],['no glaucoma']
306
+ 304,REFUGE-Training400/n0265.jpg,[],['no glaucoma']
307
+ 305,REFUGE-Training400/n0266.jpg,[],['no glaucoma']
308
+ 306,REFUGE-Training400/n0267.jpg,[],['no glaucoma']
309
+ 307,REFUGE-Training400/n0268.jpg,[],['no glaucoma']
310
+ 308,REFUGE-Training400/n0269.jpg,[],['no glaucoma']
311
+ 309,REFUGE-Training400/n0270.jpg,[],['no glaucoma']
312
+ 310,REFUGE-Training400/n0271.jpg,[],['no glaucoma']
313
+ 311,REFUGE-Training400/n0272.jpg,[],['no glaucoma']
314
+ 312,REFUGE-Training400/n0273.jpg,[],['no glaucoma']
315
+ 313,REFUGE-Training400/n0274.jpg,[],['no glaucoma']
316
+ 314,REFUGE-Training400/n0275.jpg,[],['no glaucoma']
317
+ 315,REFUGE-Training400/n0276.jpg,[],['no glaucoma']
318
+ 316,REFUGE-Training400/n0277.jpg,[],['no glaucoma']
319
+ 317,REFUGE-Training400/n0278.jpg,[],['no glaucoma']
320
+ 318,REFUGE-Training400/n0279.jpg,[],['no glaucoma']
321
+ 319,REFUGE-Training400/n0280.jpg,[],['no glaucoma']
322
+ 320,REFUGE-Training400/n0281.jpg,[],['no glaucoma']
323
+ 321,REFUGE-Training400/n0282.jpg,[],['no glaucoma']
324
+ 322,REFUGE-Training400/n0283.jpg,[],['no glaucoma']
325
+ 323,REFUGE-Training400/n0284.jpg,[],['no glaucoma']
326
+ 324,REFUGE-Training400/n0285.jpg,[],['no glaucoma']
327
+ 325,REFUGE-Training400/n0286.jpg,[],['no glaucoma']
328
+ 326,REFUGE-Training400/n0287.jpg,[],['no glaucoma']
329
+ 327,REFUGE-Training400/n0288.jpg,[],['no glaucoma']
330
+ 328,REFUGE-Training400/n0289.jpg,[],['no glaucoma']
331
+ 329,REFUGE-Training400/n0290.jpg,[],['no glaucoma']
332
+ 330,REFUGE-Training400/n0291.jpg,[],['no glaucoma']
333
+ 331,REFUGE-Training400/n0292.jpg,[],['no glaucoma']
334
+ 332,REFUGE-Training400/n0293.jpg,[],['no glaucoma']
335
+ 333,REFUGE-Training400/n0294.jpg,[],['no glaucoma']
336
+ 334,REFUGE-Training400/n0295.jpg,[],['no glaucoma']
337
+ 335,REFUGE-Training400/n0296.jpg,[],['no glaucoma']
338
+ 336,REFUGE-Training400/n0297.jpg,[],['no glaucoma']
339
+ 337,REFUGE-Training400/n0298.jpg,[],['no glaucoma']
340
+ 338,REFUGE-Training400/n0299.jpg,[],['no glaucoma']
341
+ 339,REFUGE-Training400/n0300.jpg,[],['no glaucoma']
342
+ 340,REFUGE-Training400/n0301.jpg,[],['no glaucoma']
343
+ 341,REFUGE-Training400/n0302.jpg,[],['no glaucoma']
344
+ 342,REFUGE-Training400/n0303.jpg,[],['no glaucoma']
345
+ 343,REFUGE-Training400/n0304.jpg,[],['no glaucoma']
346
+ 344,REFUGE-Training400/n0305.jpg,[],['no glaucoma']
347
+ 345,REFUGE-Training400/n0306.jpg,[],['no glaucoma']
348
+ 346,REFUGE-Training400/n0307.jpg,[],['no glaucoma']
349
+ 347,REFUGE-Training400/n0308.jpg,[],['no glaucoma']
350
+ 348,REFUGE-Training400/n0309.jpg,[],['no glaucoma']
351
+ 349,REFUGE-Training400/n0310.jpg,[],['no glaucoma']
352
+ 350,REFUGE-Training400/n0311.jpg,[],['no glaucoma']
353
+ 351,REFUGE-Training400/n0312.jpg,[],['no glaucoma']
354
+ 352,REFUGE-Training400/n0313.jpg,[],['no glaucoma']
355
+ 353,REFUGE-Training400/n0314.jpg,[],['no glaucoma']
356
+ 354,REFUGE-Training400/n0315.jpg,[],['no glaucoma']
357
+ 355,REFUGE-Training400/n0316.jpg,[],['no glaucoma']
358
+ 356,REFUGE-Training400/n0317.jpg,[],['no glaucoma']
359
+ 357,REFUGE-Training400/n0318.jpg,[],['no glaucoma']
360
+ 358,REFUGE-Training400/n0319.jpg,[],['no glaucoma']
361
+ 359,REFUGE-Training400/n0320.jpg,[],['no glaucoma']
362
+ 360,REFUGE-Training400/n0321.jpg,[],['no glaucoma']
363
+ 361,REFUGE-Training400/n0322.jpg,[],['no glaucoma']
364
+ 362,REFUGE-Training400/n0323.jpg,[],['no glaucoma']
365
+ 363,REFUGE-Training400/n0324.jpg,[],['no glaucoma']
366
+ 364,REFUGE-Training400/n0325.jpg,[],['no glaucoma']
367
+ 365,REFUGE-Training400/n0326.jpg,[],['no glaucoma']
368
+ 366,REFUGE-Training400/n0327.jpg,[],['no glaucoma']
369
+ 367,REFUGE-Training400/n0328.jpg,[],['no glaucoma']
370
+ 368,REFUGE-Training400/n0329.jpg,[],['no glaucoma']
371
+ 369,REFUGE-Training400/n0330.jpg,[],['no glaucoma']
372
+ 370,REFUGE-Training400/n0331.jpg,[],['no glaucoma']
373
+ 371,REFUGE-Training400/n0332.jpg,[],['no glaucoma']
374
+ 372,REFUGE-Training400/n0333.jpg,[],['no glaucoma']
375
+ 373,REFUGE-Training400/n0334.jpg,[],['no glaucoma']
376
+ 374,REFUGE-Training400/n0335.jpg,[],['no glaucoma']
377
+ 375,REFUGE-Training400/n0336.jpg,[],['no glaucoma']
378
+ 376,REFUGE-Training400/n0337.jpg,[],['no glaucoma']
379
+ 377,REFUGE-Training400/n0338.jpg,[],['no glaucoma']
380
+ 378,REFUGE-Training400/n0339.jpg,[],['no glaucoma']
381
+ 379,REFUGE-Training400/n0340.jpg,[],['no glaucoma']
382
+ 380,REFUGE-Training400/n0341.jpg,[],['no glaucoma']
383
+ 381,REFUGE-Training400/n0342.jpg,[],['no glaucoma']
384
+ 382,REFUGE-Training400/n0343.jpg,[],['no glaucoma']
385
+ 383,REFUGE-Training400/n0344.jpg,[],['no glaucoma']
386
+ 384,REFUGE-Training400/n0345.jpg,[],['no glaucoma']
387
+ 385,REFUGE-Training400/n0346.jpg,[],['no glaucoma']
388
+ 386,REFUGE-Training400/n0347.jpg,[],['no glaucoma']
389
+ 387,REFUGE-Training400/n0348.jpg,[],['no glaucoma']
390
+ 388,REFUGE-Training400/n0349.jpg,[],['no glaucoma']
391
+ 389,REFUGE-Training400/n0350.jpg,[],['no glaucoma']
392
+ 390,REFUGE-Training400/n0351.jpg,[],['no glaucoma']
393
+ 391,REFUGE-Training400/n0352.jpg,[],['no glaucoma']
394
+ 392,REFUGE-Training400/n0353.jpg,[],['no glaucoma']
395
+ 393,REFUGE-Training400/n0354.jpg,[],['no glaucoma']
396
+ 394,REFUGE-Training400/n0355.jpg,[],['no glaucoma']
397
+ 395,REFUGE-Training400/n0356.jpg,[],['no glaucoma']
398
+ 396,REFUGE-Training400/n0357.jpg,[],['no glaucoma']
399
+ 397,REFUGE-Training400/n0358.jpg,[],['no glaucoma']
400
+ 398,REFUGE-Training400/n0359.jpg,[],['no glaucoma']
401
+ 399,REFUGE-Training400/n0360.jpg,[],['no glaucoma']
local_data/chexpert-5x200.csv ADDED
The diff for this file is too large to render. See raw diff
 
metadata.json ADDED
The diff for this file is too large to render. See raw diff
 
openclip_CITATION.cff ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+
4
+ cff-version: 1.1.0
5
+ message: If you use this software, please cite it as below.
6
+ authors:
7
+ - family-names: Ilharco
8
+ given-names: Gabriel
9
+ - family-names: Wortsman
10
+ given-names: Mitchell
11
+ - family-names: Wightman
12
+ given-names: Ross
13
+ - family-names: Gordon
14
+ given-names: Cade
15
+ - family-names: Carlini
16
+ given-names: Nicholas
17
+ - family-names: Taori
18
+ given-names: Rohan
19
+ - family-names: Dave
20
+ given-names: Achal
21
+ - family-names: Shankar
22
+ given-names: Vaishaal
23
+ - family-names: Namkoong
24
+ given-names: Hongseok
25
+ - family-names: Miller
26
+ given-names: John
27
+ - family-names: Hajishirzi
28
+ given-names: Hannaneh
29
+ - family-names: Farhadi
30
+ given-names: Ali
31
+ - family-names: Schmidt
32
+ given-names: Ludwig
33
+ title: OpenCLIP
34
+ version: v0.1
35
+ doi: 10.5281/zenodo.5143773
36
+ date-released: 2021-07-28
openclip_LICENSE ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2012-2021 Gabriel Ilharco, Mitchell Wortsman,
2
+ Nicholas Carlini, Rohan Taori, Achal Dave, Vaishaal Shankar,
3
+ John Miller, Hongseok Namkoong, Hannaneh Hajishirzi, Ali Farhadi,
4
+ Ludwig Schmidt
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ "Software"), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ torch>=2.4.0
2
+ torchvision
3
+ regex
4
+ ftfy
5
+ tqdm
6
+ webdataset>=0.2.5
7
+ webdataset>=0.2.5
8
+ pandas
9
+ braceexpand
run_configs_400m.py ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates
2
+
3
+ # usage:
4
+ # torchrun --nproc_per_node=4 src/training/main.py b16_400m my-experiment-name <path-to-metaclip-pretrained-checkpoint>
5
+ from dataclasses import dataclass
6
+ from configs import Config
7
+
8
+
9
+ @dataclass
10
+ class b32_400m(Config):
11
+ inmem=True
12
+ engine="train_one_epoch_ex"
13
+ eval_steps=5000
14
+ save_frequency=1
15
+ # First prepare UniMed-Dataset using instructions in the docs/PREPARE-UniMed-DATA.md and then,
16
+ # provide paths for each sub-part of UniMed dataset below.
17
+ train_data="/<dataset-path>/radimagenet_webdataset/dataset-{000001..001049}.tar::/<dataset-path>/chexpert_webdataset/dataset-{000001..000212}.tar::/<dataset-path>/openi_webdataset/dataset-{000001..000007}.tar::/<dataset-path>/chest_xray8_webdataset/dataset-{000001..000113}.tar::/<dataset-path>/mimic_cxr/dataset-{000001..000270}.tar::/<dataset-path>/roco_webdataset/dataset-{000001..000061}.tar::/<dataset-path>/pmc_clip_webdataset/dataset-{000001..001645}.tar::/<dataset-path>/llava_med_alignment_set_webdataset/dataset-{000001..000468}.tar::/<dataset-path>/llava_med_hq_60k_set_webdataset/dataset-{000001..000265}.tar::/<dataset-path>/quilt_webdataset/dataset-{000001..001018}.tar::/<dataset-path>/retina_part1_webdataset/dataset-{000001..000155}.tar::/<dataset-path>/retina_part2_webdataset/dataset-{000001..000013}.tar::/<dataset-path>/retina_part3_webdataset/dataset-{000001..000006}.tar"
18
+ # train_num_samples = 1049000 (radimagenet) + 212000 (chexpert) + 7000 (openi) + 113000 (chest-xray8) + 270000 (mimic-cxr) + 61000 (rocov2) + 1645000 (pmc-clip) + 468000 (llavamed-alignment) + 265000 (llava-medhq) + 1018000 (quilt) + 155000 (retina part 1) + 13000 (retina part 2) + 6000 (retina part 3)
19
+ # Total training samples must equal total dataset size
20
+ train_num_samples = 5282000
21
+ # By default, we provide equal weightage to all dataset parts
22
+ train_data_upsampling_factors = "1::1::1::1::1::1::1::1::1::1::1::1"
23
+ # ----------------------------------------
24
+ workers=8
25
+ batch_size=128
26
+ epochs= 10
27
+ eval_freq = 1
28
+ model="ViT-B-32-quickgelu"
29
+ name="ViT-B-32"
30
+ force_quick_gelu=True
31
+ warmup=2000
32
+ seed=0
33
+ local_loss=True
34
+ gather_with_grad=True
35
+ nodes=16
36
+ ngpus=4
37
+ imagenet_val = None
38
+ report_to = 'wandb'
39
+ tokenizer_context_length = 256
40
+ text_encode_model_name = 'microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract'
41
+
42
+ @dataclass
43
+ class b32_400m_eval(Config):
44
+ inmem=True
45
+ engine="train_one_epoch_ex"
46
+ eval_steps=5000
47
+ save_frequency=1
48
+ train_data=""
49
+ workers=8
50
+ eval_freq = 1
51
+ train_num_samples=400000000
52
+ batch_size=512
53
+ epochs=10
54
+ model="ViT-B-32-quickgelu"
55
+ name="ViT-B-32"
56
+ force_quick_gelu=True
57
+ warmup=2000
58
+ seed=0
59
+ local_loss=True
60
+ gather_with_grad=True
61
+ nodes=16
62
+ ngpus=4
63
+ imagenet_val = None
64
+ pretrained = '<path-to-metaclip-pretrained-weights-file>/b16_400m.pt'
65
+ text_encode_model_name = 'microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract'
66
+ tokenizer_context_length = 256
67
+
68
+
69
+ @dataclass
70
+ class b16_400m(b32_400m):
71
+ model="ViT-B-16-quickgelu"
72
+ name="ViT-B-16"
73
+ grad_checkpointing=True
74
+ # Change below
75
+ pretrained = '<path-to-metaclip-pretrained-weights-file>/b16_400m.pt'
76
+ text_encode_model_name = 'microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract'
77
+
78
+ @dataclass
79
+ class b16_400m_eval(b32_400m_eval):
80
+ model="ViT-B-16-quickgelu"
81
+ name="ViT-B-16"
82
+ grad_checkpointing=True
83
+ pretrained = '<path-to-metaclip-pretrained-weights-file>/b16_400m.pt'
84
+ text_encoder_model_name = 'microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract'
85
+
86
+
87
+ @dataclass
88
+ class l14_400m(b32_400m):
89
+ model="ViT-L-14-336-quickgelu"
90
+ name="ViT-L-14"
91
+ lr=0.0004
92
+ grad_checkpointing=True
93
+ batch_size=128
94
+ nodes=16
95
+ ngpus=8
96
+ text_encoder_model_name = 'microsoft/BiomedNLP-BiomedBERT-large-uncased-abstract'
97
+
98
+ @dataclass
99
+ class l14_400m_eval(b32_400m_eval):
100
+ model="ViT-L-14-336-quickgelu"
101
+ name="ViT-L-14"
102
+ lr=0.0004
103
+ grad_checkpointing=True
104
+ batch_size=256
105
+ nodes=16
106
+ ngpus=8
107
+ text_encoder_model_name = 'microsoft/BiomedNLP-BiomedBERT-large-uncased-abstract'
108
+
109
+ @dataclass
110
+ class l14_400m_base_text_encoder(b32_400m):
111
+ model="ViT-L-14-336-quickgelu"
112
+ name="ViT-L-14"
113
+ lr=0.0004
114
+ grad_checkpointing=True
115
+ batch_size=128
116
+ nodes=16
117
+ ngpus=8
118
+ text_encoder_model_name = 'microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract'
119
+
120
+ @dataclass
121
+ class l14_400m_base_text_encoder_eval(b32_400m_eval):
122
+ model="ViT-L-14-336-quickgelu"
123
+ name="ViT-L-14"
124
+ lr=0.0004
125
+ grad_checkpointing=True
126
+ batch_size=256
127
+ nodes=16
128
+ ngpus=8
129
+ text_encode_model_name = 'microsoft/BiomedNLP-BiomedBERT-base-uncased-abstract'
130
+
131
+ if __name__ == "__main__":
132
+ import inspect
133
+ import sys
134
+ for name, obj in inspect.getmembers(sys.modules[__name__]):
135
+ if inspect.isfunction(obj):
136
+ print(name)
setup.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ # All rights reserved.
3
+
4
+ """ Setup
5
+ """
6
+ from setuptools import setup, find_packages
7
+ from codecs import open
8
+ from os import path
9
+
10
+ here = path.abspath(path.dirname(__file__))
11
+
12
+ # Get the long description from the README file
13
+ with open(path.join(here, 'README.md'), encoding='utf-8') as f:
14
+ long_description = f.read()
15
+
16
+ exec(open('src/open_clip/version.py').read())
17
+ setup(
18
+ name='open_clip_torch',
19
+ version=__version__,
20
+ description='OpenCLIP',
21
+ long_description=long_description,
22
+ long_description_content_type='text/markdown',
23
+ url='https://github.com/mlfoundations/open_clip',
24
+ author='',
25
+ author_email='',
26
+ classifiers=[
27
+ # How mature is this project? Common values are
28
+ # 3 - Alpha
29
+ # 4 - Beta
30
+ # 5 - Production/Stable
31
+ 'Development Status :: 3 - Alpha',
32
+ 'Intended Audience :: Education',
33
+ 'Intended Audience :: Science/Research',
34
+ 'License :: OSI Approved :: Apache Software License',
35
+ 'Programming Language :: Python :: 3.7',
36
+ 'Programming Language :: Python :: 3.8',
37
+ 'Programming Language :: Python :: 3.9',
38
+ 'Programming Language :: Python :: 3.10',
39
+ 'Topic :: Scientific/Engineering',
40
+ 'Topic :: Scientific/Engineering :: Artificial Intelligence',
41
+ 'Topic :: Software Development',
42
+ 'Topic :: Software Development :: Libraries',
43
+ 'Topic :: Software Development :: Libraries :: Python Modules',
44
+ ],
45
+
46
+ # Note that this is a string of words separated by whitespace, not a list.
47
+ keywords='CLIP pretrained',
48
+ package_dir={'': 'src'},
49
+ packages=find_packages(where='src', exclude=['training']),
50
+ include_package_data=True,
51
+ install_requires=[
52
+ 'torch >= 1.9',
53
+ 'torchvision',
54
+ 'ftfy',
55
+ 'regex',
56
+ 'tqdm',
57
+ ],
58
+ python_requires='>=3.7',
59
+ )
src/open_clip/__init__.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from .factory import list_models, create_model, create_model_and_transforms, add_model_config
2
+ from .loss import ClipLoss
3
+ from .model import CLIP, CLIPTextCfg, CLIPVisionCfg, convert_weights_to_fp16, trace_model
4
+ from .openai import load_openai_model, list_openai_models
5
+ from .pretrained import list_pretrained, list_pretrained_tag_models, list_pretrained_model_tags,\
6
+ get_pretrained_url, download_pretrained
7
+ from .tokenizer import SimpleTokenizer, tokenize, HFTokenizer
8
+ from .transform import image_transform, get_mean_std
src/open_clip/bpe_simple_vocab_16e6.txt.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:924691ac288e54409236115652ad4aa250f48203de50a9e4722a6ecd48d6804a
3
+ size 1356917
src/open_clip/factory.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates
2
+
3
+ import json
4
+ import logging
5
+ import os
6
+ import pathlib
7
+ import re
8
+ from copy import deepcopy
9
+ from pathlib import Path
10
+ from typing import Optional, Tuple
11
+
12
+ import torch
13
+
14
+ from . import model as model_zoo
15
+ from .model import CLIP, convert_weights_to_fp16, resize_pos_embed
16
+ from .openai import load_openai_model
17
+ from .pretrained import get_pretrained_url, download_pretrained
18
+ from .transform import image_transform
19
+
20
+
21
+ _MODEL_CONFIG_PATHS = [Path(__file__).parent / f"model_configs/"]
22
+ _MODEL_CONFIGS = {} # directory (model_name: config) of model architecture configs
23
+
24
+
25
+ def _natural_key(string_):
26
+ return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_.lower())]
27
+
28
+
29
+ def _rescan_model_configs():
30
+ global _MODEL_CONFIGS
31
+
32
+ config_ext = ('.json',)
33
+ config_files = []
34
+ for config_path in _MODEL_CONFIG_PATHS:
35
+ if config_path.is_file() and config_path.suffix in config_ext:
36
+ config_files.append(config_path)
37
+ elif config_path.is_dir():
38
+ for ext in config_ext:
39
+ config_files.extend(config_path.glob(f'*{ext}'))
40
+
41
+ for cf in config_files:
42
+ with open(cf, 'r') as f:
43
+ model_cfg = json.load(f)
44
+ if all(a in model_cfg for a in ('embed_dim', 'vision_cfg', 'text_cfg')):
45
+ _MODEL_CONFIGS[cf.stem] = model_cfg
46
+
47
+ _MODEL_CONFIGS = {k: v for k, v in sorted(_MODEL_CONFIGS.items(), key=lambda x: _natural_key(x[0]))}
48
+
49
+
50
+ _rescan_model_configs() # initial populate of model config registry
51
+
52
+
53
+ def load_state_dict(checkpoint_path: str, map_location='cpu'):
54
+ checkpoint = torch.load(checkpoint_path, map_location=map_location)
55
+ if isinstance(checkpoint, dict) and 'state_dict' in checkpoint:
56
+ state_dict = checkpoint['state_dict']
57
+ else:
58
+ state_dict = checkpoint
59
+ if next(iter(state_dict.items()))[0].startswith('module'):
60
+ state_dict = {k[7:]: v for k, v in state_dict.items()}
61
+ return state_dict
62
+
63
+
64
+ def load_checkpoint(model, checkpoint_path, strict=False):
65
+ state_dict = load_state_dict(checkpoint_path)
66
+ resize_pos_embed(state_dict, model)
67
+ incompatible_keys = model.load_state_dict(state_dict, strict=strict)
68
+ return incompatible_keys
69
+
70
+
71
+ def create_model(
72
+ model_name: str,
73
+ pretrained: str = '',
74
+ precision: str = 'fp32',
75
+ device: torch.device = torch.device('cpu'),
76
+ jit: bool = False,
77
+ force_quick_gelu: bool = False,
78
+ pretrained_image: bool = False,
79
+ clip_model: str = "CLIP",
80
+ text_encoder_name=None,
81
+ ):
82
+ model_name = model_name.replace('/', '-') # for callers using old naming with / in ViT names
83
+
84
+ if pretrained.lower() == 'openai':
85
+ logging.info(f'Loading pretrained {model_name} from OpenAI.')
86
+ model = load_openai_model(model_name, device=device, jit=jit)
87
+ # See https://discuss.pytorch.org/t/valueerror-attemting-to-unscale-fp16-gradients/81372
88
+ if precision == "amp" or precision == "fp32":
89
+ model = model.float()
90
+ else:
91
+ if model_name in _MODEL_CONFIGS:
92
+ logging.info(f'Loading {model_name} model config.')
93
+ model_cfg = deepcopy(_MODEL_CONFIGS[model_name])
94
+ else:
95
+ logging.error(f'Model config for {model_name} not found; available models {list_models()}.')
96
+ raise RuntimeError(f'Model config for {model_name} not found.')
97
+
98
+ if force_quick_gelu:
99
+ # override for use of QuickGELU on non-OpenAI transformer models
100
+ model_cfg["quick_gelu"] = True
101
+
102
+ if pretrained_image:
103
+ if 'timm_model_name' in model_cfg.get('vision_cfg', {}):
104
+ # pretrained weight loading for timm models set via vision_cfg
105
+ model_cfg['vision_cfg']['timm_model_pretrained'] = True
106
+ else:
107
+ assert False, 'pretrained image towers currently only supported for timm models'
108
+ model_cfg['text_encoder_name'] = text_encoder_name
109
+ model_cls = getattr(model_zoo, clip_model)
110
+ model = model_cls(**model_cfg) # via multiple CLIP models.
111
+
112
+ if pretrained:
113
+ checkpoint_path = ''
114
+ url = get_pretrained_url(model_name, pretrained)
115
+ if url:
116
+ checkpoint_path = download_pretrained(url)
117
+ elif os.path.exists(pretrained):
118
+ checkpoint_path = pretrained
119
+
120
+ if checkpoint_path:
121
+ logging.info(f'Loading pretrained {model_name} weights ({pretrained}).')
122
+ msg = load_checkpoint(model, checkpoint_path)
123
+ logging.info(f'{msg}')
124
+ else:
125
+ logging.warning(f'Pretrained weights ({pretrained}) not found for model {model_name}.')
126
+ raise RuntimeError(f'Pretrained weights ({pretrained}) not found for model {model_name}.')
127
+
128
+ model.to(device=device)
129
+ if precision == "fp16":
130
+ assert device.type != 'cpu'
131
+ convert_weights_to_fp16(model)
132
+
133
+ if jit:
134
+ model = torch.jit.script(model)
135
+
136
+ return model
137
+
138
+
139
+ def create_model_and_transforms(
140
+ model_name: str,
141
+ pretrained: str = '',
142
+ precision: str = 'fp32',
143
+ device: torch.device = torch.device('cpu'),
144
+ jit: bool = False,
145
+ force_quick_gelu: bool = False,
146
+ pretrained_image: bool = False,
147
+ mean: Optional[Tuple[float, ...]] = None,
148
+ std: Optional[Tuple[float, ...]] = None,
149
+ inmem = False,
150
+ clip_model: str = "CLIP",
151
+ text_encoder_name=None,
152
+ ):
153
+ model = create_model(
154
+ model_name, pretrained, precision, device, jit,
155
+ force_quick_gelu=force_quick_gelu,
156
+ pretrained_image=pretrained_image,
157
+ clip_model=clip_model,
158
+ text_encoder_name=text_encoder_name,
159
+ )
160
+ preprocess_train = image_transform(model.visual.image_size, is_train=True, mean=mean, std=std, inmem=inmem)
161
+ preprocess_val = image_transform(model.visual.image_size, is_train=False, mean=mean, std=std)
162
+ return model, preprocess_train, preprocess_val
163
+
164
+
165
+ def list_models():
166
+ """ enumerate available model architectures based on config files """
167
+ return list(_MODEL_CONFIGS.keys())
168
+
169
+
170
+ def add_model_config(path):
171
+ """ add model config path or file and update registry """
172
+ if not isinstance(path, Path):
173
+ path = Path(path)
174
+ _MODEL_CONFIG_PATHS.append(path)
175
+ _rescan_model_configs()
src/open_clip/hf_configs.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HF architecture dict:
2
+ arch_dict = {
3
+ # https://huggingface.co/docs/transformers/model_doc/roberta#roberta
4
+ "roberta": {
5
+ "config_names": {
6
+ "context_length": "max_position_embeddings",
7
+ "vocab_size": "vocab_size",
8
+ "width": "hidden_size",
9
+ "heads": "num_attention_heads",
10
+ "layers": "num_hidden_layers",
11
+ "layer_attr": "layer",
12
+ "token_embeddings_attr": "embeddings"
13
+ },
14
+ "pooler": "mean_pooler",
15
+ },
16
+ # https://huggingface.co/docs/transformers/model_doc/xlm-roberta#transformers.XLMRobertaConfig
17
+ "xlm-roberta": {
18
+ "config_names": {
19
+ "context_length": "max_position_embeddings",
20
+ "vocab_size": "vocab_size",
21
+ "width": "hidden_size",
22
+ "heads": "num_attention_heads",
23
+ "layers": "num_hidden_layers",
24
+ "layer_attr": "layer",
25
+ "token_embeddings_attr": "embeddings"
26
+ },
27
+ "pooler": "mean_pooler",
28
+ },
29
+ # https://huggingface.co/docs/transformers/model_doc/mt5#mt5
30
+ "mt5": {
31
+ "config_names": {
32
+ # unlimited seqlen
33
+ # https://github.com/google-research/text-to-text-transfer-transformer/issues/273
34
+ # https://github.com/huggingface/transformers/blob/v4.24.0/src/transformers/models/t5/modeling_t5.py#L374
35
+ "context_length": "",
36
+ "vocab_size": "vocab_size",
37
+ "width": "d_model",
38
+ "heads": "num_heads",
39
+ "layers": "num_layers",
40
+ "layer_attr": "block",
41
+ "token_embeddings_attr": "embed_tokens"
42
+ },
43
+ "pooler": "mean_pooler",
44
+ },
45
+ # https://huggingface.co/docs/transformers/model_doc/bert
46
+ "bert": {
47
+ "config_names": {
48
+ "context_length": "max_position_embeddings",
49
+ "vocab_size": "vocab_size",
50
+ "width": "hidden_size",
51
+ "heads": "num_attention_heads",
52
+ "layers": "num_hidden_layers",
53
+ },
54
+ "pooler": "cls_pooler",
55
+ },
56
+ # https://huggingface.co/docs/transformers/model_doc/m2m_100
57
+ "m2m_100": {
58
+ "config_names": {
59
+ "context_length": "max_position_embeddings",
60
+ "vocab_size": "vocab_size",
61
+ "width": "d_model",
62
+ "heads": "encoder_attention_heads",
63
+ "layers": "encoder_layers",
64
+ },
65
+ "pooler": "cls_pooler",
66
+ },
67
+ }
src/open_clip/hf_model.py ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ huggingface model adapter
2
+
3
+ Wraps HuggingFace transformers (https://github.com/huggingface/transformers) models for use as a text tower in CLIP model.
4
+ """
5
+ import re
6
+
7
+ import torch
8
+ import torch.nn as nn
9
+ from torch import TensorType
10
+
11
+ try:
12
+ import transformers
13
+ from transformers import AutoModel, AutoTokenizer, AutoConfig, PretrainedConfig
14
+ from transformers.modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, \
15
+ BaseModelOutputWithPoolingAndCrossAttentions
16
+ except ImportError as e:
17
+ transformers = None
18
+
19
+
20
+ class BaseModelOutput:
21
+ pass
22
+
23
+
24
+ class PretrainedConfig:
25
+ pass
26
+
27
+ from .hf_configs import arch_dict
28
+
29
+
30
+ # utils
31
+ def _camel2snake(s):
32
+ return re.sub(r'(?<!^)(?=[A-Z])', '_', s).lower()
33
+
34
+
35
+ # TODO: ?last - for gpt-like models
36
+ _POOLERS = {}
37
+
38
+
39
+ def register_pooler(cls):
40
+ """Decorator registering pooler class"""
41
+ _POOLERS[_camel2snake(cls.__name__)] = cls
42
+ return cls
43
+
44
+
45
+ @register_pooler
46
+ class MeanPooler(nn.Module):
47
+ """Mean pooling"""
48
+
49
+ def forward(self, x: BaseModelOutput, attention_mask: TensorType):
50
+ masked_output = x.last_hidden_state * attention_mask.unsqueeze(-1)
51
+ return masked_output.sum(dim=1) / attention_mask.sum(-1, keepdim=True)
52
+
53
+
54
+ @register_pooler
55
+ class MaxPooler(nn.Module):
56
+ """Max pooling"""
57
+
58
+ def forward(self, x: BaseModelOutput, attention_mask: TensorType):
59
+ masked_output = x.last_hidden_state.masked_fill(attention_mask.unsqueeze(-1), -torch.inf)
60
+ return masked_output.max(1).values
61
+
62
+
63
+ @register_pooler
64
+ class ClsPooler(nn.Module):
65
+ """CLS token pooling"""
66
+
67
+ def __init__(self, use_pooler_output=True):
68
+ super().__init__()
69
+ self.cls_token_position = 0
70
+ self.use_pooler_output = use_pooler_output
71
+
72
+ def forward(self, x: BaseModelOutput, attention_mask: TensorType):
73
+ if (self.use_pooler_output and
74
+ isinstance(x, (BaseModelOutputWithPooling, BaseModelOutputWithPoolingAndCrossAttentions)) and
75
+ (x.pooler_output is not None)
76
+ ):
77
+ return x.pooler_output
78
+
79
+ return x.last_hidden_state[:, self.cls_token_position, :]
80
+
81
+
82
+ @register_pooler
83
+ class ClsLastHiddenStatePooler(nn.Module):
84
+ """CLS token pooling
85
+ NOTE: this is equivalent to ClsPooler above with use_pooler_output=False
86
+ """
87
+
88
+ def __init__(self):
89
+ super().__init__()
90
+ self.cls_token_position = 0
91
+
92
+ def forward(self, x: BaseModelOutput, attention_mask: TensorType):
93
+ return x.last_hidden_state[:, self.cls_token_position, :]
94
+
95
+
96
+ class HFTextEncoder(nn.Module):
97
+ """HuggingFace model adapter"""
98
+ output_tokens: torch.jit.Final[bool]
99
+
100
+ def __init__(
101
+ self,
102
+ model_name_or_path: str,
103
+ output_dim: int,
104
+ config: PretrainedConfig = None,
105
+ pooler_type: str = None,
106
+ proj_type: str = None,
107
+ pretrained: bool = True,
108
+ output_tokens: bool = False,
109
+ ):
110
+ super().__init__()
111
+ self.output_tokens = output_tokens
112
+ self.output_dim = output_dim
113
+
114
+ # TODO: find better way to get this information
115
+ uses_transformer_pooler = (pooler_type == "cls_pooler")
116
+
117
+ if transformers is None:
118
+ raise RuntimeError("Please `pip install transformers` to use pre-trained HuggingFace models")
119
+ if config is None:
120
+ self.config = AutoConfig.from_pretrained(model_name_or_path)
121
+ create_func, model_args = (AutoModel.from_pretrained, model_name_or_path) if pretrained else (
122
+ AutoModel.from_config, self.config)
123
+ # TODO: do all model configs have this attribute? PretrainedConfig does so yes??
124
+ if hasattr(self.config, "is_encoder_decoder") and self.config.is_encoder_decoder:
125
+ self.transformer = create_func(model_args)
126
+ self.transformer = self.transformer.encoder
127
+ else:
128
+ self.transformer = create_func(model_args, add_pooling_layer=uses_transformer_pooler)
129
+ else:
130
+ self.config = config
131
+ self.transformer = AutoModel.from_config(config)
132
+ if pooler_type is None: # get default arch pooler
133
+ pooler_type = (arch_dict[self.config.model_type]["pooler"])
134
+
135
+ # FIXME downstream users of OpenCLIP models use these attr, need to verify valid across all models
136
+ self.vocab_size = getattr(self.config, 'vocab_size', 0)
137
+ self.context_length = getattr(self.config, 'max_position_embeddings', 0)
138
+
139
+ self.pooler = _POOLERS[pooler_type]()
140
+
141
+ d_model = getattr(self.config, arch_dict[self.config.model_type]["config_names"]["width"])
142
+ if (d_model == output_dim) and (proj_type is None): # do we always need a proj?
143
+ self.proj = nn.Identity()
144
+ elif proj_type == 'linear':
145
+ self.proj = nn.Linear(d_model, output_dim, bias=False)
146
+ elif proj_type == 'mlp':
147
+ hidden_size = (d_model + output_dim) // 2
148
+ self.proj = nn.Sequential(
149
+ nn.Linear(d_model, hidden_size, bias=False),
150
+ nn.GELU(),
151
+ nn.Linear(hidden_size, output_dim, bias=False),
152
+ )
153
+
154
+ def forward(self, x: TensorType):
155
+ attn_mask = (x != self.config.pad_token_id).long()
156
+ out = self.transformer(input_ids=x, attention_mask=attn_mask)
157
+ pooled_out = self.pooler(out, attn_mask)
158
+ projected = self.proj(pooled_out)
159
+
160
+ seq_len = out.last_hidden_state.shape[1]
161
+ tokens = (
162
+ out.last_hidden_state[:, torch.arange(seq_len) != self.pooler.cls_token_position, :]
163
+ if type(self.pooler) == ClsPooler
164
+ else out.last_hidden_state
165
+ )
166
+
167
+ if self.output_tokens:
168
+ return projected, tokens
169
+ return projected
170
+
171
+ def lock(self, unlocked_layers: int = 0, freeze_layer_norm: bool = True):
172
+ if not unlocked_layers: # full freezing
173
+ for n, p in self.transformer.named_parameters():
174
+ p.requires_grad = (not freeze_layer_norm) if "LayerNorm" in n.split(".") else False
175
+ return
176
+
177
+ encoder = self.transformer.encoder if hasattr(self.transformer, 'encoder') else self.transformer
178
+ layer_list = getattr(encoder, arch_dict[self.config.model_type]["config_names"]["layer_attr"])
179
+ print(f"Unlocking {unlocked_layers}/{len(layer_list) + 1} layers of hf model")
180
+ embeddings = getattr(
181
+ self.transformer, arch_dict[self.config.model_type]["config_names"]["token_embeddings_attr"])
182
+ modules = [embeddings, *layer_list][:-unlocked_layers]
183
+ # freeze layers
184
+ for module in modules:
185
+ for n, p in module.named_parameters():
186
+ p.requires_grad = (not freeze_layer_norm) if "LayerNorm" in n.split(".") else False
187
+
188
+ @torch.jit.ignore
189
+ def set_grad_checkpointing(self, enable=True):
190
+ self.transformer.gradient_checkpointing_enable()
191
+
192
+ def init_parameters(self):
193
+ pass
src/open_clip/loss.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates
2
+
3
+ import torch
4
+ import torch.nn as nn
5
+ from torch.nn import functional as F
6
+
7
+ try:
8
+ import torch.distributed.nn
9
+ from torch import distributed as dist
10
+ has_distributed = True
11
+ except ImportError:
12
+ has_distributed = False
13
+
14
+ try:
15
+ import horovod.torch as hvd
16
+ except ImportError:
17
+ hvd = None
18
+
19
+
20
+ def gather_features(
21
+ image_features,
22
+ text_features,
23
+ local_loss=False,
24
+ gather_with_grad=False,
25
+ rank=0,
26
+ world_size=1,
27
+ use_horovod=False
28
+ ):
29
+ assert has_distributed, 'torch.distributed did not import correctly, please use a PyTorch version with support.'
30
+ if use_horovod:
31
+ assert hvd is not None, 'Please install horovod'
32
+ if gather_with_grad:
33
+ all_image_features = hvd.allgather(image_features)
34
+ all_text_features = hvd.allgather(text_features)
35
+ else:
36
+ with torch.no_grad():
37
+ all_image_features = hvd.allgather(image_features)
38
+ all_text_features = hvd.allgather(text_features)
39
+ if not local_loss:
40
+ # ensure grads for local rank when all_* features don't have a gradient
41
+ gathered_image_features = list(all_image_features.chunk(world_size, dim=0))
42
+ gathered_text_features = list(all_text_features.chunk(world_size, dim=0))
43
+ gathered_image_features[rank] = image_features
44
+ gathered_text_features[rank] = text_features
45
+ all_image_features = torch.cat(gathered_image_features, dim=0)
46
+ all_text_features = torch.cat(gathered_text_features, dim=0)
47
+ else:
48
+ # We gather tensors from all gpus
49
+ if gather_with_grad:
50
+ all_image_features = torch.cat(torch.distributed.nn.all_gather(image_features), dim=0)
51
+ all_text_features = torch.cat(torch.distributed.nn.all_gather(text_features), dim=0)
52
+ else:
53
+ gathered_image_features = [torch.zeros_like(image_features) for _ in range(world_size)]
54
+ gathered_text_features = [torch.zeros_like(text_features) for _ in range(world_size)]
55
+ dist.all_gather(gathered_image_features, image_features)
56
+ dist.all_gather(gathered_text_features, text_features)
57
+ if not local_loss:
58
+ # ensure grads for local rank when all_* features don't have a gradient
59
+ gathered_image_features[rank] = image_features
60
+ gathered_text_features[rank] = text_features
61
+ all_image_features = torch.cat(gathered_image_features, dim=0)
62
+ all_text_features = torch.cat(gathered_text_features, dim=0)
63
+
64
+ return all_image_features, all_text_features
65
+
66
+
67
+ class ClipLoss(nn.Module):
68
+
69
+ def __init__(
70
+ self,
71
+ local_loss=False,
72
+ gather_with_grad=False,
73
+ cache_labels=False,
74
+ rank=0,
75
+ world_size=1,
76
+ use_horovod=False,
77
+ ):
78
+ super().__init__()
79
+ self.local_loss = local_loss
80
+ self.gather_with_grad = gather_with_grad
81
+ self.cache_labels = cache_labels
82
+ self.rank = rank
83
+ self.world_size = world_size
84
+ self.use_horovod = use_horovod
85
+
86
+ # cache state
87
+ self.prev_num_logits = 0
88
+ self.labels = {}
89
+
90
+ def forward(self, image_features, text_features, logit_scale):
91
+ device = image_features.device
92
+ if self.world_size > 1:
93
+ all_image_features, all_text_features = gather_features(
94
+ image_features, text_features,
95
+ self.local_loss, self.gather_with_grad, self.rank, self.world_size, self.use_horovod)
96
+
97
+ if self.local_loss:
98
+ logits_per_image = logit_scale * image_features @ all_text_features.T
99
+ logits_per_text = logit_scale * text_features @ all_image_features.T
100
+ else:
101
+ logits_per_image = logit_scale * all_image_features @ all_text_features.T
102
+ logits_per_text = logits_per_image.T
103
+ else:
104
+ logits_per_image = logit_scale * image_features @ text_features.T
105
+ logits_per_text = logit_scale * text_features @ image_features.T
106
+
107
+ # calculated ground-truth and cache if enabled
108
+ num_logits = logits_per_image.shape[0]
109
+ if self.prev_num_logits != num_logits or device not in self.labels:
110
+ labels = torch.arange(num_logits, device=device, dtype=torch.long)
111
+ if self.world_size > 1 and self.local_loss:
112
+ labels = labels + num_logits * self.rank
113
+ if self.cache_labels:
114
+ self.labels[device] = labels
115
+ self.prev_num_logits = num_logits
116
+ else:
117
+ labels = self.labels[device]
118
+
119
+ total_loss = (
120
+ F.cross_entropy(logits_per_image, labels) +
121
+ F.cross_entropy(logits_per_text, labels)
122
+ ) / 2
123
+ return total_loss
src/open_clip/model.py ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ CLIP Model
2
+
3
+ Adapted from https://github.com/openai/CLIP. Originally MIT License, Copyright (c) 2021 OpenAI.
4
+ """
5
+ # Copyright (c) Meta Platforms, Inc. and affiliates
6
+ from .hf_model import HFTextEncoder
7
+ from collections import OrderedDict
8
+ from dataclasses import dataclass
9
+ import logging
10
+ import math
11
+ from typing import Tuple, Union, Callable, Optional
12
+
13
+ import numpy as np
14
+ import torch
15
+ import torch.nn.functional as F
16
+ from torch import nn
17
+ from torch.utils.checkpoint import checkpoint
18
+
19
+ from .timm_model import TimmModel
20
+ from .utils import freeze_batch_norm_2d, to_2tuple
21
+
22
+
23
+ class Bottleneck(nn.Module):
24
+ expansion = 4
25
+
26
+ def __init__(self, inplanes, planes, stride=1):
27
+ super().__init__()
28
+
29
+ # all conv layers have stride 1. an avgpool is performed after the second convolution when stride > 1
30
+ self.conv1 = nn.Conv2d(inplanes, planes, 1, bias=False)
31
+ self.bn1 = nn.BatchNorm2d(planes)
32
+ self.relu1 = nn.ReLU(inplace=True)
33
+
34
+ self.conv2 = nn.Conv2d(planes, planes, 3, padding=1, bias=False)
35
+ self.bn2 = nn.BatchNorm2d(planes)
36
+ self.relu2 = nn.ReLU(inplace=True)
37
+
38
+ self.avgpool = nn.AvgPool2d(stride) if stride > 1 else nn.Identity()
39
+
40
+ self.conv3 = nn.Conv2d(planes, planes * self.expansion, 1, bias=False)
41
+ self.bn3 = nn.BatchNorm2d(planes * self.expansion)
42
+ self.relu3 = nn.ReLU(inplace=True)
43
+
44
+ self.downsample = None
45
+ self.stride = stride
46
+
47
+ if stride > 1 or inplanes != planes * Bottleneck.expansion:
48
+ # downsampling layer is prepended with an avgpool, and the subsequent convolution has stride 1
49
+ self.downsample = nn.Sequential(OrderedDict([
50
+ ("-1", nn.AvgPool2d(stride)),
51
+ ("0", nn.Conv2d(inplanes, planes * self.expansion, 1, stride=1, bias=False)),
52
+ ("1", nn.BatchNorm2d(planes * self.expansion))
53
+ ]))
54
+
55
+ def forward(self, x: torch.Tensor):
56
+ identity = x
57
+
58
+ out = self.relu1(self.bn1(self.conv1(x)))
59
+ out = self.relu2(self.bn2(self.conv2(out)))
60
+ out = self.avgpool(out)
61
+ out = self.bn3(self.conv3(out))
62
+
63
+ if self.downsample is not None:
64
+ identity = self.downsample(x)
65
+
66
+ out += identity
67
+ out = self.relu3(out)
68
+ return out
69
+
70
+
71
+ class AttentionPool2d(nn.Module):
72
+ def __init__(self, spacial_dim: int, embed_dim: int, num_heads: int, output_dim: int = None):
73
+ super().__init__()
74
+ self.positional_embedding = nn.Parameter(torch.randn(spacial_dim ** 2 + 1, embed_dim) / embed_dim ** 0.5)
75
+ self.k_proj = nn.Linear(embed_dim, embed_dim)
76
+ self.q_proj = nn.Linear(embed_dim, embed_dim)
77
+ self.v_proj = nn.Linear(embed_dim, embed_dim)
78
+ self.c_proj = nn.Linear(embed_dim, output_dim or embed_dim)
79
+ self.num_heads = num_heads
80
+
81
+ def forward(self, x):
82
+ x = x.reshape(x.shape[0], x.shape[1], x.shape[2] * x.shape[3]).permute(2, 0, 1) # NCHW -> (HW)NC
83
+ x = torch.cat([x.mean(dim=0, keepdim=True), x], dim=0) # (HW+1)NC
84
+ x = x + self.positional_embedding[:, None, :].to(x.dtype) # (HW+1)NC
85
+ x, _ = F.multi_head_attention_forward(
86
+ query=x, key=x, value=x,
87
+ embed_dim_to_check=x.shape[-1],
88
+ num_heads=self.num_heads,
89
+ q_proj_weight=self.q_proj.weight,
90
+ k_proj_weight=self.k_proj.weight,
91
+ v_proj_weight=self.v_proj.weight,
92
+ in_proj_weight=None,
93
+ in_proj_bias=torch.cat([self.q_proj.bias, self.k_proj.bias, self.v_proj.bias]),
94
+ bias_k=None,
95
+ bias_v=None,
96
+ add_zero_attn=False,
97
+ dropout_p=0,
98
+ out_proj_weight=self.c_proj.weight,
99
+ out_proj_bias=self.c_proj.bias,
100
+ use_separate_proj_weight=True,
101
+ training=self.training,
102
+ need_weights=False
103
+ )
104
+
105
+ return x[0]
106
+
107
+
108
+ class ModifiedResNet(nn.Module):
109
+ """
110
+ A ResNet class that is similar to torchvision's but contains the following changes:
111
+ - There are now 3 "stem" convolutions as opposed to 1, with an average pool instead of a max pool.
112
+ - Performs anti-aliasing strided convolutions, where an avgpool is prepended to convolutions with stride > 1
113
+ - The final pooling layer is a QKV attention instead of an average pool
114
+ """
115
+
116
+ def __init__(self, layers, output_dim, heads, image_size=224, width=64):
117
+ super().__init__()
118
+ self.output_dim = output_dim
119
+ self.image_size = image_size
120
+
121
+ # the 3-layer stem
122
+ self.conv1 = nn.Conv2d(3, width // 2, kernel_size=3, stride=2, padding=1, bias=False)
123
+ self.bn1 = nn.BatchNorm2d(width // 2)
124
+ self.relu1 = nn.ReLU(inplace=True)
125
+ self.conv2 = nn.Conv2d(width // 2, width // 2, kernel_size=3, padding=1, bias=False)
126
+ self.bn2 = nn.BatchNorm2d(width // 2)
127
+ self.relu2 = nn.ReLU(inplace=True)
128
+ self.conv3 = nn.Conv2d(width // 2, width, kernel_size=3, padding=1, bias=False)
129
+ self.bn3 = nn.BatchNorm2d(width)
130
+ self.relu3 = nn.ReLU(inplace=True)
131
+ self.avgpool = nn.AvgPool2d(2)
132
+
133
+ # residual layers
134
+ self._inplanes = width # this is a *mutable* variable used during construction
135
+ self.layer1 = self._make_layer(width, layers[0])
136
+ self.layer2 = self._make_layer(width * 2, layers[1], stride=2)
137
+ self.layer3 = self._make_layer(width * 4, layers[2], stride=2)
138
+ self.layer4 = self._make_layer(width * 8, layers[3], stride=2)
139
+
140
+ embed_dim = width * 32 # the ResNet feature dimension
141
+ self.attnpool = AttentionPool2d(image_size // 32, embed_dim, heads, output_dim)
142
+
143
+ self.init_parameters()
144
+
145
+ def _make_layer(self, planes, blocks, stride=1):
146
+ layers = [Bottleneck(self._inplanes, planes, stride)]
147
+
148
+ self._inplanes = planes * Bottleneck.expansion
149
+ for _ in range(1, blocks):
150
+ layers.append(Bottleneck(self._inplanes, planes))
151
+
152
+ return nn.Sequential(*layers)
153
+
154
+ def init_parameters(self):
155
+ if self.attnpool is not None:
156
+ std = self.attnpool.c_proj.in_features ** -0.5
157
+ nn.init.normal_(self.attnpool.q_proj.weight, std=std)
158
+ nn.init.normal_(self.attnpool.k_proj.weight, std=std)
159
+ nn.init.normal_(self.attnpool.v_proj.weight, std=std)
160
+ nn.init.normal_(self.attnpool.c_proj.weight, std=std)
161
+
162
+ for resnet_block in [self.layer1, self.layer2, self.layer3, self.layer4]:
163
+ for name, param in resnet_block.named_parameters():
164
+ if name.endswith("bn3.weight"):
165
+ nn.init.zeros_(param)
166
+
167
+ def lock(self, unlocked_groups=0, freeze_bn_stats=False):
168
+ assert unlocked_groups == 0, 'partial locking not currently supported for this model'
169
+ for param in self.parameters():
170
+ param.requires_grad = False
171
+ if freeze_bn_stats:
172
+ freeze_batch_norm_2d(self)
173
+
174
+ @torch.jit.ignore
175
+ def set_grad_checkpointing(self, enable=True):
176
+ # FIXME support for non-transformer
177
+ pass
178
+
179
+ def stem(self, x):
180
+ x = self.relu1(self.bn1(self.conv1(x)))
181
+ x = self.relu2(self.bn2(self.conv2(x)))
182
+ x = self.relu3(self.bn3(self.conv3(x)))
183
+ x = self.avgpool(x)
184
+ return x
185
+
186
+ def forward(self, x):
187
+ x = self.stem(x)
188
+ x = self.layer1(x)
189
+ x = self.layer2(x)
190
+ x = self.layer3(x)
191
+ x = self.layer4(x)
192
+ x = self.attnpool(x)
193
+
194
+ return x
195
+
196
+
197
+ class LayerNorm(nn.LayerNorm):
198
+ """Subclass torch's LayerNorm to handle fp16."""
199
+
200
+ def forward(self, x: torch.Tensor):
201
+ orig_type = x.dtype
202
+ x = F.layer_norm(x, self.normalized_shape, self.weight, self.bias, self.eps)
203
+ return x.to(orig_type)
204
+
205
+
206
+ class QuickGELU(nn.Module):
207
+ # NOTE This is slower than nn.GELU or nn.SiLU and uses more GPU memory
208
+ def forward(self, x: torch.Tensor):
209
+ return x * torch.sigmoid(1.702 * x)
210
+
211
+
212
+ class ResidualAttentionBlock(nn.Module):
213
+ def __init__(self, d_model: int, n_head: int, mlp_ratio: float = 4.0, act_layer: Callable = nn.GELU):
214
+ super().__init__()
215
+
216
+ self.attn = nn.MultiheadAttention(d_model, n_head)
217
+ self.ln_1 = LayerNorm(d_model)
218
+ mlp_width = int(d_model * mlp_ratio)
219
+ self.mlp = nn.Sequential(OrderedDict([
220
+ ("c_fc", nn.Linear(d_model, mlp_width)),
221
+ ("gelu", act_layer()),
222
+ ("c_proj", nn.Linear(mlp_width, d_model))
223
+ ]))
224
+ self.ln_2 = LayerNorm(d_model)
225
+
226
+ def attention(self, x: torch.Tensor, attn_mask: Optional[torch.Tensor] = None):
227
+ return self.attn(x, x, x, need_weights=False, attn_mask=attn_mask)[0]
228
+
229
+ def forward(self, x: torch.Tensor, attn_mask: Optional[torch.Tensor] = None):
230
+ x = x + self.attention(self.ln_1(x), attn_mask=attn_mask)
231
+ x = x + self.mlp(self.ln_2(x))
232
+ return x
233
+
234
+
235
+ class Transformer(nn.Module):
236
+ def __init__(self, width: int, layers: int, heads: int, mlp_ratio: float = 4.0, act_layer: Callable = nn.GELU):
237
+ super().__init__()
238
+ self.width = width
239
+ self.layers = layers
240
+ self.grad_checkpointing = False
241
+
242
+ self.resblocks = nn.ModuleList([
243
+ ResidualAttentionBlock(width, heads, mlp_ratio, act_layer=act_layer)
244
+ for _ in range(layers)
245
+ ])
246
+
247
+ def forward(self, x: torch.Tensor, attn_mask: Optional[torch.Tensor] = None):
248
+ for r in self.resblocks:
249
+ if self.grad_checkpointing and not torch.jit.is_scripting():
250
+ x = checkpoint(r, x, attn_mask)
251
+ else:
252
+ x = r(x, attn_mask=attn_mask)
253
+ return x
254
+
255
+
256
+ class VisualTransformer(nn.Module):
257
+ def __init__(
258
+ self, image_size: int, patch_size: int, width: int, layers: int, heads: int, mlp_ratio: float,
259
+ output_dim: int, act_layer: Callable = nn.GELU):
260
+ super().__init__()
261
+ self.image_size = to_2tuple(image_size)
262
+ self.patch_size = to_2tuple(patch_size)
263
+ self.grid_size = (self.image_size[0] // self.patch_size[0], self.image_size[1] // self.patch_size[1])
264
+ self.output_dim = output_dim
265
+ self.conv1 = nn.Conv2d(in_channels=3, out_channels=width, kernel_size=patch_size, stride=patch_size, bias=False)
266
+
267
+ scale = width ** -0.5
268
+ self.class_embedding = nn.Parameter(scale * torch.randn(width))
269
+ self.positional_embedding = nn.Parameter(scale * torch.randn(self.grid_size[0] * self.grid_size[1] + 1, width))
270
+ self.ln_pre = LayerNorm(width)
271
+
272
+ self.transformer = Transformer(width, layers, heads, mlp_ratio, act_layer=act_layer)
273
+
274
+ self.ln_post = LayerNorm(width)
275
+ self.proj = nn.Parameter(scale * torch.randn(width, output_dim))
276
+
277
+ def lock(self, unlocked_groups=0, freeze_bn_stats=False):
278
+ assert unlocked_groups == 0, 'partial locking not currently supported for this model'
279
+ for param in self.parameters():
280
+ param.requires_grad = False
281
+
282
+ @torch.jit.ignore
283
+ def set_grad_checkpointing(self, enable=True):
284
+ self.transformer.grad_checkpointing = enable
285
+
286
+ def forward(self, x: torch.Tensor):
287
+ x = self.conv1(x) # shape = [*, width, grid, grid]
288
+ x = x.reshape(x.shape[0], x.shape[1], -1) # shape = [*, width, grid ** 2]
289
+ x = x.permute(0, 2, 1) # shape = [*, grid ** 2, width]
290
+ x = torch.cat(
291
+ [self.class_embedding.to(x.dtype) + torch.zeros(x.shape[0], 1, x.shape[-1], dtype=x.dtype, device=x.device),
292
+ x], dim=1) # shape = [*, grid ** 2 + 1, width]
293
+ x = x + self.positional_embedding.to(x.dtype)
294
+ x = self.ln_pre(x)
295
+
296
+ x = x.permute(1, 0, 2) # NLD -> LND
297
+ x = self.transformer(x)
298
+ x = x.permute(1, 0, 2) # LND -> NLD
299
+
300
+ x = self.ln_post(x[:, 0, :])
301
+
302
+ if self.proj is not None:
303
+ x = x @ self.proj
304
+
305
+ return x
306
+
307
+
308
+ @dataclass
309
+ class CLIPVisionCfg:
310
+ layers: Union[Tuple[int, int, int, int], int] = 12
311
+ width: int = 768
312
+ head_width: int = 64
313
+ mlp_ratio: float = 4.0
314
+ patch_size: int = 16
315
+ image_size: Union[Tuple[int, int], int] = 224
316
+ timm_model_name: str = None # a valid model name overrides layers, width, patch_size
317
+ timm_model_pretrained: bool = False # use (imagenet) pretrained weights for named model
318
+ timm_pool: str = 'avg' # feature pooling for timm model ('abs_attn', 'rot_attn', 'avg', '')
319
+ timm_proj: str = 'linear' # linear projection for timm model output ('linear', 'mlp', '')
320
+
321
+
322
+ @dataclass
323
+ class CLIPTextCfg:
324
+ context_length: int = 77
325
+ vocab_size: int = 49408
326
+ width: int = 512
327
+ heads: int = 8
328
+ layers: int = 12
329
+
330
+
331
+ class CLIP(nn.Module):
332
+ def __init__(
333
+ self,
334
+ embed_dim: int,
335
+ vision_cfg: CLIPVisionCfg,
336
+ text_cfg: CLIPTextCfg,
337
+ quick_gelu: bool = False,
338
+ text_encoder_name = None,
339
+ ):
340
+ super().__init__()
341
+ if isinstance(vision_cfg, dict):
342
+ vision_cfg = CLIPVisionCfg(**vision_cfg)
343
+ if isinstance(text_cfg, dict):
344
+ text_cfg = CLIPTextCfg(**text_cfg)
345
+
346
+ self.context_length = text_cfg.context_length
347
+
348
+ # OpenAI models are pretrained w/ QuickGELU
349
+ # NOTE: timm models always use native GELU regardless of quick_gelu flag.
350
+ act_layer = QuickGELU if quick_gelu else nn.GELU
351
+
352
+ if vision_cfg.timm_model_name:
353
+ self.visual = TimmModel(
354
+ vision_cfg.timm_model_name,
355
+ pretrained=vision_cfg.timm_model_pretrained,
356
+ pool=vision_cfg.timm_pool,
357
+ proj=vision_cfg.timm_proj,
358
+ embed_dim=embed_dim,
359
+ image_size=vision_cfg.image_size
360
+ )
361
+ act_layer = nn.GELU # so that text transformer doesn't use QuickGELU w/ timm models
362
+ elif isinstance(vision_cfg.layers, (tuple, list)):
363
+ vision_heads = vision_cfg.width * 32 // vision_cfg.head_width
364
+ self.visual = ModifiedResNet(
365
+ layers=vision_cfg.layers,
366
+ output_dim=embed_dim,
367
+ heads=vision_heads,
368
+ image_size=vision_cfg.image_size,
369
+ width=vision_cfg.width
370
+ )
371
+ else:
372
+ vision_heads = vision_cfg.width // vision_cfg.head_width
373
+ self.visual = VisualTransformer(
374
+ image_size=vision_cfg.image_size,
375
+ patch_size=vision_cfg.patch_size,
376
+ width=vision_cfg.width,
377
+ layers=vision_cfg.layers,
378
+ heads=vision_heads,
379
+ mlp_ratio=vision_cfg.mlp_ratio,
380
+ output_dim=embed_dim,
381
+ act_layer=act_layer,
382
+ )
383
+
384
+ self.text_encoder = HFTextEncoder(
385
+ text_encoder_name,
386
+ output_dim=embed_dim,
387
+ proj_type='mlp',
388
+ pooler_type='cls_last_hidden_state_pooler',
389
+ pretrained=True,
390
+ output_tokens=False,
391
+ )
392
+
393
+ self.logit_scale = nn.Parameter(torch.ones([]) * np.log(1 / 0.07))
394
+
395
+ self.init_parameters()
396
+
397
+ def init_parameters(self):
398
+ # nn.init.normal_(self.token_embedding.weight, std=0.02)
399
+ # nn.init.normal_(self.positional_embedding, std=0.01)
400
+ nn.init.constant_(self.logit_scale, np.log(1 / 0.07))
401
+
402
+ if hasattr(self.visual, 'init_parameters'):
403
+ self.visual.init_parameters()
404
+
405
+
406
+ def build_attention_mask(self):
407
+ # lazily create causal attention mask, with full attention between the vision tokens
408
+ # pytorch uses additive attention mask; fill with -inf
409
+ mask = torch.empty(self.context_length, self.context_length)
410
+ mask.fill_(float("-inf"))
411
+ mask.triu_(1) # zero out the lower diagonal
412
+ return mask
413
+
414
+ def lock_image_tower(self, unlocked_groups=0, freeze_bn_stats=False):
415
+ # lock image tower as per LiT - https://arxiv.org/abs/2111.07991
416
+ self.visual.lock(unlocked_groups=unlocked_groups, freeze_bn_stats=freeze_bn_stats)
417
+
418
+ @torch.jit.ignore
419
+ def set_grad_checkpointing(self, enable=True):
420
+ self.visual.set_grad_checkpointing(enable)
421
+ self.text_encoder.grad_checkpointing = enable
422
+
423
+ def encode_image(self, image):
424
+ return self.visual(image)
425
+
426
+
427
+ def encode_text(self, text):
428
+ text_features = self.text_encoder(text) # For BioMedCLIP text encoder
429
+ return text_features
430
+
431
+ def forward(self, image, text, clamp_logit_scale_to=None):
432
+ if image is not None:
433
+ image_features = self.encode_image(image)
434
+ image_features = F.normalize(image_features, dim=-1)
435
+ else:
436
+ image_features = None
437
+ if text is not None:
438
+ # text_features = self.encode_text(text) # For normal CLIP text encoder
439
+ text_features = self.text_encoder(text) # For BioMedCLIP text encoder
440
+ text_features = F.normalize(text_features, dim=-1)
441
+ else:
442
+ text_features = None
443
+ if clamp_logit_scale_to is not None:
444
+ with torch.no_grad():
445
+ self.logit_scale.data.clamp_(0, clamp_logit_scale_to)
446
+ return image_features, text_features, self.logit_scale.exp()
447
+
448
+
449
+ def convert_weights_to_fp16(model: nn.Module):
450
+ """Convert applicable model parameters to fp16"""
451
+
452
+ def _convert_weights_to_fp16(l):
453
+ if isinstance(l, (nn.Conv1d, nn.Conv2d, nn.Linear)):
454
+ l.weight.data = l.weight.data.half()
455
+ if l.bias is not None:
456
+ l.bias.data = l.bias.data.half()
457
+
458
+ if isinstance(l, nn.MultiheadAttention):
459
+ for attr in [*[f"{s}_proj_weight" for s in ["in", "q", "k", "v"]], "in_proj_bias", "bias_k", "bias_v"]:
460
+ tensor = getattr(l, attr)
461
+ if tensor is not None:
462
+ tensor.data = tensor.data.half()
463
+
464
+ for name in ["text_projection", "proj"]:
465
+ if hasattr(l, name):
466
+ attr = getattr(l, name)
467
+ if attr is not None:
468
+ attr.data = attr.data.half()
469
+
470
+ model.apply(_convert_weights_to_fp16)
471
+
472
+
473
+ def build_model_from_openai_state_dict(state_dict: dict):
474
+ vit = "visual.proj" in state_dict
475
+
476
+ if vit:
477
+ vision_width = state_dict["visual.conv1.weight"].shape[0]
478
+ vision_layers = len(
479
+ [k for k in state_dict.keys() if k.startswith("visual.") and k.endswith(".attn.in_proj_weight")])
480
+ vision_patch_size = state_dict["visual.conv1.weight"].shape[-1]
481
+ grid_size = round((state_dict["visual.positional_embedding"].shape[0] - 1) ** 0.5)
482
+ image_size = vision_patch_size * grid_size
483
+ else:
484
+ counts: list = [
485
+ len(set(k.split(".")[2] for k in state_dict if k.startswith(f"visual.layer{b}"))) for b in [1, 2, 3, 4]]
486
+ vision_layers = tuple(counts)
487
+ vision_width = state_dict["visual.layer1.0.conv1.weight"].shape[0]
488
+ output_width = round((state_dict["visual.attnpool.positional_embedding"].shape[0] - 1) ** 0.5)
489
+ vision_patch_size = None
490
+ assert output_width ** 2 + 1 == state_dict["visual.attnpool.positional_embedding"].shape[0]
491
+ image_size = output_width * 32
492
+
493
+ embed_dim = state_dict["text_projection"].shape[1]
494
+ context_length = state_dict["positional_embedding"].shape[0]
495
+ vocab_size = state_dict["token_embedding.weight"].shape[0]
496
+ transformer_width = state_dict["ln_final.weight"].shape[0]
497
+ transformer_heads = transformer_width // 64
498
+ transformer_layers = len(set(k.split(".")[2] for k in state_dict if k.startswith(f"transformer.resblocks")))
499
+
500
+ vision_cfg = CLIPVisionCfg(
501
+ layers=vision_layers,
502
+ width=vision_width,
503
+ patch_size=vision_patch_size,
504
+ image_size=image_size,
505
+ )
506
+ text_cfg = CLIPTextCfg(
507
+ context_length=context_length,
508
+ vocab_size=vocab_size,
509
+ width=transformer_width,
510
+ heads=transformer_heads,
511
+ layers=transformer_layers
512
+ )
513
+ model = CLIP(
514
+ embed_dim,
515
+ vision_cfg=vision_cfg,
516
+ text_cfg=text_cfg,
517
+ quick_gelu=True, # OpenAI models were trained with QuickGELU
518
+ )
519
+
520
+ for key in ["input_resolution", "context_length", "vocab_size"]:
521
+ state_dict.pop(key, None)
522
+
523
+ convert_weights_to_fp16(model)
524
+ model.load_state_dict(state_dict)
525
+ return model.eval()
526
+
527
+
528
+ def trace_model(model, batch_size=256, device=torch.device('cpu')):
529
+ model.eval()
530
+ image_size = model.visual.image_size
531
+ example_images = torch.ones((batch_size, 3, image_size, image_size), device=device)
532
+ example_text = torch.zeros((batch_size, model.context_length), dtype=torch.int, device=device)
533
+ model = torch.jit.trace_module(
534
+ model,
535
+ inputs=dict(
536
+ forward=(example_images, example_text),
537
+ encode_text=(example_text,),
538
+ encode_image=(example_images,)
539
+ ))
540
+ model.visual.image_size = image_size
541
+ return model
542
+
543
+
544
+ def resize_pos_embed(state_dict, model, interpolation: str = 'bicubic', seq_dim=1):
545
+ # Rescale the grid of position embeddings when loading from state_dict
546
+ old_pos_embed = state_dict.get('visual.positional_embedding', None)
547
+ if old_pos_embed is None or not hasattr(model.visual, 'grid_size'):
548
+ return
549
+ grid_size = to_2tuple(model.visual.grid_size)
550
+ extra_tokens = 1 # FIXME detect different token configs (ie no class token, or more)
551
+ new_seq_len = grid_size[0] * grid_size[1] + extra_tokens
552
+ if new_seq_len == old_pos_embed.shape[0]:
553
+ return
554
+
555
+ if extra_tokens:
556
+ pos_emb_tok, pos_emb_img = old_pos_embed[:extra_tokens], old_pos_embed[extra_tokens:]
557
+ else:
558
+ pos_emb_tok, pos_emb_img = None, old_pos_embed
559
+ old_grid_size = to_2tuple(int(math.sqrt(len(pos_emb_img))))
560
+
561
+ logging.info('Resizing position embedding grid-size from %s to %s', old_grid_size, grid_size)
562
+ pos_emb_img = pos_emb_img.reshape(1, old_grid_size[0], old_grid_size[1], -1).permute(0, 3, 1, 2)
563
+ pos_emb_img = F.interpolate(
564
+ pos_emb_img,
565
+ size=grid_size,
566
+ mode=interpolation,
567
+ align_corners=True,
568
+ )
569
+ pos_emb_img = pos_emb_img.permute(0, 2, 3, 1).reshape(1, grid_size[0] * grid_size[1], -1)[0]
570
+ if pos_emb_tok is not None:
571
+ new_pos_embed = torch.cat([pos_emb_tok, pos_emb_img], dim=0)
572
+ else:
573
+ new_pos_embed = pos_emb_img
574
+ state_dict['visual.positional_embedding'] = new_pos_embed
src/open_clip/model_configs/RN101-quickgelu.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "embed_dim": 512,
3
+ "quick_gelu": true,
4
+ "vision_cfg": {
5
+ "image_size": 224,
6
+ "layers": [
7
+ 3,
8
+ 4,
9
+ 23,
10
+ 3
11
+ ],
12
+ "width": 64,
13
+ "patch_size": null
14
+ },
15
+ "text_cfg": {
16
+ "context_length": 77,
17
+ "vocab_size": 49408,
18
+ "width": 512,
19
+ "heads": 8,
20
+ "layers": 12
21
+ }
22
+ }
src/open_clip/model_configs/RN101.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "embed_dim": 512,
3
+ "vision_cfg": {
4
+ "image_size": 224,
5
+ "layers": [
6
+ 3,
7
+ 4,
8
+ 23,
9
+ 3
10
+ ],
11
+ "width": 64,
12
+ "patch_size": null
13
+ },
14
+ "text_cfg": {
15
+ "context_length": 77,
16
+ "vocab_size": 49408,
17
+ "width": 512,
18
+ "heads": 8,
19
+ "layers": 12
20
+ }
21
+ }
src/open_clip/model_configs/RN50-quickgelu.json ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "embed_dim": 1024,
3
+ "quick_gelu": true,
4
+ "vision_cfg": {
5
+ "image_size": 224,
6
+ "layers": [
7
+ 3,
8
+ 4,
9
+ 6,
10
+ 3
11
+ ],
12
+ "width": 64,
13
+ "patch_size": null
14
+ },
15
+ "text_cfg": {
16
+ "context_length": 77,
17
+ "vocab_size": 49408,
18
+ "width": 512,
19
+ "heads": 8,
20
+ "layers": 12
21
+ }
22
+ }
src/open_clip/model_configs/RN50.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "embed_dim": 1024,
3
+ "vision_cfg": {
4
+ "image_size": 224,
5
+ "layers": [
6
+ 3,
7
+ 4,
8
+ 6,
9
+ 3
10
+ ],
11
+ "width": 64,
12
+ "patch_size": null
13
+ },
14
+ "text_cfg": {
15
+ "context_length": 77,
16
+ "vocab_size": 49408,
17
+ "width": 512,
18
+ "heads": 8,
19
+ "layers": 12
20
+ }
21
+ }