Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
00228775
Unverified
Commit
00228775
authored
Apr 24, 2021
by
littletomatodonkey
Committed by
GitHub
Apr 24, 2021
Browse files
fix hub post (#2613)
* fix hub serving for db post process * update hub serving config method
parent
c9841fe2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
8 deletions
+75
-8
deploy/hubserving/ocr_cls/module.py
deploy/hubserving/ocr_cls/module.py
+18
-2
deploy/hubserving/ocr_det/module.py
deploy/hubserving/ocr_det/module.py
+19
-2
deploy/hubserving/ocr_det/params.py
deploy/hubserving/ocr_det/params.py
+1
-0
deploy/hubserving/ocr_rec/module.py
deploy/hubserving/ocr_rec/module.py
+18
-2
deploy/hubserving/ocr_system/module.py
deploy/hubserving/ocr_system/module.py
+18
-2
deploy/hubserving/ocr_system/params.py
deploy/hubserving/ocr_system/params.py
+1
-0
No files found.
deploy/hubserving/ocr_cls/module.py
View file @
00228775
...
@@ -6,6 +6,7 @@ from __future__ import print_function
...
@@ -6,6 +6,7 @@ from __future__ import print_function
import
os
import
os
import
sys
import
sys
sys
.
path
.
insert
(
0
,
"."
)
sys
.
path
.
insert
(
0
,
"."
)
import
copy
from
paddlehub.common.logger
import
logger
from
paddlehub.common.logger
import
logger
from
paddlehub.module.module
import
moduleinfo
,
runnable
,
serving
from
paddlehub.module.module
import
moduleinfo
,
runnable
,
serving
...
@@ -14,6 +15,7 @@ import paddlehub as hub
...
@@ -14,6 +15,7 @@ import paddlehub as hub
from
tools.infer.utility
import
base64_to_cv2
from
tools.infer.utility
import
base64_to_cv2
from
tools.infer.predict_cls
import
TextClassifier
from
tools.infer.predict_cls
import
TextClassifier
from
tools.infer.utility
import
parse_args
@
moduleinfo
(
@
moduleinfo
(
...
@@ -28,8 +30,7 @@ class OCRCls(hub.Module):
...
@@ -28,8 +30,7 @@ class OCRCls(hub.Module):
"""
"""
initialize with the necessary elements
initialize with the necessary elements
"""
"""
from
ocr_cls.params
import
read_params
cfg
=
self
.
merge_configs
()
cfg
=
read_params
()
cfg
.
use_gpu
=
use_gpu
cfg
.
use_gpu
=
use_gpu
if
use_gpu
:
if
use_gpu
:
...
@@ -48,6 +49,21 @@ class OCRCls(hub.Module):
...
@@ -48,6 +49,21 @@ class OCRCls(hub.Module):
self
.
text_classifier
=
TextClassifier
(
cfg
)
self
.
text_classifier
=
TextClassifier
(
cfg
)
def
merge_configs
(
self
,
):
# deafult cfg
backup_argv
=
copy
.
deepcopy
(
sys
.
argv
)
sys
.
argv
=
sys
.
argv
[:
1
]
cfg
=
parse_args
()
from
ocr_det.params
import
read_params
update_cfg_map
=
vars
(
read_params
())
for
key
in
update_cfg_map
:
cfg
.
__setattr__
(
key
,
update_cfg_map
[
key
])
sys
.
argv
=
copy
.
deepcopy
(
backup_argv
)
return
cfg
def
read_images
(
self
,
paths
=
[]):
def
read_images
(
self
,
paths
=
[]):
images
=
[]
images
=
[]
for
img_path
in
paths
:
for
img_path
in
paths
:
...
...
deploy/hubserving/ocr_det/module.py
View file @
00228775
...
@@ -7,6 +7,8 @@ import os
...
@@ -7,6 +7,8 @@ import os
import
sys
import
sys
sys
.
path
.
insert
(
0
,
"."
)
sys
.
path
.
insert
(
0
,
"."
)
import
copy
from
paddlehub.common.logger
import
logger
from
paddlehub.common.logger
import
logger
from
paddlehub.module.module
import
moduleinfo
,
runnable
,
serving
from
paddlehub.module.module
import
moduleinfo
,
runnable
,
serving
import
cv2
import
cv2
...
@@ -15,6 +17,7 @@ import paddlehub as hub
...
@@ -15,6 +17,7 @@ import paddlehub as hub
from
tools.infer.utility
import
base64_to_cv2
from
tools.infer.utility
import
base64_to_cv2
from
tools.infer.predict_det
import
TextDetector
from
tools.infer.predict_det
import
TextDetector
from
tools.infer.utility
import
parse_args
@
moduleinfo
(
@
moduleinfo
(
...
@@ -29,8 +32,7 @@ class OCRDet(hub.Module):
...
@@ -29,8 +32,7 @@ class OCRDet(hub.Module):
"""
"""
initialize with the necessary elements
initialize with the necessary elements
"""
"""
from
ocr_det.params
import
read_params
cfg
=
self
.
merge_configs
()
cfg
=
read_params
()
cfg
.
use_gpu
=
use_gpu
cfg
.
use_gpu
=
use_gpu
if
use_gpu
:
if
use_gpu
:
...
@@ -49,6 +51,21 @@ class OCRDet(hub.Module):
...
@@ -49,6 +51,21 @@ class OCRDet(hub.Module):
self
.
text_detector
=
TextDetector
(
cfg
)
self
.
text_detector
=
TextDetector
(
cfg
)
def
merge_configs
(
self
,
):
# deafult cfg
backup_argv
=
copy
.
deepcopy
(
sys
.
argv
)
sys
.
argv
=
sys
.
argv
[:
1
]
cfg
=
parse_args
()
from
ocr_det.params
import
read_params
update_cfg_map
=
vars
(
read_params
())
for
key
in
update_cfg_map
:
cfg
.
__setattr__
(
key
,
update_cfg_map
[
key
])
sys
.
argv
=
copy
.
deepcopy
(
backup_argv
)
return
cfg
def
read_images
(
self
,
paths
=
[]):
def
read_images
(
self
,
paths
=
[]):
images
=
[]
images
=
[]
for
img_path
in
paths
:
for
img_path
in
paths
:
...
...
deploy/hubserving/ocr_det/params.py
View file @
00228775
...
@@ -22,6 +22,7 @@ def read_params():
...
@@ -22,6 +22,7 @@ def read_params():
cfg
.
det_db_box_thresh
=
0.5
cfg
.
det_db_box_thresh
=
0.5
cfg
.
det_db_unclip_ratio
=
1.6
cfg
.
det_db_unclip_ratio
=
1.6
cfg
.
use_dilation
=
False
cfg
.
use_dilation
=
False
cfg
.
det_db_score_mode
=
"fast"
# #EAST parmas
# #EAST parmas
# cfg.det_east_score_thresh = 0.8
# cfg.det_east_score_thresh = 0.8
...
...
deploy/hubserving/ocr_rec/module.py
View file @
00228775
...
@@ -6,6 +6,7 @@ from __future__ import print_function
...
@@ -6,6 +6,7 @@ from __future__ import print_function
import
os
import
os
import
sys
import
sys
sys
.
path
.
insert
(
0
,
"."
)
sys
.
path
.
insert
(
0
,
"."
)
import
copy
from
paddlehub.common.logger
import
logger
from
paddlehub.common.logger
import
logger
from
paddlehub.module.module
import
moduleinfo
,
runnable
,
serving
from
paddlehub.module.module
import
moduleinfo
,
runnable
,
serving
...
@@ -14,6 +15,7 @@ import paddlehub as hub
...
@@ -14,6 +15,7 @@ import paddlehub as hub
from
tools.infer.utility
import
base64_to_cv2
from
tools.infer.utility
import
base64_to_cv2
from
tools.infer.predict_rec
import
TextRecognizer
from
tools.infer.predict_rec
import
TextRecognizer
from
tools.infer.utility
import
parse_args
@
moduleinfo
(
@
moduleinfo
(
...
@@ -28,8 +30,7 @@ class OCRRec(hub.Module):
...
@@ -28,8 +30,7 @@ class OCRRec(hub.Module):
"""
"""
initialize with the necessary elements
initialize with the necessary elements
"""
"""
from
ocr_rec.params
import
read_params
cfg
=
self
.
merge_configs
()
cfg
=
read_params
()
cfg
.
use_gpu
=
use_gpu
cfg
.
use_gpu
=
use_gpu
if
use_gpu
:
if
use_gpu
:
...
@@ -48,6 +49,21 @@ class OCRRec(hub.Module):
...
@@ -48,6 +49,21 @@ class OCRRec(hub.Module):
self
.
text_recognizer
=
TextRecognizer
(
cfg
)
self
.
text_recognizer
=
TextRecognizer
(
cfg
)
def
merge_configs
(
self
,
):
# deafult cfg
backup_argv
=
copy
.
deepcopy
(
sys
.
argv
)
sys
.
argv
=
sys
.
argv
[:
1
]
cfg
=
parse_args
()
from
ocr_det.params
import
read_params
update_cfg_map
=
vars
(
read_params
())
for
key
in
update_cfg_map
:
cfg
.
__setattr__
(
key
,
update_cfg_map
[
key
])
sys
.
argv
=
copy
.
deepcopy
(
backup_argv
)
return
cfg
def
read_images
(
self
,
paths
=
[]):
def
read_images
(
self
,
paths
=
[]):
images
=
[]
images
=
[]
for
img_path
in
paths
:
for
img_path
in
paths
:
...
...
deploy/hubserving/ocr_system/module.py
View file @
00228775
...
@@ -6,6 +6,7 @@ from __future__ import print_function
...
@@ -6,6 +6,7 @@ from __future__ import print_function
import
os
import
os
import
sys
import
sys
sys
.
path
.
insert
(
0
,
"."
)
sys
.
path
.
insert
(
0
,
"."
)
import
copy
import
time
import
time
...
@@ -17,6 +18,7 @@ import paddlehub as hub
...
@@ -17,6 +18,7 @@ import paddlehub as hub
from
tools.infer.utility
import
base64_to_cv2
from
tools.infer.utility
import
base64_to_cv2
from
tools.infer.predict_system
import
TextSystem
from
tools.infer.predict_system
import
TextSystem
from
tools.infer.utility
import
parse_args
@
moduleinfo
(
@
moduleinfo
(
...
@@ -31,8 +33,7 @@ class OCRSystem(hub.Module):
...
@@ -31,8 +33,7 @@ class OCRSystem(hub.Module):
"""
"""
initialize with the necessary elements
initialize with the necessary elements
"""
"""
from
ocr_system.params
import
read_params
cfg
=
self
.
merge_configs
()
cfg
=
read_params
()
cfg
.
use_gpu
=
use_gpu
cfg
.
use_gpu
=
use_gpu
if
use_gpu
:
if
use_gpu
:
...
@@ -51,6 +52,21 @@ class OCRSystem(hub.Module):
...
@@ -51,6 +52,21 @@ class OCRSystem(hub.Module):
self
.
text_sys
=
TextSystem
(
cfg
)
self
.
text_sys
=
TextSystem
(
cfg
)
def
merge_configs
(
self
,
):
# deafult cfg
backup_argv
=
copy
.
deepcopy
(
sys
.
argv
)
sys
.
argv
=
sys
.
argv
[:
1
]
cfg
=
parse_args
()
from
ocr_det.params
import
read_params
update_cfg_map
=
vars
(
read_params
())
for
key
in
update_cfg_map
:
cfg
.
__setattr__
(
key
,
update_cfg_map
[
key
])
sys
.
argv
=
copy
.
deepcopy
(
backup_argv
)
return
cfg
def
read_images
(
self
,
paths
=
[]):
def
read_images
(
self
,
paths
=
[]):
images
=
[]
images
=
[]
for
img_path
in
paths
:
for
img_path
in
paths
:
...
...
deploy/hubserving/ocr_system/params.py
View file @
00228775
...
@@ -22,6 +22,7 @@ def read_params():
...
@@ -22,6 +22,7 @@ def read_params():
cfg
.
det_db_box_thresh
=
0.5
cfg
.
det_db_box_thresh
=
0.5
cfg
.
det_db_unclip_ratio
=
1.6
cfg
.
det_db_unclip_ratio
=
1.6
cfg
.
use_dilation
=
False
cfg
.
use_dilation
=
False
cfg
.
det_db_score_mode
=
"fast"
#EAST parmas
#EAST parmas
cfg
.
det_east_score_thresh
=
0.8
cfg
.
det_east_score_thresh
=
0.8
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment