Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
周伟奇
/
part_of_F3_OCR
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
d0995b37
authored
2022-07-14 11:45:01 +0800
by
Lyu Kui
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
modify locustfile
1 parent
a33165ce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
async_test/classification/model.py
async_test/locustfile.py
async_test/server2.py
async_test/classification/model.py
View file @
d0995b3
...
...
@@ -28,7 +28,7 @@ class F3Classification:
res
=
{
'label'
:
label
,
'confidence'
:
confidence
'confidence'
:
float
(
confidence
)
}
return
res
...
...
async_test/locustfile.py
View file @
d0995b3
...
...
@@ -13,4 +13,11 @@ class QuickstartUser(HttpUser):
@tag
(
'async'
)
@task
def
async_test
(
self
):
self
.
client
.
get
(
"/async"
)
\ No newline at end of file
self
.
client
.
get
(
"/async"
)
@tag
(
'sync_classification'
)
@task
def
sync_classification
(
self
):
img_path
=
'/home/lk/MyProject/BMW_F3OCR/数据集/文件分类/营业执照/授信资料-43.jpg'
files
=
[(
'image'
,
(
''
,
open
(
img_path
,
'rb'
),
''
))]
self
.
client
.
post
(
"/sync_classification"
,
files
=
files
)
...
...
async_test/server2.py
View file @
d0995b3
import
grpc
import
os
import
cv2
import
grpc
import
numpy
as
np
import
tensorflow
as
tf
from
tensorflow_serving.apis
import
prediction_service_pb2_grpc
,
predict_pb2
...
...
@@ -8,6 +9,7 @@ from sanic import Sanic
from
sanic.response
import
json
from
classification
import
classifier
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
'-1'
app
=
Sanic
(
"async_test"
)
...
...
@@ -15,7 +17,7 @@ app = Sanic("async_test")
tf_serving_settings
=
{
'servers'
:
{
'server_1'
:
{
'host'
:
'
192.168.10.191
'
,
'host'
:
'
localhost
'
,
'port'
:
'8500'
,
'options'
:
[
(
'grpc.max_send_message_length'
,
1000
*
1024
*
1024
),
...
...
@@ -40,7 +42,7 @@ async def sync_handler(request):
request
=
predict_pb2
.
PredictRequest
()
request
.
model_spec
.
name
=
classifier
.
model_name
request
.
model_spec
.
signature_name
=
classifier
.
signature_name
stub
=
getattr
(
app
.
ctx
,
classifier
.
server_name
)
stub
=
getattr
(
app
,
classifier
.
server_name
)
request
.
inputs
[
'input_1'
]
.
CopyFrom
(
tf
.
make_tensor_proto
(
input_images
))
result
=
stub
.
Predict
(
request
,
100.0
)
# 100 secs timeout
...
...
@@ -63,7 +65,7 @@ async def set_grpc_channel(app, loop):
'{0}:{1}'
.
format
(
server_settings
[
'host'
],
server_settings
[
'port'
]),
options
=
server_settings
.
get
(
'options'
))
stub
=
prediction_service_pb2_grpc
.
PredictionServiceStub
(
channel
)
setattr
(
app
.
ctx
,
server_name
,
stub
)
setattr
(
app
,
server_name
,
stub
)
if
__name__
==
'__main__'
:
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment