Views
No views yet
mayocream/koharu-layout-rfdetr-seg-2xl-1152.
It predicts bounding boxes and instance masks for manga page layout analysis.| ID | Class |
|---|---|
| 0 | text |
| 1 | onomatopoeia |
| 2 | bubble |
| 3 | panel |
rfdetr-seg-2xlarge.onnx — static-batch FP32 ONNX graph, opset 17onnx_config.json — tensor, preprocessing, class, and threshold contractonnx_validation.json — PyTorch/ONNX Runtime parity reportpip install huggingface_hub numpy onnxruntime pillow1from huggingface_hub import hf_hub_download
2from PIL import Image
3import numpy as np
4import onnxruntime as ort
5
6repo_id = "ShiniShiho/koharu-layout-rfdetr-seg-2xl-1152-onnx"
7model_path = hf_hub_download(repo_id=repo_id, filename="rfdetr-seg-2xlarge.onnx")
8session = ort.InferenceSession(model_path)
9
10image = Image.open("page.jpg").convert("RGB")
11array = np.asarray(
12 image.resize((1152, 1152), Image.Resampling.BILINEAR),
13 dtype=np.float32,
14) / 255.0
15array = (array - np.asarray([0.485, 0.456, 0.406], dtype=np.float32)) / np.asarray(
16 [0.229, 0.224, 0.225], dtype=np.float32
17)
18input_tensor = array.transpose(2, 0, 1)[None].astype(np.float32)
19
20boxes_cxcywh, class_logits, mask_logits = session.run(
21 ["dets", "labels", "masks"],
22 {"input": input_tensor},
23)
24class_scores = 1.0 / (1.0 + np.exp(-class_logits[..., :4]))
25class_ids = class_scores.argmax(axis=-1)
26confidences = class_scores.max(axis=-1)float32 NCHW input shape of [1, 3, 1152, 1152].
dets contains 300 normalized cx, cy, width, height boxes. labels
contains four class logits plus a final no-object channel; apply sigmoid to the
first four channels. masks contains 300 masks at 288 × 288; resize mask logits
bilinearly to the target image size and threshold at zero.2.25e-50.999799bf6d2cbd7793c956d8c857bb1672a396eb7f100eb0682f86830d05e31168efb7cc10d4316371946b8441da3512261a8e148b129abcdb0ea6235ed1d1d06d351rfdetr==1.7.0, ONNX opset 17, and a static batch size of 1.
See onnx_validation.json for environment and raw-output error statistics.other license designation; users are
responsible for complying with Manga109 and third-party content terms.