pathoinfer 0.2.0__tar.gz

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 (178) hide show
  1. pathoinfer-0.2.0/.dockerignore +9 -0
  2. pathoinfer-0.2.0/.github/workflows/ci.yml +64 -0
  3. pathoinfer-0.2.0/.gitignore +49 -0
  4. pathoinfer-0.2.0/.pre-commit-config.yaml +22 -0
  5. pathoinfer-0.2.0/CHANGELOG.md +284 -0
  6. pathoinfer-0.2.0/LICENSE +202 -0
  7. pathoinfer-0.2.0/PKG-INFO +369 -0
  8. pathoinfer-0.2.0/README.md +285 -0
  9. pathoinfer-0.2.0/deploy/Dockerfile +46 -0
  10. pathoinfer-0.2.0/deploy/Dockerfile.triton +6 -0
  11. pathoinfer-0.2.0/deploy/README.md +115 -0
  12. pathoinfer-0.2.0/deploy/demo/run_job.py +44 -0
  13. pathoinfer-0.2.0/deploy/demo/setup.py +19 -0
  14. pathoinfer-0.2.0/deploy/docker-compose.gpu.yml +11 -0
  15. pathoinfer-0.2.0/deploy/docker-compose.yml +52 -0
  16. pathoinfer-0.2.0/docs/model_contract.md +209 -0
  17. pathoinfer-0.2.0/docs/outputs.md +223 -0
  18. pathoinfer-0.2.0/docs/qupath.md +96 -0
  19. pathoinfer-0.2.0/docs/vlm_grounding.md +131 -0
  20. pathoinfer-0.2.0/docs/vlm_quantisation.md +153 -0
  21. pathoinfer-0.2.0/examples/classification.yaml +12 -0
  22. pathoinfer-0.2.0/examples/detection.yaml +42 -0
  23. pathoinfer-0.2.0/examples/instance.yaml +46 -0
  24. pathoinfer-0.2.0/examples/segmentation.yaml +55 -0
  25. pathoinfer-0.2.0/figures/pathoinfer_banner.png +0 -0
  26. pathoinfer-0.2.0/pyproject.toml +148 -0
  27. pathoinfer-0.2.0/scripts/README.md +88 -0
  28. pathoinfer-0.2.0/scripts/bench_infer.py +96 -0
  29. pathoinfer-0.2.0/scripts/bench_read.py +85 -0
  30. pathoinfer-0.2.0/scripts/perf_report.py +160 -0
  31. pathoinfer-0.2.0/scripts/qc_overlay.py +60 -0
  32. pathoinfer-0.2.0/src/pathoinfer/__init__.py +6 -0
  33. pathoinfer-0.2.0/src/pathoinfer/_extras.py +18 -0
  34. pathoinfer-0.2.0/src/pathoinfer/_logging.py +91 -0
  35. pathoinfer-0.2.0/src/pathoinfer/analysis.py +68 -0
  36. pathoinfer-0.2.0/src/pathoinfer/cli.py +480 -0
  37. pathoinfer-0.2.0/src/pathoinfer/config.py +395 -0
  38. pathoinfer-0.2.0/src/pathoinfer/convert/README.md +340 -0
  39. pathoinfer-0.2.0/src/pathoinfer/convert/__init__.py +4 -0
  40. pathoinfer-0.2.0/src/pathoinfer/convert/common.py +98 -0
  41. pathoinfer-0.2.0/src/pathoinfer/convert/fp16.py +135 -0
  42. pathoinfer-0.2.0/src/pathoinfer/convert/parity.py +484 -0
  43. pathoinfer-0.2.0/src/pathoinfer/convert/ptq.py +163 -0
  44. pathoinfer-0.2.0/src/pathoinfer/convert/tensorrt.py +139 -0
  45. pathoinfer-0.2.0/src/pathoinfer/convert/vlm.py +359 -0
  46. pathoinfer-0.2.0/src/pathoinfer/convert/vlm_parity.py +233 -0
  47. pathoinfer-0.2.0/src/pathoinfer/engine/README.md +134 -0
  48. pathoinfer-0.2.0/src/pathoinfer/engine/__init__.py +3 -0
  49. pathoinfer-0.2.0/src/pathoinfer/engine/pipeline.py +437 -0
  50. pathoinfer-0.2.0/src/pathoinfer/engine/scheduler.py +161 -0
  51. pathoinfer-0.2.0/src/pathoinfer/io/README.md +79 -0
  52. pathoinfer-0.2.0/src/pathoinfer/io/__init__.py +1 -0
  53. pathoinfer-0.2.0/src/pathoinfer/io/interop.py +21 -0
  54. pathoinfer-0.2.0/src/pathoinfer/io/objects.py +232 -0
  55. pathoinfer-0.2.0/src/pathoinfer/io/writers/__init__.py +1 -0
  56. pathoinfer-0.2.0/src/pathoinfer/io/writers/geojson.py +106 -0
  57. pathoinfer-0.2.0/src/pathoinfer/io/writers/overlay.py +102 -0
  58. pathoinfer-0.2.0/src/pathoinfer/io/writers/parquet.py +188 -0
  59. pathoinfer-0.2.0/src/pathoinfer/io/writers/tiff.py +101 -0
  60. pathoinfer-0.2.0/src/pathoinfer/post/README.md +116 -0
  61. pathoinfer-0.2.0/src/pathoinfer/post/__init__.py +1 -0
  62. pathoinfer-0.2.0/src/pathoinfer/post/instances.py +92 -0
  63. pathoinfer-0.2.0/src/pathoinfer/post/nms.py +1 -0
  64. pathoinfer-0.2.0/src/pathoinfer/post/smoothing.py +1 -0
  65. pathoinfer-0.2.0/src/pathoinfer/post/vectorise.py +486 -0
  66. pathoinfer-0.2.0/src/pathoinfer/py.typed +0 -0
  67. pathoinfer-0.2.0/src/pathoinfer/registry/README.md +72 -0
  68. pathoinfer-0.2.0/src/pathoinfer/registry/__init__.py +1 -0
  69. pathoinfer-0.2.0/src/pathoinfer/registry/create.py +71 -0
  70. pathoinfer-0.2.0/src/pathoinfer/registry/legacy.py +71 -0
  71. pathoinfer-0.2.0/src/pathoinfer/registry/loader.py +171 -0
  72. pathoinfer-0.2.0/src/pathoinfer/registry/model_card.py +309 -0
  73. pathoinfer-0.2.0/src/pathoinfer/registry/onnx_info.py +45 -0
  74. pathoinfer-0.2.0/src/pathoinfer/registry/schema/model_card.v1.json +1049 -0
  75. pathoinfer-0.2.0/src/pathoinfer/runtime/README.md +119 -0
  76. pathoinfer-0.2.0/src/pathoinfer/runtime/__init__.py +1 -0
  77. pathoinfer-0.2.0/src/pathoinfer/runtime/base.py +86 -0
  78. pathoinfer-0.2.0/src/pathoinfer/runtime/factory.py +51 -0
  79. pathoinfer-0.2.0/src/pathoinfer/runtime/local/__init__.py +1 -0
  80. pathoinfer-0.2.0/src/pathoinfer/runtime/local/onnx.py +155 -0
  81. pathoinfer-0.2.0/src/pathoinfer/runtime/local/tensorrt.py +70 -0
  82. pathoinfer-0.2.0/src/pathoinfer/runtime/local/torch.py +57 -0
  83. pathoinfer-0.2.0/src/pathoinfer/runtime/local/vllm_offline.py +56 -0
  84. pathoinfer-0.2.0/src/pathoinfer/runtime/remote/README.md +124 -0
  85. pathoinfer-0.2.0/src/pathoinfer/runtime/remote/__init__.py +1 -0
  86. pathoinfer-0.2.0/src/pathoinfer/runtime/remote/triton.py +77 -0
  87. pathoinfer-0.2.0/src/pathoinfer/runtime/remote/vllm.py +137 -0
  88. pathoinfer-0.2.0/src/pathoinfer/runtime/vlm.py +138 -0
  89. pathoinfer-0.2.0/src/pathoinfer/serving/README.md +124 -0
  90. pathoinfer-0.2.0/src/pathoinfer/serving/__init__.py +2 -0
  91. pathoinfer-0.2.0/src/pathoinfer/serving/api.py +359 -0
  92. pathoinfer-0.2.0/src/pathoinfer/serving/triton_repo.py +146 -0
  93. pathoinfer-0.2.0/src/pathoinfer/serving/vllm.py +101 -0
  94. pathoinfer-0.2.0/src/pathoinfer/stitch/README.md +209 -0
  95. pathoinfer-0.2.0/src/pathoinfer/stitch/__init__.py +1 -0
  96. pathoinfer-0.2.0/src/pathoinfer/stitch/base.py +133 -0
  97. pathoinfer-0.2.0/src/pathoinfer/stitch/detection.py +241 -0
  98. pathoinfer-0.2.0/src/pathoinfer/stitch/heatmap.py +211 -0
  99. pathoinfer-0.2.0/src/pathoinfer/stitch/instance.py +232 -0
  100. pathoinfer-0.2.0/src/pathoinfer/stitch/segmentation.py +247 -0
  101. pathoinfer-0.2.0/src/pathoinfer/tiling/README.md +143 -0
  102. pathoinfer-0.2.0/src/pathoinfer/tiling/__init__.py +4 -0
  103. pathoinfer-0.2.0/src/pathoinfer/tiling/dataset.py +82 -0
  104. pathoinfer-0.2.0/src/pathoinfer/tiling/grid.py +232 -0
  105. pathoinfer-0.2.0/src/pathoinfer/tiling/slide_id.py +18 -0
  106. pathoinfer-0.2.0/src/pathoinfer/tiling/synthetic.py +36 -0
  107. pathoinfer-0.2.0/tests/__init__.py +0 -0
  108. pathoinfer-0.2.0/tests/conftest.py +54 -0
  109. pathoinfer-0.2.0/tests/convert/__init__.py +0 -0
  110. pathoinfer-0.2.0/tests/convert/conftest.py +11 -0
  111. pathoinfer-0.2.0/tests/convert/test_convert.py +397 -0
  112. pathoinfer-0.2.0/tests/convert/test_nvidia.py +155 -0
  113. pathoinfer-0.2.0/tests/convert/test_vlm.py +368 -0
  114. pathoinfer-0.2.0/tests/convert/test_vlm_full.py +61 -0
  115. pathoinfer-0.2.0/tests/engine/__init__.py +0 -0
  116. pathoinfer-0.2.0/tests/engine/conftest.py +14 -0
  117. pathoinfer-0.2.0/tests/engine/test_pipeline.py +321 -0
  118. pathoinfer-0.2.0/tests/engine/test_regression.py +90 -0
  119. pathoinfer-0.2.0/tests/fixtures/make_fixtures.py +267 -0
  120. pathoinfer-0.2.0/tests/fixtures/tiny_cls/model.pt2 +0 -0
  121. pathoinfer-0.2.0/tests/fixtures/tiny_cls/model_card.json +60 -0
  122. pathoinfer-0.2.0/tests/fixtures/tiny_dark/model.pt2 +0 -0
  123. pathoinfer-0.2.0/tests/fixtures/tiny_dark/model_card.json +60 -0
  124. pathoinfer-0.2.0/tests/fixtures/tiny_dark_onnx/model.onnx +0 -0
  125. pathoinfer-0.2.0/tests/fixtures/tiny_dark_onnx/model_card.json +60 -0
  126. pathoinfer-0.2.0/tests/fixtures/tiny_det/model.pt2 +0 -0
  127. pathoinfer-0.2.0/tests/fixtures/tiny_det/model_card.json +60 -0
  128. pathoinfer-0.2.0/tests/fixtures/tiny_nuclei/model.pt2 +0 -0
  129. pathoinfer-0.2.0/tests/fixtures/tiny_nuclei/model_card.json +58 -0
  130. pathoinfer-0.2.0/tests/fixtures/tiny_seg/model.onnx +0 -0
  131. pathoinfer-0.2.0/tests/fixtures/tiny_seg/model_card.json +27 -0
  132. pathoinfer-0.2.0/tests/fixtures/tiny_seg_card.onnx +0 -0
  133. pathoinfer-0.2.0/tests/fixtures/tiny_seg_export/model.pt2 +0 -0
  134. pathoinfer-0.2.0/tests/fixtures/tiny_seg_export/model_card.json +61 -0
  135. pathoinfer-0.2.0/tests/fixtures/tiny_seg_fp16/model.onnx +0 -0
  136. pathoinfer-0.2.0/tests/fixtures/tiny_seg_fp16/model_card.json +61 -0
  137. pathoinfer-0.2.0/tests/fixtures/tiny_seg_legacy.onnx +0 -0
  138. pathoinfer-0.2.0/tests/fixtures/tiny_seg_torch/model.pt +0 -0
  139. pathoinfer-0.2.0/tests/fixtures/tiny_seg_torch/model_card.json +61 -0
  140. pathoinfer-0.2.0/tests/io/__init__.py +0 -0
  141. pathoinfer-0.2.0/tests/io/test_geojson.py +89 -0
  142. pathoinfer-0.2.0/tests/io/test_objects.py +71 -0
  143. pathoinfer-0.2.0/tests/io/test_parquet.py +151 -0
  144. pathoinfer-0.2.0/tests/io/test_tiff.py +77 -0
  145. pathoinfer-0.2.0/tests/outputs.py +44 -0
  146. pathoinfer-0.2.0/tests/post/__init__.py +0 -0
  147. pathoinfer-0.2.0/tests/post/test_instances.py +72 -0
  148. pathoinfer-0.2.0/tests/post/test_vectorise.py +163 -0
  149. pathoinfer-0.2.0/tests/registry/__init__.py +0 -0
  150. pathoinfer-0.2.0/tests/registry/test_loader.py +123 -0
  151. pathoinfer-0.2.0/tests/registry/test_model_card.py +77 -0
  152. pathoinfer-0.2.0/tests/registry/test_schema.py +17 -0
  153. pathoinfer-0.2.0/tests/runtime/__init__.py +0 -0
  154. pathoinfer-0.2.0/tests/runtime/test_base.py +82 -0
  155. pathoinfer-0.2.0/tests/runtime/test_local.py +139 -0
  156. pathoinfer-0.2.0/tests/runtime/test_vllm_client.py +136 -0
  157. pathoinfer-0.2.0/tests/runtime/test_vllm_offline.py +64 -0
  158. pathoinfer-0.2.0/tests/runtime/test_vlm.py +91 -0
  159. pathoinfer-0.2.0/tests/serving/__init__.py +0 -0
  160. pathoinfer-0.2.0/tests/serving/fakes.py +30 -0
  161. pathoinfer-0.2.0/tests/serving/test_api.py +145 -0
  162. pathoinfer-0.2.0/tests/serving/test_triton.py +150 -0
  163. pathoinfer-0.2.0/tests/serving/test_vllm.py +91 -0
  164. pathoinfer-0.2.0/tests/stitch/__init__.py +0 -0
  165. pathoinfer-0.2.0/tests/stitch/test_detection.py +213 -0
  166. pathoinfer-0.2.0/tests/stitch/test_heatmap.py +196 -0
  167. pathoinfer-0.2.0/tests/stitch/test_instance.py +164 -0
  168. pathoinfer-0.2.0/tests/stitch/test_segmentation.py +423 -0
  169. pathoinfer-0.2.0/tests/test_analysis.py +73 -0
  170. pathoinfer-0.2.0/tests/test_cli.py +76 -0
  171. pathoinfer-0.2.0/tests/test_config.py +74 -0
  172. pathoinfer-0.2.0/tests/test_extras.py +12 -0
  173. pathoinfer-0.2.0/tests/test_import_guard.py +88 -0
  174. pathoinfer-0.2.0/tests/test_logging.py +100 -0
  175. pathoinfer-0.2.0/tests/tiling/__init__.py +0 -0
  176. pathoinfer-0.2.0/tests/tiling/conftest.py +17 -0
  177. pathoinfer-0.2.0/tests/tiling/test_dataset.py +38 -0
  178. pathoinfer-0.2.0/tests/tiling/test_grid.py +116 -0
@@ -0,0 +1,9 @@
1
+ # Only what the image needs: the package, the demo model and the deploy scripts.
2
+ **
3
+ !pyproject.toml
4
+ !README.md
5
+ !LICENSE
6
+ !src/**
7
+ !tests/fixtures/tiny_dark_onnx/**
8
+ !deploy/demo/**
9
+ **/__pycache__
@@ -0,0 +1,64 @@
1
+ # Clean-venv check: only patchology and pathoinfer (never pathotrain), CPU torch, then
2
+ # lint, type-check, CPU tests (GPU tests skip without nvidia-smi) and a wheel build.
3
+ name: CI
4
+
5
+ on:
6
+ push:
7
+ branches: [main, dev]
8
+ pull_request:
9
+
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ env:
15
+ # The patchology commit pathoinfer is tested against; bump it with patchology changes.
16
+ PATCHOLOGY_REF: 593b13b8bbb197c0cbaf4d806a51fa7376dbe53b
17
+ PYTHONUNBUFFERED: "1"
18
+
19
+ jobs:
20
+ check:
21
+ runs-on: ubuntu-24.04
22
+ timeout-minutes: 30
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - uses: astral-sh/setup-uv@v6
27
+ with:
28
+ python-version: "3.12"
29
+
30
+ - name: Install (clean venv, CPU torch)
31
+ run: |
32
+ uv venv .venv
33
+ uv pip install torch --index-url https://download.pytorch.org/whl/cpu
34
+ uv pip install "patchology @ git+https://github.com/twpkevin06222/patchology@${PATCHOLOGY_REF}"
35
+ # --no-sources: ignore the workspace's CUDA torch index; the CPU torch above stays.
36
+ # onnx runs the FP16, ONNX Runtime INT8 and parity tests; ModelOpt and TensorRT
37
+ # (the rest of [convert] and [trt]) are too large for CI and their tests skip.
38
+ # serve: mypy checks the job API against FastAPI's types, and its tests run.
39
+ uv pip install --no-sources -e ".[onnx,serve]" "onnx>=1.23.2" --group dev
40
+ uv pip list | grep -Ei "^(torch|patchology|pathoinfer|onnxruntime|polars|duckdb) "
41
+
42
+ - name: No pathotrain in the environment
43
+ run: "! .venv/bin/python -c 'import pathotrain'"
44
+
45
+ - name: Lint
46
+ run: |
47
+ .venv/bin/ruff check
48
+ .venv/bin/ruff format --check
49
+
50
+ - name: Type-check
51
+ run: .venv/bin/mypy src
52
+
53
+ - name: Tests (CPU)
54
+ run: .venv/bin/python -m pytest -q -rs
55
+
56
+ - name: Build wheel
57
+ run: |
58
+ uv build --wheel
59
+ .venv/bin/python -m zipfile -l dist/*.whl | grep -q "pathoinfer/registry/schema/model_card.v1.json"
60
+
61
+ - uses: actions/upload-artifact@v4
62
+ with:
63
+ name: wheel
64
+ path: dist/*.whl
@@ -0,0 +1,49 @@
1
+ # Agent instructions and handoff notes, kept local.
2
+ CLAUDE.md
3
+ .claude/
4
+ HANDOFF.md
5
+ PATHOINFER_INTERACTIVE_DESIGN.md
6
+
7
+ # Python
8
+ __pycache__/
9
+ *.py[cod]
10
+ *.egg-info/
11
+ build/
12
+ dist/
13
+
14
+ # Environments
15
+ .venv/
16
+ .venv-*/
17
+ .env
18
+
19
+ # Tool caches and reports
20
+ .mypy_cache/
21
+ .pytest_cache/
22
+ .ruff_cache/
23
+ .coverage
24
+ htmlcov/
25
+
26
+ # Model artifacts: models live in model folders outside the repo.
27
+ *.onnx
28
+ *.onnx.data
29
+ *.plan
30
+ *.pt
31
+ *.pt2
32
+ *.safetensors
33
+
34
+ # Slides and slide-sized outputs: tests generate synthetic slides, real ones never go in.
35
+ *.svs
36
+ *.ndpi
37
+ *.mrxs
38
+ *.scn
39
+ *.bif
40
+ *.czi
41
+ *.isyntax
42
+ *.vms
43
+ *.vmu
44
+ *.tif
45
+ *.tiff
46
+
47
+ # Committed test fixtures (tiny, generated by tests/fixtures/make_fixtures.py).
48
+ !tests/fixtures/**
49
+ tests/fixtures/**/__pycache__/
@@ -0,0 +1,22 @@
1
+ # Local hooks run the locked tool versions (uv run never prunes the environment).
2
+ repos:
3
+ - repo: local
4
+ hooks:
5
+ - id: ruff
6
+ name: ruff check
7
+ entry: uv run ruff check --fix
8
+ language: system
9
+ types: [python]
10
+ pass_filenames: false
11
+ - id: ruff-format
12
+ name: ruff format
13
+ entry: uv run ruff format
14
+ language: system
15
+ types: [python]
16
+ pass_filenames: false
17
+ - id: mypy
18
+ name: mypy
19
+ entry: uv run mypy src
20
+ language: system
21
+ types: [python]
22
+ pass_filenames: false
@@ -0,0 +1,284 @@
1
+ # Changelog
2
+
3
+ All notable changes to pathoinfer. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
+ [Semantic Versioning](https://semver.org/). Before 1.0, a minor release may break the
6
+ config or output formats; the entry says so.
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.2.0] - 2026-12-01
11
+
12
+ Classification runs, the instance task, model conversion, serving and VLM runtimes.
13
+ Breaks output formats: the objects Parquet table gains an `object_type` column, and new
14
+ config sections change the settings hash, so resumed runs redo finished slides once.
15
+
16
+ ### Added
17
+
18
+ - Tile classification runs (`task: classification`, `examples/classification.yaml`).
19
+ Every tile core is written as a QuPath `detection` with its argmax class, a `score`
20
+ and a `prob_<class>` measurement per class (for QuPath's measurement maps);
21
+ `classification.thresholds` adds region polygons where a class's probability reaches
22
+ the threshold, as `annotation`s in the same files. `classification.sigma_tiles`
23
+ smooths the core grid. With `outputs.tiff`, each class gets a
24
+ `<slide>.prob_<class>.tiff` heatmap, one pixel per tile core. The summary counts
25
+ tiles. Tiles of the card's background class are not written. New fixture `tiny_cls`.
26
+ The new config section changes the settings hash, so finished slides of any task run
27
+ again once.
28
+ - The objects table has an `object_type` column (QuPath's `objectType`) for every task,
29
+ after `task`.
30
+ - TIFF rasters may start away from the slide's corner: the ImageDescription gains
31
+ `origin` (level-0 px) and the file XPosition/YPosition tags (previously refused).
32
+
33
+ - A nucleus instance task (`task: instance`): HoVer-Net style models (pathotrain's
34
+ `cellseg` HoVer-Net, HoVer-NeXt, CellViT) give `np`, `hv` and `nt` maps, and pathoinfer
35
+ runs HoVer-Net's watershed per tile (`post/instances.py`, ported from pathotrain), keeps
36
+ each nucleus in the tile whose core holds its centroid, and writes one polygon per
37
+ nucleus with its type (QuPath `detection` objects), a `score` (its type's mean
38
+ probability) and `nucleus_probability`. New card variant `InstanceCard` (schema stays
39
+ v1; existing cards are unchanged), config section `instance:`
40
+ (`examples/instance.yaml`), fixture `tiny_nuclei`. New core dependencies:
41
+ `scikit-image` (the watershed) and `scipy`. `convert parity` scores instance models
42
+ like detection (F1 and count difference per type, nuclei matched by polygon IoU), with
43
+ the `instance:` settings in the parity config. `instance.workers` (default 4) runs the
44
+ per-tile watershed and polygons in that many processes: 64 tiles/s on one thread, 228
45
+ with 8 on PanNuke tiles. It is not part of the settings hash, so changing it does not
46
+ re-run finished slides.
47
+
48
+ - `segmentation.background_classes` counts classes as background, and
49
+ `segmentation.class_map` renames and merges classes: each key is an output name, its
50
+ value a model class (renamed) or a list of them (merged), e.g.
51
+ `{tumor: invasive tumor, stroma: [inflamed stroma, tumor-associated stroma]}`; classes
52
+ not named keep theirs. Probabilities move before each pixel's class is chosen, so the
53
+ label map, polygons, overlay and summary all show the result. `class_colors` takes the
54
+ new names. `pathoinfer validate` checks the names against the model.
55
+ - Each slide ends with a readable summary in the log: time per stage with its share of
56
+ the run, the main process's CPU (average cores used) and peak RAM, and on a local GPU
57
+ its utilisation during inference (mean and max) and peak memory in use on the device,
58
+ sampled through NVML every 0.5 s (TensorRT and ONNX Runtime memory included). Reader
59
+ processes are not measured. The `slide=...` line gains `cpu_s`, `peak_gpu_util_mean`,
60
+ `peak_gpu_util_max` and `peak_gpu_used_mb`. New core dependency: `nvidia-ml-py`
61
+ (machines without an NVIDIA driver skip the GPU line).
62
+ - Segmentation runs write `<slide>.overlay.png`: the whole slide at `outputs.overlay_mpp`
63
+ (default 6) with every class filled at 40% opacity, outlined, and a legend
64
+ (`io.writers.overlay`). On by default; `outputs.overlay: false` turns it off.
65
+ - `outputs.summary_format: json` writes the per-class summary as `<slide>.summary.json`
66
+ for every task: the run metadata once and `classes` mapping each class name to
67
+ `class_id`, `count`, `mean_score` and `total_area_um2`. The default stays Parquet.
68
+ Either new option changes the settings hash, so finished slides run again once.
69
+ - `pathoinfer convert fp16|ptq|trt|parity`:
70
+ - FP16 conversion with ONNX Runtime's converter; I/O dtypes and the FP32 op block list
71
+ are configurable.
72
+ - INT8/FP8 static PTQ with NVIDIA ModelOpt (TensorRT targets, kept layers in FP16) or
73
+ ONNX Runtime (INT8, kept layers in FP32), calibrated on tiles read through patchology
74
+ from a slide list (entropy, minmax or percentile). First/last layers, LayerNorm,
75
+ Softmax and attention are kept in high precision by default.
76
+ - TensorRT plans built as strongly typed networks with a batch profile, cached by
77
+ model, GPU, TensorRT version, precision and profile.
78
+ - A parity gate: both models run through the real stitchers on mini-slides (Dice, F1
79
+ and count difference, AUC per class). A pass writes the variant with
80
+ `provenance.parity` and can register it in MLflow under an alias; a fail names the
81
+ worst classes and layers and writes nothing.
82
+ - TensorRT plan runtime: `framework: tensorrt` model folders run in `pathoinfer run`.
83
+ - Serving:
84
+ - `TritonRuntime` (gRPC) implements the `Runtime` protocol; `runtime.triton_url` runs a
85
+ config's model on Triton with the engine unchanged.
86
+ - `pathoinfer serve triton-repo`: a Triton model repository (`config.pbtxt` built as
87
+ Triton's own protobuf, weights, card) from ONNX folders and TensorRT plans, with
88
+ dynamic batching from a config.
89
+ - `pathoinfer serve api`: a FastAPI slide job API (`POST /jobs`, status and progress,
90
+ outputs, cancel), each job's engine in its own process, bounded concurrency, state on
91
+ disk.
92
+ - `deploy/`: one Dockerfile (CPU, or CUDA with `TORCH_INDEX=cu130`), a compose stack
93
+ (Triton 26.10, API, demo client; the demo slide and repository are baked into the
94
+ images) and a GPU override.
95
+ - `pathoinfer.tiling.synthetic.write_pyramid`: the synthetic slide, now in the package.
96
+ - `run_slide(..., on_progress=)`: a callback after each batch with tiles done and total.
97
+ - VLM conversion for Qwen3-VL / SmolVLM fine-tuned with TRL + PEFT
98
+ (`docs/vlm_quantisation.md`): `pathoinfer convert vlm-merge` (LoRA into a bf16
99
+ safetensors folder), `convert vlm` (llm-compressor `fp8`, `w4a16-awq` or
100
+ `w4a16-gptq` on the language model only, vision encoder and projector kept bf16 by a
101
+ verified ignore list, calibrated on pathology image + question pairs) and
102
+ `convert vlm-parity` (PathVQA accuracy and box IoU against bf16 through two vLLM
103
+ servers; registers only within tolerance). `runtime/remote/vllm.py` gains a minimal
104
+ OpenAI-compatible client.
105
+ - ModelCard: `VqaCard` variant (task `vqa`, framework `hf`, precision up to `int4`),
106
+ additive at schema version 1.
107
+ - ModelCard: optional `provenance.parity` (schema stays version 1).
108
+ - VLM runtimes (`runtime/README.md`, `docs/vlm_grounding.md` for the Qwen3-VL to SAM 3
109
+ grounding design):
110
+ - `VllmClient` now retries connection errors, timeouts and HTTP 408/429/5xx with
111
+ backoff, caps requests in flight (`concurrency`, across threads), asks lists in
112
+ order (`ask_many`), sends images as data URLs or `file://` URIs (`local_media`),
113
+ takes RGB arrays, a system prompt, an API key and a JSON schema for the answer.
114
+ - `runtime.vlm.parse_boxes`: every box in an answer (Qwen JSON with labels, or text),
115
+ in the card's units and format, to level-0 px through the `Crop` it was read from.
116
+ - `runtime/local/vllm_offline.py` (`OfflineVlm`): offline batch generation with
117
+ vLLM's Python API, the only module that imports `vllm`. New `[vllm]` extra, not in
118
+ `[all]`: it needs its own Python 3.13 venv, which the workspace lock resolves as a
119
+ separate fork.
120
+ - `pathoinfer serve vllm MODEL`: the `vllm serve` command for a VLM folder, with dtype
121
+ and quantisation from the card and folder, `max_pixels`, and sizing from
122
+ `VllmServeConfig`.
123
+ - `stitch.heatmap.HeatmapStitcher`: tile classification to one probability vector per
124
+ tile core (overlap-area weighted), per-class float16 rasters, one QuPath detection per
125
+ core with `prob_<class>` measurements, optional thresholded region polygons and
126
+ optional Gaussian smoothing. Not yet wired into `pathoinfer run`.
127
+
128
+ ### Changed
129
+
130
+ - Segmentation regions now have a `score`: their `mean_probability` (the blended
131
+ probability of the region's class over its predicted pixels). GeoJSON writes it in
132
+ `measurements.score` for every task, and the Parquet `score` column is no longer null
133
+ for segmentation, so viewers that filter on `score` (patholamina, QuPath) can filter
134
+ regions. `mean_probability` stays. Output change: the summary's `mean_score` is now set
135
+ for segmentation, and `class_density(min_score=...)` now drops regions below it
136
+ instead of always counting them.
137
+ - Require patchology 0.1.1 (FastSlide 0.8.3+, which reads BIF, MRXS, iSyntax and TIFF
138
+ slides as OpenSlide does). CI and the Docker image pin patchology's `v0.1.1` commit.
139
+
140
+ - `convert trt --workspace-gb` no longer defaults to 4 GB: unset, TensorRT may use the
141
+ GPU's memory for tactics. 4 GB failed to build an FP32 HoVer-Net ("Could not find any
142
+ implementation"); with a cap set, that failure now says to raise it.
143
+ - Polygons are now the exact union of each region's pixels: areas equal pixel counts
144
+ and holes keep their corners (before, outlines came out 1-4% too large and every hole
145
+ lost a quarter pixel per corner). About 5x faster on noisy masks. **Segmentation
146
+ outputs change.**
147
+ - New `segmentation.connectivity` (8, default, or 4): whether parts touching only at a
148
+ pixel corner are one region. 8 matches the old grouping without its half-pixel joint.
149
+ - Smoothing cuts about a pixel per corner whatever the edge lengths (edges are split to
150
+ at most 4 px first); long straight edges no longer lose large corners. Smoothed
151
+ polygons have fewer vertices.
152
+ - The mask-to-polygon code moved from `stitch/segmentation.py` to `post/vectorise.py`
153
+ and is shared by segmentation and heatmaps.
154
+ - `[vlm-convert]` is `llmcompressor>=0.15` and `peft>=0.21.2`. llm-compressor caps
155
+ torch at 2.14.1 and transformers at 5.21.0, which holds the workspace lock there.
156
+ - Floors lowered for the `[vllm]` fork: torch to 2.14.0 and numpy to 2.4.6 (the main
157
+ environment still resolves torch 2.14.1 and numpy 2.5.4).
158
+ - The VLM parity gate reads boxes with `runtime.vlm.parse_boxes` (clipped to the image)
159
+ and its clients run `concurrency` requests at once.
160
+ - Extras: `[convert]` is now NVIDIA ModelOpt (>= 0.48), `onnx` and the helpers
161
+ ModelOpt's ONNX quantiser imports, listed without ModelOpt's own `[onnx]` pins so
162
+ onnxruntime-gpu 1.31 stays; `llmcompressor` moved to the new `[vlm-convert]`.
163
+
164
+ - `scripts/qc_overlay.py` draws like the run's overlay (`io.writers.overlay.render`): the
165
+ whole slide at `--mpp` (default 6), objects filled at `--alpha` (default 0.4) with
166
+ outlines and a class legend. The thumbnail and crops are gone, and `--thumbnail`,
167
+ `--crop`, `--downsample` and `--seed` with them.
168
+
169
+ ### Fixed
170
+
171
+ - Segmentation `finalize` was slow on large regions: `shape_borders` densified whole
172
+ polygons, and GEOS re-validates each one, which took 365 s on one 58k-hole region of a
173
+ real slide at 2 mpp. It now densifies their rings (0.1 s; the same vertices). On that
174
+ slide `finalize` went from about 400 s to 86 s; polygons are unchanged.
175
+ - `fill_holes` kept a region's own same-class islands inside the holes it filled (other
176
+ regions' islands were dropped). The result was an invalid MultiPolygon, which the slow
177
+ densify above had silently repaired; such islands are now dropped too.
178
+ - `convert fp16` let ONNX Runtime's converter clip weights above FP16's range (65504)
179
+ silently. HoVer-Net's decoder BatchNorms hold running variances up to 3e7, so its FP16
180
+ variant scaled them up to 22x and failed parity with F1 0. BatchNorms whose
181
+ parameters do not fit are now rewritten to the same affine map in a form that does
182
+ (mean 0, variance 1, epsilon 0); the FP16 HoVer-Net passes parity with F1 1.0. Any
183
+ other out-of-range weight feeding an FP16 op now raises, naming it and `--keep-fp32`.
184
+ - A failing `convert parity` on a large ONNX model could exhaust host memory: the
185
+ worst-layer report fetched every intermediate tensor of both graphs at once (60 GB for
186
+ HoVer-Net on 8 tiles). It now fetches them in groups of about 1 GB per graph, without
187
+ ONNX Runtime's CPU arena (11 GB peak for HoVer-Net), and reports the same layers.
188
+ - `serve triton-repo` copied only an ONNX model's graph, not its external weights, so
189
+ models over 2 GB failed to load in Triton. The files the graph references are now
190
+ copied beside it under the names it records (`registry.onnx_info.external_data_files`).
191
+
192
+ - The label map TIFF is a pyramid OpenSlide, fastslide and QuPath open. Its levels were
193
+ SubIFDs, which OpenSlide (and QuPath through it) does not see, so it read one level
194
+ and reported no pyramid; each level is now a top-level image. Label maps are 8-bit,
195
+ class ids with 255 where no tile reached (was int16 with -1): OpenSlide reads 16-bit
196
+ images as zeros. Breaking: the TIFF's dtype and no-data value change. QuPath opens
197
+ plain TIFFs with Bio-Formats, which sees one level; choose its OpenSlide reader
198
+ (`docs/qupath.md`).
199
+ - Segmentation post-processing is about twice as fast (95 s to 49 s on a 29,000-tile
200
+ slide at 6 mpp): band pieces merge with a coverage union, filling a hole drops its ring
201
+ instead of a union with the whole region, and only invalid polygons are repaired.
202
+ Outputs are unchanged.
203
+ - A simplified border could run through a junction where only other borders end, making
204
+ a ring touch itself; repairing that took 25 s on one large stroma polygon. Borders may
205
+ now touch only at ends they share.
206
+ - Segmentation polygons of neighbouring classes no longer overlap. Each polygon was
207
+ simplified and smoothed on its own, so the two copies of a shared border moved apart
208
+ (1% of the polygon area overlapped on a real slide); borders are now shaped once per
209
+ arc between junctions (`post.vectorise.shape_borders`). Polygon outputs change
210
+ slightly; the synthetic ellipse's area moves by 0.04%. `to_feature` is replaced by
211
+ `to_features`, which takes all pieces at once.
212
+ - The segmentation label TIFF now shows the same clean-up as the polygons: filled holes
213
+ take their class and regions under `min_area_um2` become background. It was the raw
214
+ argmax, so it held objects the GeoJSON did not. Small regions are decided once, on
215
+ their exact pixel area; a second check after smoothing, which dropped regions whose
216
+ smoothed outline dipped under the threshold, is gone, so slightly more small polygons
217
+ are kept. `fill_holes` returns the filled holes too, and `to_features` takes no
218
+ `min_area_um2`.
219
+ - `fill_holes` no longer fills a hole over another class's region that leaves the hole
220
+ through a pixel corner (with `connectivity` 8), which made classes overlap.
221
+ - `convert fp16` converts models over 2 GB (weights in a file beside the graph); it
222
+ failed with "Unable to parse proto" in ONNX's in-memory shape inference. Shapes are now
223
+ inferred from the file, and a large FP16 model is saved as `model.onnx` plus
224
+ `model.onnx.data`.
225
+ - `convert trt` builds models whose weights sit in a file beside the graph (ONNX
226
+ models over 2 GB); it failed with "Failed to import initializer". The plan cache key
227
+ now covers those weights, so a retrained model no longer reuses the old plan.
228
+
229
+ ## [0.1.0] - 2026-11-06
230
+
231
+ First release: segmentation and detection inference on whole slide images, from a model
232
+ folder to GeoJSON, Parquet and TIFF.
233
+
234
+ ### Added
235
+
236
+ - **Model contract.** ModelCard v1 for segmentation, detection and classification
237
+ models, with a published JSON Schema (`registry/schema/model_card.v1.json`). Models
238
+ load from a local folder or ONNX file, an MLflow registry (`models:/`, `[mlflow]`) or
239
+ the Hugging Face Hub (`hf://`, `[hf]`). ONNX files with only legacy `pathotrain`
240
+ metadata load with a deprecation warning.
241
+ - **CLI.** `pathoinfer run`, `validate`, `info model`, `info slide`, `card create` and
242
+ `card validate`, with `--log-level` and `-v`.
243
+ - **Run config.** One YAML per run: tiling, runtime, reader processes, stitching options,
244
+ outputs, slides (path, glob or `.txt`/`.csv`/`.parquet` list) and resume. Examples in
245
+ `examples/`.
246
+ - **Tiling** through patchology: tissue detection, a grid with tile cores that partition
247
+ the slide, parallel reader processes. Slides without a resolution are refused.
248
+ - **Runtimes.** ONNX Runtime (CPU, CUDA, TensorRT execution provider when available) and
249
+ PyTorch (`torch.export` and TorchScript, bf16/fp16 autocast), sharing one
250
+ preprocessing step driven by the ModelCard.
251
+ - **Segmentation stitching.** Gaussian-weighted blending of overlapping tiles, streamed
252
+ in bands; polygons with holes on pixel edges, merged across bands; simplification,
253
+ Chaikin smoothing (`smooth`), hole filling (`fill_holes_um2`) and small-object removal
254
+ (`min_area_um2`). Optional label-map raster.
255
+ - **Detection stitching.** Each detection is kept by the one tile whose core holds its
256
+ centre, so objects up to about the overlap are reported once; optional cross-tile NMS;
257
+ box or point output with class probabilities.
258
+ - **Outputs.** QuPath GeoJSON (`.geojson[.gz]`, optionally one file per class), Parquet
259
+ objects and per-class summary tables (WKB geometry, optional GeoParquet through DuckDB
260
+ with a pixel CRS), pyramidal TIFF label maps. Every output records the run metadata.
261
+ - **Engine.** Batch runs that load the model once, record failed slides and carry on,
262
+ resume finished slides by settings hash, and log one line per slide with stage
263
+ timings and peak memory; a batch summary Parquet and a run log per batch.
264
+ - **Analysis.** DuckDB queries over many slides' Parquet files returning Polars frames:
265
+ `class_density`, `score_histogram`.
266
+ - **Logging** with loguru through patchology's shared handler; `PATHOINFER_LOG_LEVEL`,
267
+ `set_log_level`, `add_file_sink`.
268
+ - **Tools.** `scripts/qc_overlay.py` (alignment check), `scripts/perf_report.py`
269
+ (per-stage throughput and bottleneck), `scripts/bench_read.py`,
270
+ `scripts/bench_infer.py`.
271
+ - **Docs.** README, `docs/model_contract.md`, `docs/outputs.md`, `docs/qupath.md`, and a
272
+ README per module.
273
+ - **CI.** Clean-environment install (patchology and pathoinfer only, CPU PyTorch), ruff,
274
+ mypy, CPU tests and a wheel build.
275
+
276
+ ### Not yet
277
+
278
+ - Tile classification runs (heatmaps): v0.2.
279
+ - Model conversion (FP16, INT8/FP8, TensorRT plans): v0.2.
280
+ - Serving and remote runtimes (Triton, vLLM): v0.3 and later.
281
+
282
+ [Unreleased]: https://github.com/twpkevin06222/pathoinfer/compare/v0.2.0...HEAD
283
+ [0.2.0]: https://github.com/twpkevin06222/pathoinfer/releases/tag/v0.2.0
284
+ [0.1.0]: https://github.com/twpkevin06222/pathoinfer/releases/tag/v0.1.0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.