blacckkkyykykykyk
This commit is contained in:
parent
4c9e6c38bd
commit
1776e3083c
@ -26,7 +26,6 @@ def make_prediction_server(predict_fn: Callable):
|
|||||||
|
|
||||||
@app.route("/", methods=["POST"])
|
@app.route("/", methods=["POST"])
|
||||||
def predict():
|
def predict():
|
||||||
|
|
||||||
def predict_fn_wrapper(pdf, return_dict):
|
def predict_fn_wrapper(pdf, return_dict):
|
||||||
return_dict["result"] = predict_fn(pdf)
|
return_dict["result"] = predict_fn(pdf)
|
||||||
|
|
||||||
|
|||||||
@ -11,9 +11,7 @@ def process(predict_fn_wrapper):
|
|||||||
return_dict = manager.dict()
|
return_dict = manager.dict()
|
||||||
p = multiprocessing.Process(
|
p = multiprocessing.Process(
|
||||||
target=predict_fn_wrapper,
|
target=predict_fn_wrapper,
|
||||||
args=(
|
args=(return_dict,),
|
||||||
return_dict,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
p.start()
|
p.start()
|
||||||
p.join()
|
p.join()
|
||||||
|
|||||||
@ -12,7 +12,6 @@ logger = get_logger()
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
def predict(pdf):
|
def predict(pdf):
|
||||||
# Keras model.predict stalls when model was loaded in different process
|
# Keras model.predict stalls when model was loaded in different process
|
||||||
# https://stackoverflow.com/questions/42504669/keras-tensorflow-and-multiprocessing-in-python
|
# https://stackoverflow.com/questions/42504669/keras-tensorflow-and-multiprocessing-in-python
|
||||||
|
|||||||
@ -9,7 +9,18 @@ def test_predict_pdf_works(predictor, test_pdf):
|
|||||||
metadata = list(metadata)
|
metadata = list(metadata)
|
||||||
metadata = dict(**metadata[0])
|
metadata = dict(**metadata[0])
|
||||||
metadata.pop("document_filename") # temp filename cannot be tested
|
metadata.pop("document_filename") # temp filename cannot be tested
|
||||||
assert metadata == {'px_width': 389.0, 'px_height': 389.0, 'width': 194.49999000000003,
|
assert metadata == {
|
||||||
'height': 194.49998999999997, 'x1': 320.861, 'x2': 515.36099, 'y1': 347.699, 'y2': 542.19899,
|
"px_width": 389.0,
|
||||||
'page_width': 595.2800000000001, 'page_height': 841.89, 'page_rotation': 0, 'page_idx': 1,
|
"px_height": 389.0,
|
||||||
'n_pages': 3}
|
"width": 194.49999000000003,
|
||||||
|
"height": 194.49998999999997,
|
||||||
|
"x1": 320.861,
|
||||||
|
"x2": 515.36099,
|
||||||
|
"y1": 347.699,
|
||||||
|
"y2": 542.19899,
|
||||||
|
"page_width": 595.2800000000001,
|
||||||
|
"page_height": 841.89,
|
||||||
|
"page_rotation": 0,
|
||||||
|
"page_idx": 1,
|
||||||
|
"n_pages": 3,
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user