onnxtr 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. onnxtr/__init__.py +2 -0
  2. onnxtr/contrib/__init__.py +0 -0
  3. onnxtr/contrib/artefacts.py +131 -0
  4. onnxtr/contrib/base.py +105 -0
  5. onnxtr/file_utils.py +33 -0
  6. onnxtr/io/__init__.py +5 -0
  7. onnxtr/io/elements.py +455 -0
  8. onnxtr/io/html.py +28 -0
  9. onnxtr/io/image.py +56 -0
  10. onnxtr/io/pdf.py +42 -0
  11. onnxtr/io/reader.py +85 -0
  12. onnxtr/models/__init__.py +4 -0
  13. onnxtr/models/_utils.py +141 -0
  14. onnxtr/models/builder.py +355 -0
  15. onnxtr/models/classification/__init__.py +2 -0
  16. onnxtr/models/classification/models/__init__.py +1 -0
  17. onnxtr/models/classification/models/mobilenet.py +120 -0
  18. onnxtr/models/classification/predictor/__init__.py +1 -0
  19. onnxtr/models/classification/predictor/base.py +57 -0
  20. onnxtr/models/classification/zoo.py +76 -0
  21. onnxtr/models/detection/__init__.py +2 -0
  22. onnxtr/models/detection/core.py +101 -0
  23. onnxtr/models/detection/models/__init__.py +3 -0
  24. onnxtr/models/detection/models/differentiable_binarization.py +159 -0
  25. onnxtr/models/detection/models/fast.py +160 -0
  26. onnxtr/models/detection/models/linknet.py +160 -0
  27. onnxtr/models/detection/postprocessor/__init__.py +0 -0
  28. onnxtr/models/detection/postprocessor/base.py +144 -0
  29. onnxtr/models/detection/predictor/__init__.py +1 -0
  30. onnxtr/models/detection/predictor/base.py +54 -0
  31. onnxtr/models/detection/zoo.py +73 -0
  32. onnxtr/models/engine.py +50 -0
  33. onnxtr/models/predictor/__init__.py +1 -0
  34. onnxtr/models/predictor/base.py +175 -0
  35. onnxtr/models/predictor/predictor.py +145 -0
  36. onnxtr/models/preprocessor/__init__.py +1 -0
  37. onnxtr/models/preprocessor/base.py +118 -0
  38. onnxtr/models/recognition/__init__.py +2 -0
  39. onnxtr/models/recognition/core.py +28 -0
  40. onnxtr/models/recognition/models/__init__.py +5 -0
  41. onnxtr/models/recognition/models/crnn.py +226 -0
  42. onnxtr/models/recognition/models/master.py +145 -0
  43. onnxtr/models/recognition/models/parseq.py +134 -0
  44. onnxtr/models/recognition/models/sar.py +134 -0
  45. onnxtr/models/recognition/models/vitstr.py +166 -0
  46. onnxtr/models/recognition/predictor/__init__.py +1 -0
  47. onnxtr/models/recognition/predictor/_utils.py +86 -0
  48. onnxtr/models/recognition/predictor/base.py +79 -0
  49. onnxtr/models/recognition/utils.py +89 -0
  50. onnxtr/models/recognition/zoo.py +69 -0
  51. onnxtr/models/zoo.py +114 -0
  52. onnxtr/transforms/__init__.py +1 -0
  53. onnxtr/transforms/base.py +112 -0
  54. onnxtr/utils/__init__.py +4 -0
  55. onnxtr/utils/common_types.py +18 -0
  56. onnxtr/utils/data.py +126 -0
  57. onnxtr/utils/fonts.py +41 -0
  58. onnxtr/utils/geometry.py +498 -0
  59. onnxtr/utils/multithreading.py +50 -0
  60. onnxtr/utils/reconstitution.py +70 -0
  61. onnxtr/utils/repr.py +64 -0
  62. onnxtr/utils/visualization.py +291 -0
  63. onnxtr/utils/vocabs.py +71 -0
  64. onnxtr/version.py +1 -0
  65. onnxtr-0.1.0.dist-info/LICENSE +201 -0
  66. onnxtr-0.1.0.dist-info/METADATA +481 -0
  67. onnxtr-0.1.0.dist-info/RECORD +70 -0
  68. onnxtr-0.1.0.dist-info/WHEEL +5 -0
  69. onnxtr-0.1.0.dist-info/top_level.txt +2 -0
  70. onnxtr-0.1.0.dist-info/zip-safe +1 -0
@@ -0,0 +1,291 @@
1
+ # Copyright (C) 2021-2024, Mindee | Felix Dittrich.
2
+
3
+ # This program is licensed under the Apache License 2.0.
4
+ # See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
5
+
6
+ from copy import deepcopy
7
+ from typing import Any, Dict, List, Optional, Tuple, Union
8
+
9
+ import cv2
10
+ import matplotlib.patches as patches
11
+ import matplotlib.pyplot as plt
12
+ import numpy as np
13
+ from matplotlib.figure import Figure
14
+
15
+ from .common_types import BoundingBox, Polygon4P
16
+
17
+ __all__ = ["visualize_page", "draw_boxes"]
18
+
19
+
20
+ def rect_patch(
21
+ geometry: BoundingBox,
22
+ page_dimensions: Tuple[int, int],
23
+ label: Optional[str] = None,
24
+ color: Tuple[float, float, float] = (0, 0, 0),
25
+ alpha: float = 0.3,
26
+ linewidth: int = 2,
27
+ fill: bool = True,
28
+ preserve_aspect_ratio: bool = False,
29
+ ) -> patches.Rectangle:
30
+ """Create a matplotlib rectangular patch for the element
31
+
32
+ Args:
33
+ ----
34
+ geometry: bounding box of the element
35
+ page_dimensions: dimensions of the Page in format (height, width)
36
+ label: label to display when hovered
37
+ color: color to draw box
38
+ alpha: opacity parameter to fill the boxes, 0 = transparent
39
+ linewidth: line width
40
+ fill: whether the patch should be filled
41
+ preserve_aspect_ratio: pass True if you passed True to the predictor
42
+
43
+ Returns:
44
+ -------
45
+ a rectangular Patch
46
+ """
47
+ if len(geometry) != 2 or any(not isinstance(elt, tuple) or len(elt) != 2 for elt in geometry):
48
+ raise ValueError("invalid geometry format")
49
+
50
+ # Unpack
51
+ height, width = page_dimensions
52
+ (xmin, ymin), (xmax, ymax) = geometry
53
+ # Switch to absolute coords
54
+ if preserve_aspect_ratio:
55
+ width = height = max(height, width)
56
+ xmin, w = xmin * width, (xmax - xmin) * width
57
+ ymin, h = ymin * height, (ymax - ymin) * height
58
+
59
+ return patches.Rectangle(
60
+ (xmin, ymin),
61
+ w,
62
+ h,
63
+ fill=fill,
64
+ linewidth=linewidth,
65
+ edgecolor=(*color, alpha),
66
+ facecolor=(*color, alpha),
67
+ label=label,
68
+ )
69
+
70
+
71
+ def polygon_patch(
72
+ geometry: np.ndarray,
73
+ page_dimensions: Tuple[int, int],
74
+ label: Optional[str] = None,
75
+ color: Tuple[float, float, float] = (0, 0, 0),
76
+ alpha: float = 0.3,
77
+ linewidth: int = 2,
78
+ fill: bool = True,
79
+ preserve_aspect_ratio: bool = False,
80
+ ) -> patches.Polygon:
81
+ """Create a matplotlib polygon patch for the element
82
+
83
+ Args:
84
+ ----
85
+ geometry: bounding box of the element
86
+ page_dimensions: dimensions of the Page in format (height, width)
87
+ label: label to display when hovered
88
+ color: color to draw box
89
+ alpha: opacity parameter to fill the boxes, 0 = transparent
90
+ linewidth: line width
91
+ fill: whether the patch should be filled
92
+ preserve_aspect_ratio: pass True if you passed True to the predictor
93
+
94
+ Returns:
95
+ -------
96
+ a polygon Patch
97
+ """
98
+ if not geometry.shape == (4, 2):
99
+ raise ValueError("invalid geometry format")
100
+
101
+ # Unpack
102
+ height, width = page_dimensions
103
+ geometry[:, 0] = geometry[:, 0] * (max(width, height) if preserve_aspect_ratio else width)
104
+ geometry[:, 1] = geometry[:, 1] * (max(width, height) if preserve_aspect_ratio else height)
105
+
106
+ return patches.Polygon(
107
+ geometry,
108
+ fill=fill,
109
+ linewidth=linewidth,
110
+ edgecolor=(*color, alpha),
111
+ facecolor=(*color, alpha),
112
+ label=label,
113
+ )
114
+
115
+
116
+ def create_obj_patch(
117
+ geometry: Union[BoundingBox, Polygon4P, np.ndarray],
118
+ page_dimensions: Tuple[int, int],
119
+ **kwargs: Any,
120
+ ) -> patches.Patch:
121
+ """Create a matplotlib patch for the element
122
+
123
+ Args:
124
+ ----
125
+ geometry: bounding box (straight or rotated) of the element
126
+ page_dimensions: dimensions of the page in format (height, width)
127
+ **kwargs: keyword arguments for the patch
128
+
129
+ Returns:
130
+ -------
131
+ a matplotlib Patch
132
+ """
133
+ if isinstance(geometry, tuple):
134
+ if len(geometry) == 2: # straight word BB (2 pts)
135
+ return rect_patch(geometry, page_dimensions, **kwargs)
136
+ elif len(geometry) == 4: # rotated word BB (4 pts)
137
+ return polygon_patch(np.asarray(geometry), page_dimensions, **kwargs)
138
+ elif isinstance(geometry, np.ndarray) and geometry.shape == (4, 2): # rotated line
139
+ return polygon_patch(geometry, page_dimensions, **kwargs)
140
+ raise ValueError("invalid geometry format")
141
+
142
+
143
+ def visualize_page(
144
+ page: Dict[str, Any],
145
+ image: np.ndarray,
146
+ words_only: bool = True,
147
+ display_artefacts: bool = True,
148
+ scale: float = 10,
149
+ interactive: bool = True,
150
+ add_labels: bool = True,
151
+ **kwargs: Any,
152
+ ) -> Figure:
153
+ """Visualize a full page with predicted blocks, lines and words
154
+
155
+ >>> import numpy as np
156
+ >>> import matplotlib.pyplot as plt
157
+ >>> from onnxtr.utils.visualization import visualize_page
158
+ >>> from onnxtr.models import ocr_db_crnn
159
+ >>> model = ocr_db_crnn()
160
+ >>> input_page = (255 * np.random.rand(600, 800, 3)).astype(np.uint8)
161
+ >>> out = model([[input_page]])
162
+ >>> visualize_page(out[0].pages[0].export(), input_page)
163
+ >>> plt.show()
164
+
165
+ Args:
166
+ ----
167
+ page: the exported Page of a Document
168
+ image: np array of the page, needs to have the same shape than page['dimensions']
169
+ words_only: whether only words should be displayed
170
+ display_artefacts: whether artefacts should be displayed
171
+ scale: figsize of the largest windows side
172
+ interactive: whether the plot should be interactive
173
+ add_labels: for static plot, adds text labels on top of bounding box
174
+ **kwargs: keyword arguments for the polygon patch
175
+
176
+ Returns:
177
+ -------
178
+ the matplotlib figure
179
+ """
180
+ # Get proper scale and aspect ratio
181
+ h, w = image.shape[:2]
182
+ size = (scale * w / h, scale) if h > w else (scale, h / w * scale)
183
+ fig, ax = plt.subplots(figsize=size)
184
+ # Display the image
185
+ ax.imshow(image)
186
+ # hide both axis
187
+ ax.axis("off")
188
+
189
+ if interactive:
190
+ artists: List[patches.Patch] = [] # instantiate an empty list of patches (to be drawn on the page)
191
+
192
+ for block in page["blocks"]:
193
+ if not words_only:
194
+ rect = create_obj_patch(
195
+ block["geometry"], page["dimensions"], label="block", color=(0, 1, 0), linewidth=1, **kwargs
196
+ )
197
+ # add patch on figure
198
+ ax.add_patch(rect)
199
+ if interactive:
200
+ # add patch to cursor's artists
201
+ artists.append(rect)
202
+
203
+ for line in block["lines"]:
204
+ if not words_only:
205
+ rect = create_obj_patch(
206
+ line["geometry"], page["dimensions"], label="line", color=(1, 0, 0), linewidth=1, **kwargs
207
+ )
208
+ ax.add_patch(rect)
209
+ if interactive:
210
+ artists.append(rect)
211
+
212
+ for word in line["words"]:
213
+ rect = create_obj_patch(
214
+ word["geometry"],
215
+ page["dimensions"],
216
+ label=f"{word['value']} (confidence: {word['confidence']:.2%})",
217
+ color=(0, 0, 1),
218
+ **kwargs,
219
+ )
220
+ ax.add_patch(rect)
221
+ if interactive:
222
+ artists.append(rect)
223
+ elif add_labels:
224
+ if len(word["geometry"]) == 5:
225
+ text_loc = (
226
+ int(page["dimensions"][1] * (word["geometry"][0] - word["geometry"][2] / 2)),
227
+ int(page["dimensions"][0] * (word["geometry"][1] - word["geometry"][3] / 2)),
228
+ )
229
+ else:
230
+ text_loc = (
231
+ int(page["dimensions"][1] * word["geometry"][0][0]),
232
+ int(page["dimensions"][0] * word["geometry"][0][1]),
233
+ )
234
+
235
+ if len(word["geometry"]) == 2:
236
+ # We draw only if boxes are in straight format
237
+ ax.text(
238
+ *text_loc,
239
+ word["value"],
240
+ size=10,
241
+ alpha=0.5,
242
+ color=(0, 0, 1),
243
+ )
244
+
245
+ if display_artefacts:
246
+ for artefact in block["artefacts"]:
247
+ rect = create_obj_patch(
248
+ artefact["geometry"],
249
+ page["dimensions"],
250
+ label="artefact",
251
+ color=(0.5, 0.5, 0.5),
252
+ linewidth=1,
253
+ **kwargs,
254
+ )
255
+ ax.add_patch(rect)
256
+ if interactive:
257
+ artists.append(rect)
258
+
259
+ if interactive:
260
+ import mplcursors
261
+
262
+ # Create mlp Cursor to hover patches in artists
263
+ mplcursors.Cursor(artists, hover=2).connect("add", lambda sel: sel.annotation.set_text(sel.artist.get_label()))
264
+ fig.tight_layout(pad=0.0)
265
+
266
+ return fig
267
+
268
+
269
+ def draw_boxes(boxes: np.ndarray, image: np.ndarray, color: Optional[Tuple[int, int, int]] = None, **kwargs) -> None:
270
+ """Draw an array of relative straight boxes on an image
271
+
272
+ Args:
273
+ ----
274
+ boxes: array of relative boxes, of shape (*, 4)
275
+ image: np array, float32 or uint8
276
+ color: color to use for bounding box edges
277
+ **kwargs: keyword arguments from `matplotlib.pyplot.plot`
278
+ """
279
+ h, w = image.shape[:2]
280
+ # Convert boxes to absolute coords
281
+ _boxes = deepcopy(boxes)
282
+ _boxes[:, [0, 2]] *= w
283
+ _boxes[:, [1, 3]] *= h
284
+ _boxes = _boxes.astype(np.int32)
285
+ for box in _boxes.tolist():
286
+ xmin, ymin, xmax, ymax = box
287
+ image = cv2.rectangle(
288
+ image, (xmin, ymin), (xmax, ymax), color=color if isinstance(color, tuple) else (0, 0, 255), thickness=2
289
+ )
290
+ plt.imshow(image)
291
+ plt.plot(**kwargs)
onnxtr/utils/vocabs.py ADDED
@@ -0,0 +1,71 @@
1
+ # Copyright (C) 2021-2024, Mindee | Felix Dittrich.
2
+
3
+ # This program is licensed under the Apache License 2.0.
4
+ # See LICENSE or go to <https://opensource.org/licenses/Apache-2.0> for full license details.
5
+
6
+ import string
7
+ from typing import Dict
8
+
9
+ __all__ = ["VOCABS"]
10
+
11
+
12
+ VOCABS: Dict[str, str] = {
13
+ "digits": string.digits,
14
+ "ascii_letters": string.ascii_letters,
15
+ "punctuation": string.punctuation,
16
+ "currency": "£€¥¢฿",
17
+ "ancient_greek": "αβγδεζηθικλμνξοπρστυφχψωΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ",
18
+ "arabic_letters": "ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىي",
19
+ "persian_letters": "پچڢڤگ",
20
+ "hindi_digits": "٠١٢٣٤٥٦٧٨٩",
21
+ "arabic_diacritics": "ًٌٍَُِّْ",
22
+ "arabic_punctuation": "؟؛«»—",
23
+ }
24
+
25
+ VOCABS["latin"] = VOCABS["digits"] + VOCABS["ascii_letters"] + VOCABS["punctuation"]
26
+ VOCABS["english"] = VOCABS["latin"] + "°" + VOCABS["currency"]
27
+ VOCABS["legacy_french"] = VOCABS["latin"] + "°" + "àâéèêëîïôùûçÀÂÉÈËÎÏÔÙÛÇ" + VOCABS["currency"]
28
+ VOCABS["french"] = VOCABS["english"] + "àâéèêëîïôùûüçÀÂÉÈÊËÎÏÔÙÛÜÇ"
29
+ VOCABS["portuguese"] = VOCABS["english"] + "áàâãéêíïóôõúüçÁÀÂÃÉÊÍÏÓÔÕÚÜÇ"
30
+ VOCABS["spanish"] = VOCABS["english"] + "áéíóúüñÁÉÍÓÚÜÑ" + "¡¿"
31
+ VOCABS["italian"] = VOCABS["english"] + "àèéìíîòóùúÀÈÉÌÍÎÒÓÙÚ"
32
+ VOCABS["german"] = VOCABS["english"] + "äöüßÄÖÜẞ"
33
+ VOCABS["arabic"] = (
34
+ VOCABS["digits"]
35
+ + VOCABS["hindi_digits"]
36
+ + VOCABS["arabic_letters"]
37
+ + VOCABS["persian_letters"]
38
+ + VOCABS["arabic_diacritics"]
39
+ + VOCABS["arabic_punctuation"]
40
+ + VOCABS["punctuation"]
41
+ )
42
+ VOCABS["czech"] = VOCABS["english"] + "áčďéěíňóřšťúůýžÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ"
43
+ VOCABS["polish"] = VOCABS["english"] + "ąćęłńóśźżĄĆĘŁŃÓŚŹŻ"
44
+ VOCABS["dutch"] = VOCABS["english"] + "áéíóúüñÁÉÍÓÚÜÑ"
45
+ VOCABS["norwegian"] = VOCABS["english"] + "æøåÆØÅ"
46
+ VOCABS["danish"] = VOCABS["english"] + "æøåÆØÅ"
47
+ VOCABS["finnish"] = VOCABS["english"] + "äöÄÖ"
48
+ VOCABS["swedish"] = VOCABS["english"] + "åäöÅÄÖ"
49
+ VOCABS["vietnamese"] = (
50
+ VOCABS["english"]
51
+ + "áàảạãăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệóòỏõọôốồổộỗơớờởợỡúùủũụưứừửữựiíìỉĩịýỳỷỹỵ"
52
+ + "ÁÀẢẠÃĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆÓÒỎÕỌÔỐỒỔỘỖƠỚỜỞỢỠÚÙỦŨỤƯỨỪỬỮỰIÍÌỈĨỊÝỲỶỸỴ"
53
+ )
54
+ VOCABS["hebrew"] = VOCABS["english"] + "אבגדהוזחטיכלמנסעפצקרשת" + "₪"
55
+ VOCABS["multilingual"] = "".join(
56
+ dict.fromkeys(
57
+ VOCABS["french"]
58
+ + VOCABS["portuguese"]
59
+ + VOCABS["spanish"]
60
+ + VOCABS["german"]
61
+ + VOCABS["czech"]
62
+ + VOCABS["polish"]
63
+ + VOCABS["dutch"]
64
+ + VOCABS["italian"]
65
+ + VOCABS["norwegian"]
66
+ + VOCABS["danish"]
67
+ + VOCABS["finnish"]
68
+ + VOCABS["swedish"]
69
+ + "§"
70
+ )
71
+ )
onnxtr/version.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = 'v0.1.0'
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.