зеркало из
https://github.com/ssciwr/AMMICO.git
synced 2025-10-29 21:16:06 +02:00
* deleted lavis from utils * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixed test_objects * added 'not gcv' to CI * fixed multimodal search and summary tests * disable doc build on PR for now * restrict ipywidgets version to avoid dummycomm error * limit deepface version * original repositories for retinaface lavis * update gcv test results * update display test outputs * update test env * run all tests * wo xdist to avoid segfault * remove widgets ref * skip long-running tests * skip long * verbose codecov upload * refactor summary test 2 * finish summary test refactor * reduce memory overhead of SummaryDetector * remove VQA models from self * remove VQA models from self * update notebook for changes * update notebook for changes * fixed multimodal search tests * fixed tests in multimodal search after precommit * run all tests * update doc notebook for summary changes * skip long-running multimodal * exclude blip2 from testing --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Inga Ulusoy <inga.ulusoy@uni-heidelberg.de>
63 строки
2.2 KiB
Python
63 строки
2.2 KiB
Python
import misinformation.cropposts as crpo
|
|
import numpy as np
|
|
from PIL import Image
|
|
|
|
TEST_IMAGE_1 = "pic1.png"
|
|
TEST_IMAGE_2 = "pic2.png"
|
|
|
|
|
|
def test_matching_points(get_path):
|
|
ref_view = np.array(Image.open(get_path + TEST_IMAGE_2))
|
|
view = np.array(Image.open(get_path + TEST_IMAGE_1))
|
|
filtered_matches, _, _ = crpo.matching_points(ref_view, view)
|
|
assert len(filtered_matches) > 0
|
|
|
|
|
|
def test_kp_from_matches(get_path):
|
|
ref_view = np.array(Image.open(get_path + TEST_IMAGE_2))
|
|
view = np.array(Image.open(get_path + TEST_IMAGE_1))
|
|
filtered_matches, kp1, kp2 = crpo.matching_points(ref_view, view)
|
|
kp1, kp2 = crpo.kp_from_matches(filtered_matches, kp1, kp2)
|
|
|
|
assert kp1.shape[0] == len(filtered_matches)
|
|
assert kp2.shape[0] == len(filtered_matches)
|
|
assert kp1.shape[1] == 2
|
|
assert kp2.shape[1] == 2
|
|
|
|
|
|
def test_compute_crop_corner(get_path):
|
|
ref_view = np.array(Image.open(get_path + TEST_IMAGE_2))
|
|
view = np.array(Image.open(get_path + TEST_IMAGE_1))
|
|
filtered_matches, kp1, kp2 = crpo.matching_points(ref_view, view)
|
|
corner = crpo.compute_crop_corner(filtered_matches, kp1, kp2)
|
|
print(view.shape)
|
|
print(corner)
|
|
assert corner is not None
|
|
v, h = corner
|
|
assert 0 <= v < view.shape[0]
|
|
assert 0 <= h < view.shape[0]
|
|
|
|
|
|
def test_crop_posts_image(get_path):
|
|
ref_view = np.array(Image.open(get_path + TEST_IMAGE_2))
|
|
view = np.array(Image.open(get_path + TEST_IMAGE_1))
|
|
rte = crpo.crop_posts_image(ref_view, view)
|
|
assert rte is not None
|
|
crop_view, match_num = rte
|
|
assert match_num > 0
|
|
assert crop_view.shape[0] * crop_view.shape[1] <= view.shape[0] * view.shape[1]
|
|
|
|
|
|
def test_crop_posts_from_refs(get_path):
|
|
ref_view = np.array(Image.open(get_path + TEST_IMAGE_2))
|
|
view = np.array(Image.open(get_path + TEST_IMAGE_1))
|
|
ref_views = [ref_view]
|
|
crop_view = crpo.crop_posts_from_refs(ref_views, view)
|
|
assert crop_view.shape[0] * crop_view.shape[1] <= view.shape[0] * view.shape[1]
|
|
|
|
|
|
def test_get_file_list(get_path):
|
|
ref_list = []
|
|
ref_list = crpo.get_file_list(get_path, ref_list, ext="png")
|
|
assert len(ref_list) > 0
|