Skip to content

Commit

Permalink
feat: webp support
Browse files Browse the repository at this point in the history
  • Loading branch information
yurijmikhalevich committed Jun 9, 2024
1 parent f17cfd3 commit 64cd297
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 9 deletions.
2 changes: 1 addition & 1 deletion rclip/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def is_image_meta_equal(image: db.Image, meta: ImageMeta) -> bool:

class RClip:
EXCLUDE_DIRS_DEFAULT = ['@eaDir', 'node_modules', '.git']
IMAGE_REGEX = re.compile(r'^.+\.(jpe?g|png)$', re.I)
IMAGE_REGEX = re.compile(r'^.+\.(jpe?g|png|webp)$', re.I)
DB_IMAGES_BEFORE_COMMIT = 50_000

class SearchResult(NamedTuple):
Expand Down
Binary file added tests/e2e/images/tree.webp
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ score filepath
0.245 "<test_images_dir>cautious cat.jpg"
0.241 "<test_images_dir>black kitty.jpg"
0.236 "<test_images_dir>cat.jpg"
0.193 "<test_images_dir>tree.webp"
0.185 "<test_images_dir>cake.jpg"
0.182 "<test_images_dir>camera.jpg"
0.181 "<test_images_dir>chessboard with rocks.JPG"
0.174 "<test_images_dir>books.jpg"
0.165 "<test_images_dir>camera lens.jpg"
2 changes: 1 addition & 1 deletion tests/e2e/output_snapshots/test_add_queries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ score filepath
0.877 "<test_images_dir>cautious cat.jpg"
0.841 "<test_images_dir>cat.jpg"
0.822 "<test_images_dir>black kitty.jpg"
0.785 "<test_images_dir>tree.webp"
0.774 "<test_images_dir>chessboard with rocks.JPG"
0.744 "<test_images_dir>camera.jpg"
0.722 "<test_images_dir>boats on a lake.jpg"
0.717 "<test_images_dir>cake.jpg"
0.713 "<test_images_dir>bee.jpg"
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
score filepath
0.046 "<test_images_dir>bee.jpg"
-0.032 "<test_images_dir>tree.webp"
-0.045 "<test_images_dir>camera lens.jpg"
-0.065 "<test_images_dir>cake.jpg"
-0.088 "<test_images_dir>camera.jpg"
Expand All @@ -8,4 +9,3 @@ score filepath
-0.123 "<test_images_dir>boats on a lake.jpg"
-0.190 "<test_images_dir>black cat at night.jpg"
-0.202 "<test_images_dir>cautious cat.jpg"
-0.225 "<test_images_dir>black cat sleeping on a chair.JPG"
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ score filepath
0.482 "<test_images_dir>cake.jpg"
0.471 "<test_images_dir>chessboard with rocks.JPG"
0.449 "<test_images_dir>black kitty.jpg"
0.448 "<test_images_dir>tree.webp"
0.403 "<test_images_dir>camera.jpg"
0.396 "<test_images_dir>black cat sleeping on a chair.JPG"
0.386 "<test_images_dir>books.jpg"
0.379 "<test_images_dir>boats on a lake.jpg"
0.367 "<test_images_dir>black cat at night.jpg"
0.361 "<test_images_dir>camera lens.jpg"
2 changes: 1 addition & 1 deletion tests/e2e/output_snapshots/test_query_multipliers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ score filepath
0.582 "<test_images_dir>cat.jpg"
0.579 "<test_images_dir>black kitty.jpg"
0.535 "<test_images_dir>cautious cat.jpg"
0.487 "<test_images_dir>tree.webp"
0.472 "<test_images_dir>chessboard with rocks.JPG"
0.472 "<test_images_dir>camera.jpg"
0.467 "<test_images_dir>cake.jpg"
0.436 "<test_images_dir>boats on a lake.jpg"
0.431 "<test_images_dir>books.jpg"
2 changes: 1 addition & 1 deletion tests/e2e/output_snapshots/test_search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ score filepath
0.248 "<test_images_dir>cat.jpg"
0.247 "<test_images_dir>black kitty.jpg"
0.244 "<test_images_dir>cautious cat.jpg"
0.184 "<test_images_dir>tree.webp"
0.178 "<test_images_dir>camera.jpg"
0.175 "<test_images_dir>cake.jpg"
0.171 "<test_images_dir>chessboard with rocks.JPG"
0.164 "<test_images_dir>boats on a lake.jpg"
0.161 "<test_images_dir>bee.jpg"
2 changes: 1 addition & 1 deletion tests/e2e/output_snapshots/test_search_by_image.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ score filepath
0.744 "<test_images_dir>black cat at night.jpg"
0.700 "<test_images_dir>cautious cat.jpg"
0.611 "<test_images_dir>chessboard with rocks.JPG"
0.585 "<test_images_dir>tree.webp"
0.564 "<test_images_dir>bee.jpg"
0.560 "<test_images_dir>cake.jpg"
0.558 "<test_images_dir>camera.jpg"
0.531 "<test_images_dir>books.jpg"
0.531 "<test_images_dir>boats on a lake.jpg"
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ score filepath
0.744 "<test_images_dir>black cat at night.jpg"
0.700 "<test_images_dir>cautious cat.jpg"
0.611 "<test_images_dir>chessboard with rocks.JPG"
0.585 "<test_images_dir>tree.webp"
0.564 "<test_images_dir>bee.jpg"
0.560 "<test_images_dir>cake.jpg"
0.558 "<test_images_dir>camera.jpg"
0.531 "<test_images_dir>books.jpg"
11 changes: 11 additions & 0 deletions tests/e2e/output_snapshots/test_search_webp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
score filepath
0.280 "<test_images_dir>tree.webp"
0.209 "<test_images_dir>black cat at night.jpg"
0.207 "<test_images_dir>chessboard with rocks.JPG"
0.198 "<test_images_dir>cautious cat.jpg"
0.196 "<test_images_dir>black cat sleeping on a chair.JPG"
0.191 "<test_images_dir>bee.jpg"
0.188 "<test_images_dir>camera.jpg"
0.182 "<test_images_dir>boats on a lake.jpg"
0.181 "<test_images_dir>cake.jpg"
0.174 "<test_images_dir>cat.jpg"
6 changes: 6 additions & 0 deletions tests/e2e/test_rclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def test_search(test_images_dir: Path, monkeypatch: pytest.MonkeyPatch):
execute_query(test_images_dir, monkeypatch, 'kitty')


@pytest.mark.usefixtures('assert_output_snapshot')
def test_search_webp(test_images_dir: Path, monkeypatch: pytest.MonkeyPatch):
# this test result snapshot should contain webp image
execute_query(test_images_dir, monkeypatch, 'tree')


@pytest.mark.usefixtures('assert_output_snapshot')
def test_search_by_image(test_images_dir: Path, monkeypatch: pytest.MonkeyPatch):
execute_query(test_images_dir, monkeypatch, str(test_images_dir / 'cat.jpg'))
Expand Down

0 comments on commit 64cd297

Please sign in to comment.