Re-export CRAFT as single .onnx file (fixes GPU acceleration)
Browse files- README.md +2 -17
- model.onnx +2 -2
README.md
CHANGED
|
@@ -21,8 +21,8 @@ Converted for use with [inference4j](https://github.com/inference4j/inference4j)
|
|
| 21 |
## Usage with inference4j
|
| 22 |
|
| 23 |
```java
|
| 24 |
-
try (
|
| 25 |
-
List<TextRegion> regions =
|
| 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(),
|
|
@@ -62,21 +62,6 @@ try (Craft craft = Craft.fromPretrained("models/craft-mlt-25k")) {
|
|
| 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 |
-
## Conversion
|
| 66 |
-
|
| 67 |
-
This model was converted from PyTorch to ONNX using [`craft_exporter.py`](craft_exporter.py) included in this repo. To reproduce:
|
| 68 |
-
|
| 69 |
-
```bash
|
| 70 |
-
# Download original PyTorch weights (~79 MB)
|
| 71 |
-
gdown 1Jk4eGD7crsqCCg9C9VjCLkMN3ze8kutZ -O craft_mlt_25k.pth
|
| 72 |
-
|
| 73 |
-
# Install dependencies
|
| 74 |
-
pip install torch torchvision onnx onnxruntime
|
| 75 |
-
|
| 76 |
-
# Export to ONNX
|
| 77 |
-
python craft_exporter.py
|
| 78 |
-
```
|
| 79 |
-
|
| 80 |
## Original Paper
|
| 81 |
|
| 82 |
> Baek, Y., Lee, B., Han, D., Yun, S., & Lee, H. (2019).
|
|
|
|
| 21 |
## Usage with inference4j
|
| 22 |
|
| 23 |
```java
|
| 24 |
+
try (CraftTextDetector detector = CraftTextDetector.builder().build()) {
|
| 25 |
+
List<TextRegion> regions = detector.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(),
|
|
|
|
| 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).
|
model.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:28c05f8b5e97f3c5765d00bca556ec2397c86c954d4ac5ef73aa10043db16388
|
| 3 |
+
size 83169398
|