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"])
|
||||
def predict():
|
||||
|
||||
def predict_fn_wrapper(pdf, return_dict):
|
||||
return_dict["result"] = predict_fn(pdf)
|
||||
|
||||
|
||||
@ -11,9 +11,7 @@ def process(predict_fn_wrapper):
|
||||
return_dict = manager.dict()
|
||||
p = multiprocessing.Process(
|
||||
target=predict_fn_wrapper,
|
||||
args=(
|
||||
return_dict,
|
||||
),
|
||||
args=(return_dict,),
|
||||
)
|
||||
p.start()
|
||||
p.join()
|
||||
|
||||
@ -12,7 +12,6 @@ logger = get_logger()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
def predict(pdf):
|
||||
# Keras model.predict stalls when model was loaded in different process
|
||||
# https://stackoverflow.com/questions/42504669/keras-tensorflow-and-multiprocessing-in-python
|
||||
|
||||
@ -67,4 +67,4 @@ def predictor():
|
||||
@pytest.fixture
|
||||
def test_pdf():
|
||||
with open("./test/test_data/f2dc689ca794fccb8cd38b95f2bf6ba9.pdf", "rb") as f:
|
||||
return f.read()
|
||||
return f.read()
|
||||
|
||||
@ -9,7 +9,18 @@ def test_predict_pdf_works(predictor, test_pdf):
|
||||
metadata = list(metadata)
|
||||
metadata = dict(**metadata[0])
|
||||
metadata.pop("document_filename") # temp filename cannot be tested
|
||||
assert metadata == {'px_width': 389.0, 'px_height': 389.0, '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}
|
||||
assert metadata == {
|
||||
"px_width": 389.0,
|
||||
"px_height": 389.0,
|
||||
"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