Skip to content

Commit 41735b3

Browse files
committed
[C] Update READMEs
1 parent 1d9f0ec commit 41735b3

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,46 @@ For more details, please refer to the [**DocClassifier Documents**](https://docs
6868
pip install dist/docclassifier_docsaid-*-py3-none-any.whl
6969
```
7070

71+
## Inference
72+
73+
> [!TIP]
74+
> We have designed an automatic model download feature. When the program detects that you are missing the model, it will automatically connect to our server to download it.
75+
76+
Here is a simple example:
77+
78+
```python
79+
import cv2
80+
from skimage import io
81+
from docclassifier import DocClassifier
82+
83+
img = io.imread('https://github.com/DocsaidLab/DocClassifier/blob/main/docs/test_driver.jpg?raw=true')
84+
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
85+
86+
model = DocClassifier()
87+
88+
most_similar, max_score = model(img)
89+
print(f'most_similar: {most_similar}, max_score: {max_score:.4f}')
90+
# >>> most_similar: None, max_score: 0.0000
91+
```
92+
93+
By default, this example returns `None` and `0.0000` because the difference between our default registration data and the input image is significant. Therefore, the model finds the similarity between the image and the registration data to be very low.
94+
95+
In this case, you may consider lowering the `threshold` parameter:
96+
97+
```python
98+
model = DocClassifier(
99+
threshold=0.6
100+
)
101+
102+
# Re-run the inference
103+
most_similar, max_score = model(img)
104+
print(f'most_similar: {most_similar}, max_score: {max_score:.4f}')
105+
# >>> most_similar: Taiwan driver's license front, max_score: 0.6116
106+
```
107+
108+
> [!TIP]
109+
> MRZScanner has been encapsulated with `__call__`, so you can directly call the instance for inference.
110+
71111
## Model Design
72112

73113
Creating a comprehensive model involves multiple adjustments and design iterations.

README_tw.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,50 @@ DocClassifier 是一個基於 Metric Learning 技術的文件圖像分類系統
6868
pip install dist/docclassifier_docsaid-*-py3-none-any.whl
6969
```
7070

71+
## 模型推論
72+
73+
> [!TIP]
74+
> 我們有設計了自動下載模型的功能,當程式檢查你缺少模型時,會自動連接到我們的伺服器進行下載。
75+
76+
確保註冊資料已經準備好之後,我們就可以開始進行模型推論。
77+
78+
以下是一個簡單的範例:
79+
80+
```python
81+
import cv2
82+
from skimage import io
83+
from docclassifier import DocClassifier
84+
85+
img = io.imread('https://github.com/DocsaidLab/DocClassifier/blob/main/docs/test_driver.jpg?raw=true')
86+
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
87+
88+
model = DocClassifier()
89+
90+
most_similar, max_score = model(img)
91+
print(f'most_similar: {most_similar}, max_score: {max_score:.4f}')
92+
# >>> most_similar: None, max_score: 0.0000
93+
```
94+
95+
在預設的情況下,這個範例會返回 `None``0.0000`,這是因為我們預設的註冊資料和輸入圖片差異非常大。因此模型判斷這張圖片和註冊資料之間的相似性非常低。
96+
97+
這種時候你可以考慮降低 `threshold` 參數:
98+
99+
```python
100+
model = DocClassifier(
101+
threshold=0.6
102+
)
103+
104+
# 重新進行推論
105+
most_similar, max_score = model(img)
106+
print(f'most_similar: {most_similar}, max_score: {max_score:.4f}')
107+
# >>> most_similar: 台灣駕照正面, max_score: 0.6116
108+
```
109+
110+
這次你就會得到一個標籤名稱和一個分數:`台灣駕照正面``0.6116`。這個分數代表了輸入圖片和註冊資料之間的相似性。
111+
112+
> [!TIP]
113+
> DocClassifier 已經用 `__call__` 進行了封裝,因此你可以直接呼叫實例進行推論。
114+
71115
## 模型設計
72116

73117
一個較為完整的模型功能,都不是一蹴可幾的,中間必須經過多次的調整和設計。

0 commit comments

Comments
 (0)