from pathlib import Path from funcy import first from image_prediction.config import CONFIG from image_prediction.pipeline import load_pipeline def test_image_classification_does_not_regress(): """See RED-9948: the predictions unexpectedly changed for some images. In the end the issue is the tensorflow version. We ensure that the prediction of the image with the hash FA30F080F0C031CE17E8CF237 is inconclusive, and that the flag all_passed is false.""" pdf_path = Path(__file__).parents[1] / "data" / "RED-9948" / "SYNGENTA_EFSA_sanitisation_GFL_v2.pdf" pdf_bytes = pdf_path.read_bytes() pipeline = load_pipeline(verbose=True, batch_size=CONFIG.service.batch_size) predictions = list(pipeline(pdf_bytes)) predictions = first([x for x in predictions if x["representation"] == "FA30F080F0C031CE17E8CF237"]) assert predictions["filters"]["allPassed"] is False assert predictions["filters"]["probability"]["unconfident"] is True