Upload CRAFT MLT 25K ONNX model
Browse files- .gitattributes +1 -0
- README.md +73 -0
- model.onnx +3 -0
- model.onnx.data +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
model.onnx.data filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: onnx
|
| 3 |
+
tags:
|
| 4 |
+
- text-detection
|
| 5 |
+
- craft
|
| 6 |
+
- onnx
|
| 7 |
+
- inference4j
|
| 8 |
+
license: mit
|
| 9 |
+
datasets:
|
| 10 |
+
- SynthText
|
| 11 |
+
- IC13
|
| 12 |
+
- IC17
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# CRAFT Text Detection (MLT 25K) — ONNX
|
| 16 |
+
|
| 17 |
+
ONNX export of [CRAFT](https://github.com/clovaai/CRAFT-pytorch) (Character Region Awareness for Text Detection) trained on SynthText + IC13/IC17 (MLT 25K variant).
|
| 18 |
+
|
| 19 |
+
Converted for use with [inference4j](https://github.com/inference4j/inference4j), an inference-only AI library for Java.
|
| 20 |
+
|
| 21 |
+
## Usage with inference4j
|
| 22 |
+
|
| 23 |
+
```java
|
| 24 |
+
try (Craft craft = Craft.fromPretrained("models/craft-mlt-25k")) {
|
| 25 |
+
List<TextRegion> regions = craft.detect(Path.of("document.jpg"));
|
| 26 |
+
for (TextRegion r : regions) {
|
| 27 |
+
System.out.printf("Text at [%.0f, %.0f, %.0f, %.0f] (confidence=%.2f)%n",
|
| 28 |
+
r.box().x1(), r.box().y1(), r.box().x2(), r.box().y2(),
|
| 29 |
+
r.confidence());
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
## Model Details
|
| 35 |
+
|
| 36 |
+
| Property | Value |
|
| 37 |
+
|----------|-------|
|
| 38 |
+
| Architecture | VGG16-BN backbone + U-Net decoder |
|
| 39 |
+
| Task | Text detection (character-level region + affinity maps) |
|
| 40 |
+
| Training data | SynthText + ICDAR 2013/2017 (MLT) |
|
| 41 |
+
| Weights | `craft_mlt_25k.pth` from [clovaai/CRAFT-pytorch](https://github.com/clovaai/CRAFT-pytorch) |
|
| 42 |
+
| ONNX opset | 17 |
|
| 43 |
+
| Input | `[batch, 3, height, width]` — RGB, ImageNet-normalized, dimensions must be multiples of 32 |
|
| 44 |
+
| Output: score_map | `[batch, height/2, width/2, 2]` — channel 0: region score, channel 1: affinity score |
|
| 45 |
+
| Output: feature_map | `[batch, 32, height/2, width/2]` — intermediate features (optional, for refinement) |
|
| 46 |
+
| Dynamic axes | Batch, height, and width are dynamic |
|
| 47 |
+
|
| 48 |
+
## Preprocessing
|
| 49 |
+
|
| 50 |
+
1. Resize maintaining aspect ratio (long side to target size, e.g. 1280)
|
| 51 |
+
2. Round both dimensions to nearest multiple of 32
|
| 52 |
+
3. ImageNet normalization: `(pixel / 255 - mean) / std`
|
| 53 |
+
- mean = `[0.485, 0.456, 0.406]`
|
| 54 |
+
- std = `[0.229, 0.224, 0.225]`
|
| 55 |
+
4. NCHW layout: `[1, 3, H, W]`
|
| 56 |
+
|
| 57 |
+
## Postprocessing
|
| 58 |
+
|
| 59 |
+
1. Combine: `clip(region_score + affinity_score, 0, 1)`
|
| 60 |
+
2. Binary threshold at `low_text_threshold` (default 0.4)
|
| 61 |
+
3. Connected component labeling (4-connectivity)
|
| 62 |
+
4. For each component: compute mean region score, filter by `text_threshold` (default 0.7)
|
| 63 |
+
5. Extract axis-aligned bounding box, scale back to original image coordinates
|
| 64 |
+
|
| 65 |
+
## Original Paper
|
| 66 |
+
|
| 67 |
+
> Baek, Y., Lee, B., Han, D., Yun, S., & Lee, H. (2019).
|
| 68 |
+
> Character Region Awareness for Text Detection.
|
| 69 |
+
> CVPR 2019. [arXiv:1904.01941](https://arxiv.org/abs/1904.01941)
|
| 70 |
+
|
| 71 |
+
## License
|
| 72 |
+
|
| 73 |
+
The original CRAFT model weights are released under the MIT License by Clova AI Research (NAVER Corp).
|
model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b0773559ece3671df618d660e68782406ccfb830c18281664b453e5fe97c95bb
|
| 3 |
+
size 132927
|
model.onnx.data
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ae9997d6c9b185c7eae07c338eef1a1ada086602c287b9a46dd5e6ac0c47295e
|
| 3 |
+
size 83099648
|