From b9ef52107b81bf043cdd0119c43768a162d07f43 Mon Sep 17 00:00:00 2001 From: Petr Andriushchenko Date: Mon, 27 Feb 2023 15:28:26 +0100 Subject: [PATCH] fixed opencv version --- misinformation/test/test_summary.py | 30 ++++++++++++++--------------- pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/misinformation/test/test_summary.py b/misinformation/test/test_summary.py index fde1045..c2981b9 100644 --- a/misinformation/test/test_summary.py +++ b/misinformation/test/test_summary.py @@ -38,14 +38,6 @@ def test_analyse_image(): id_ = os.path.splitext(os.path.basename(img_path))[0] mydict[id_] = {"filename": img_path} - summary_device = device("cuda" if cuda.is_available() else "cpu") - summary_model, summary_vis_processors, _ = load_model_and_preprocess( - name="blip_caption", - model_type="base_coco", - is_eval=True, - device=summary_device, - ) - for key in mydict: mydict[key] = sm.SummaryDetector(mydict[key]).analyse_image() keys = list(mydict.keys()) @@ -90,6 +82,17 @@ def test_analyse_image(): "a person running on a beach near a rock formation" ) + del sm.SummaryDetector.summary_model, sm.SummaryDetector.summary_vis_processors + cuda.empty_cache() + + summary_device = device("cuda" if cuda.is_available() else "cpu") + summary_model, summary_vis_processors, _ = load_model_and_preprocess( + name="blip_caption", + model_type="base_coco", + is_eval=True, + device=summary_device, + ) + for key in mydict: mydict[key] = sm.SummaryDetector(mydict[key]).analyse_image( summary_model, summary_vis_processors @@ -136,6 +139,9 @@ def test_analyse_image(): "a person running on a beach near a rock formation" ) + del summary_model, summary_vis_processors + cuda.empty_cache() + summary_model, summary_vis_processors, _ = load_model_and_preprocess( name="blip_caption", model_type="large_coco", @@ -210,14 +216,6 @@ def test_analyse_questions(): id_ = os.path.splitext(os.path.basename(img_path))[0] mydict[id_] = {"filename": img_path} - summary_device = device("cuda" if cuda.is_available() else "cpu") - ( - summary_VQA_model, - summary_VQA_vis_processors, - summary_VQA_txt_processors, - ) = load_model_and_preprocess( - name="blip_vqa", model_type="vqav2", is_eval=True, device=summary_device - ) list_of_questions = [ "How many persons on the picture?", "What happends on the picture?", diff --git a/pyproject.toml b/pyproject.toml index 65f5b43..b138efe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dependencies = [ "pytest-cov", "matplotlib", "pytest", - "opencv-contrib-python", + "opencv-contrib-python <= 4.6", "googletrans==3.1.0a0", "spacy", "jupyterlab",