-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
155 lines (134 loc) · 3.56 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# LINTING
lint:
yapf -i src/*.py
# EVALUATE
ioueval:
python3 src/iou.py \
--iou 0.4 \
--area 0.8
deteval:
python3 src/deteval.py \
--tp 0.4 \
--tr 0.8
# TRAINING
train: lint
python3 src/train.py
cwd=$(CURDIR)
serve_dir=$(cwd)/model_store
img_path=$(cwd)/assets/foo18.jpg
model_path=$(cwd)/models/db_resnet18.pth
# model_path=./models/ctw_best_cp_1806.pth
# model_path=./models/quantized/db_resnet18_quantized.pth
thresh=0.25
box_thresh=0.50
unclip_ratio=1.5
device=cuda # cpu / cuda
# TESTING
test-heatmap:
python3 $(cwd)/src/test.py --image_path $(img_path) \
--model_path $(model_path) \
--device $(device) \
--heatmap True \
--is_output_polygon True \
--unclip_ratio $(unclip_ratio) \
--thresh $(thresh)
test-poly:
python3 $(cwd)/src/test.py --image_path $(img_path) \
--model_path $(model_path) \
--device $(device) \
--heatmap False \
--is_output_polygon True \
--unclip_ratio $(unclip_ratio) \
--thresh $(thresh) \
--box_thresh $(box_thresh)
test-rect:
python3 $(cwd)/src/test.py --image_path $(img_path) \
--model_path $(model_path) \
--device $(device) \
--heatmap False \
--is_output_polygon False \
--unclip_ratio $(unclip_ratio) \
--thresh $(thresh) \
--box_thresh $(box_thresh)
test-all: test-heatmap test-poly test-rect
# MODEL SERVING
model_name=dbtext
save-jit:
python3 $(cwd)/src/save_jit.py
save-trt:
python3 $(cwd)/src/save_trt.py
ts-archive:
torch-model-archiver \
--model-name $(model_name) \
--version 1.0 \
--serialized-file $(cwd)/models/db_resnet18_jit.pt \
--handler $(cwd)/src/db_handler.py \
--export-path $(serve_dir) -f
ts-start:
torchserve --start \
--model-store $(serve_dir) \
--models $(model_name)=dbtext.mar
ts-stop:
torchserve --stop
ts-restart: ts-stop ts-archive ts-start
ts-curl:
curl -X POST http://127.0.0.1:8080/predictions/$(model_name) -T $(cwd)/assets/foo.jpg
ts-request:
python3 $(cwd)/src/ts_request.py --image_path $(cwd)/assets/foo.jpg
### TEXT RECOGNITION
rect_model_path=$(cwd)/models/recognition/best_norm_ED.pth
# cropped char images
test-img:
python3 $(cwd)/src/test_ocr.py \
--device $(device) \
--img_path $(cwd)/tmp/reconized/word_10.jpg \
--workers 1 \
--batch_size 1 \
--saved_model $(rect_model_path) \
--Transformation None --FeatureExtraction ResNet \
--SequenceModeling BiLSTM --Prediction Attn
# cropped char images
test-folder:
python3 $(cwd)/src/test_ocr.py \
--device $(device) \
--img_folder $(cwd)/tmp/reconized \
--workers 1 \
--batch_size 1 \
--saved_model $(rect_model_path) \
--Transformation None --FeatureExtraction ResNet \
--SequenceModeling BiLSTM --Prediction Attn
### FULL PIPELINE
# detect --> recognize
test-pp:
python3 $(cwd)/src/test_ocr.py \
--device $(device) \
--img_path $(cwd)/assets/foo.jpg \
--out_path $(cwd)/tmp/ocr_04.jpg \
--workers 1 \
--batch_size 1 \
--det_model_path $(model_path) \
--saved_model $(rect_model_path) \
--Transformation None --FeatureExtraction ResNet \
--SequenceModeling BiLSTM --Prediction Attn
test-webcam:
python3 $(cwd)/src/test_webcam.py \
--show_video \
--per_frame 1 \
--device $(device) \
--workers 1 \
--batch_size 1 \
--det_model_path $(model_path) \
--saved_model $(rect_model_path) \
--Transformation None --FeatureExtraction ResNet \
--SequenceModeling BiLSTM --Prediction Attn
test-video:
python3 $(cwd)/src/test_webcam.py \
--video_path /home/phan.huy.hoang/testvideo.mp4 \
--per_frame 1 \
--device $(device) \
--workers 1 \
--batch_size 1 \
--det_model_path $(model_path) \
--saved_model $(rect_model_path) \
--Transformation None --FeatureExtraction ResNet \
--SequenceModeling BiLSTM --Prediction Attn