Skip to content

Commit f0f01c9

Browse files
authored
Merge pull request #2954 from Wovchena/models/intel/handwritten-english-recognition-0001-fix-style
models/intel/handwritten-english-recognition-0001 fix style
2 parents 4012f2d + 97ce8e2 commit f0f01c9

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

ci/check-basics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def complain(message):
5151

5252
print('running miscellaneous checks...', flush=True)
5353

54-
if subprocess.run(['git', '--no-pager', 'diff', '--check', empty_tree_hash, '--'],
54+
if subprocess.run(['git', '--no-pager', 'diff', '--check', empty_tree_hash, '--', ':(exclude)data/dataset_classes/gnhk.txt'],
5555
cwd=OMZ_ROOT).returncode != 0:
5656
all_passed = False
5757

demos/handwritten_text_recognition_demo/python/handwritten_text_recognition_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def main():
9191
out_blob = args.output_blob
9292
else:
9393
assert len(net.outputs) == 1, "Demo supports only single output topologies"
94-
out_blob = next(iter(net.output_info))
94+
out_blob = next(iter(net.outputs))
9595

9696
characters = get_characters(args)
9797
codec = CTCCodec(characters, args.designated_characters, args.top_k)
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# This file can be used with the --list option of the model downloader.
2-
handwritten-japanese-recognition-0001
3-
handwritten-simplified-chinese-recognition-0001
4-
handwritten-english-recognition-0001
2+
handwritten-japanese-recognition-????
3+
handwritten-simplified-chinese-recognition-????
4+
# TODO
5+
# handwritten-english-recognition-????

models/intel/device_support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
| formula-recognition-polynomials-handwritten-0001-decoder | YES | YES | |
3535
| formula-recognition-polynomials-handwritten-0001-encoder | YES | YES | |
3636
| gaze-estimation-adas-0002 | YES | YES | YES |
37+
| handwritten-english-recognition-0001 | YES | YES | YES |
3738
| handwritten-japanese-recognition-0001 | YES | YES | YES |
3839
| handwritten-score-recognition-0003 | YES | YES | YES |
3940
| handwritten-simplified-chinese-recognition-0001 | YES | YES | YES |

models/intel/handwritten-english-recognition-0001/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The network is able to recognize English text consisting of characters in the [G
1818
| Accuracy on GNHK test subset (excluding images wider than 2000px after resized to height 96px with aspect ratio) | 81.5% |
1919
| Source framework | PyTorch\* |
2020

21-
> **Note:** to achieve the accuracy, images from the GNHK test set should be binarized using adaptive thresholding, and preprocessed into single-line text images, using the coordinates from the accompanying JSON annotation files in the GNHK dataset. See [preprocess_gnhk.py](./preprocess_gnhk.py).
21+
> **Note:** to achieve the accuracy, images from the GNHK test set should be binarized using adaptive thresholding, and preprocessed into single-line text images, using the coordinates from the accompanying JSON annotation files in the GNHK dataset. See `<omz_dir>/models/intel/handwritten-english-recognition-0001/preprocess_gnhk.py`.
2222
2323
This model adopts [label error rate](https://dl.acm.org/doi/abs/10.1145/1143844.1143891) as the metric for accuracy.
2424

models/intel/handwritten-english-recognition-0001/accuracy-check.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ models:
2828
metrics:
2929
- type: label_level_recognition_accuracy
3030
reference: 0.815
31-

models/intel/handwritten-english-recognition-0001/preprocess_gnhk.py

100644100755
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def main():
5656
line_indices = set(map(lambda obj: obj["line_idx"], data))
5757
img = cv2.imread(image, cv2.IMREAD_GRAYSCALE)
5858
img = binarize(img)
59-
for idx in sorted(list(line_indices)):
59+
for idx in sorted(line_indices):
6060
objects = list(filter(lambda obj: obj["line_idx"] == idx, data))
6161
# discard math symbols, scribbles, illegible text, and printed text
6262
objects = list(filter(lambda obj: obj["text"] != "%math%" and obj["text"] != "%SC%" and obj["text"] != "%NA%" and obj["type"] != "P", objects))
@@ -69,26 +69,26 @@ def main():
6969
# create mask for the words
7070
mask = np.zeros(img.shape[0:2], dtype=np.uint8)
7171
for obj in objects:
72-
region = [
73-
[obj["polygon"]["x0"], obj["polygon"]["y0"]],
74-
[obj["polygon"]["x1"], obj["polygon"]["y1"]],
75-
[obj["polygon"]["x2"], obj["polygon"]["y2"]],
76-
[obj["polygon"]["x3"], obj["polygon"]["y3"]]
77-
]
78-
points = np.array([region])
79-
cv2.drawContours(mask, [points], -1, (255, 255, 255), -1, cv2.LINE_AA)
72+
region = [
73+
[obj["polygon"]["x0"], obj["polygon"]["y0"]],
74+
[obj["polygon"]["x1"], obj["polygon"]["y1"]],
75+
[obj["polygon"]["x2"], obj["polygon"]["y2"]],
76+
[obj["polygon"]["x3"], obj["polygon"]["y3"]]
77+
]
78+
points = np.array([region])
79+
cv2.drawContours(mask, [points], -1, (255, 255, 255), -1, cv2.LINE_AA)
8080
masked = cv2.bitwise_and(img, img, mask = mask)
8181
bg = np.ones_like(img, np.uint8) * 255
8282
cv2.bitwise_not(bg, bg, mask = mask)
8383
overlay = bg + masked
8484
# crop bounding rectangle of the text region
85-
l = list(map(lambda obj: [
85+
polys = list(map(lambda obj: [
8686
[obj["polygon"]["x0"], obj["polygon"]["y0"]],
8787
[obj["polygon"]["x1"], obj["polygon"]["y1"]],
8888
[obj["polygon"]["x2"], obj["polygon"]["y2"]],
8989
[obj["polygon"]["x3"], obj["polygon"]["y3"]]
90-
], objects))
91-
flat = [item for sublist in l for item in sublist]
90+
], objects))
91+
flat = [item for sublist in polys for item in sublist]
9292
pts = np.array(flat)
9393
rect = cv2.boundingRect(pts)
9494
x, y, w, h = rect
@@ -107,4 +107,3 @@ def main():
107107

108108
if __name__ == '__main__':
109109
main()
110-

0 commit comments

Comments
 (0)