Skip to content

Commit 9a1305e

Browse files
authored
Reworking datasets & interfaces
* Introduced slightly different interfaces for datasets * Made a dedicated folder for images datasets. Renamed and moved old datasets. Kept names of the old dataset for backward compatibility. * Removed `ListDataset` and its' tests * In tests: `DummyQGDataset` -> `EmbeddingsQueryGalleryDataset`
1 parent ec091f1 commit 9a1305e

File tree

24 files changed

+774
-637
lines changed

24 files changed

+774
-637
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ tmp.ipynb
1616
*outputs*
1717
*.hydra*
1818
*predictions.json*
19+
*ml-runs*
1920

2021
# __________________________________
2122

docs/source/contents/datasets.rst

+18-9
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,51 @@ Datasets
77
.. contents::
88
:local:
99

10-
BaseDataset
10+
ImageBaseDataset
1111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12-
.. autoclass:: oml.datasets.base.BaseDataset
12+
.. autoclass:: oml.datasets.images.ImageBaseDataset
1313
:undoc-members:
1414
:show-inheritance:
1515

1616
.. automethod:: __init__
17+
.. automethod:: __getitem__
18+
.. automethod:: visualize
1719

18-
DatasetWithLabels
20+
ImageLabeledDataset
1921
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20-
.. autoclass:: oml.datasets.base.DatasetWithLabels
22+
.. autoclass:: oml.datasets.images.ImageLabeledDataset
2123
:undoc-members:
2224
:show-inheritance:
2325

2426
.. automethod:: __init__
2527
.. automethod:: __getitem__
2628
.. automethod:: get_labels
27-
.. automethod:: get_label2category
29+
.. automethod:: visualize
2830

29-
DatasetQueryGallery
31+
ImageQueryGalleryLabeledDataset
3032
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31-
.. autoclass:: oml.datasets.base.DatasetQueryGallery
33+
.. autoclass:: oml.datasets.images.ImageQueryGalleryLabeledDataset
3234
:undoc-members:
3335
:show-inheritance:
3436

3537
.. automethod:: __init__
3638
.. automethod:: __getitem__
39+
.. automethod:: get_query_ids
40+
.. automethod:: get_gallery_ids
41+
.. automethod:: get_labels
42+
.. automethod:: visualize
3743

38-
ListDataset
44+
ImageQueryGalleryDataset
3945
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
40-
.. autoclass:: oml.datasets.list_dataset.ListDataset
46+
.. autoclass:: oml.datasets.images.ImageQueryGalleryDataset
4147
:undoc-members:
4248
:show-inheritance:
4349

4450
.. automethod:: __init__
4551
.. automethod:: __getitem__
52+
.. automethod:: get_query_ids
53+
.. automethod:: get_gallery_ids
54+
.. automethod:: visualize
4655

4756
EmbeddingPairsDataset
4857
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/source/contents/interfaces.rst

+30-5
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,39 @@ ITripletLossWithMiner
5252

5353
.. automethod:: forward
5454

55-
IDatasetWithLabels
55+
IBaseDataset
5656
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57-
.. autoclass:: oml.interfaces.datasets.IDatasetWithLabels
57+
.. autoclass:: oml.interfaces.datasets.IBaseDataset
58+
:undoc-members:
59+
:show-inheritance:
60+
61+
ILabeledDataset
62+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63+
.. autoclass:: oml.interfaces.datasets.ILabeledDataset
5864
:undoc-members:
5965
:show-inheritance:
6066

6167
.. automethod:: __getitem__
6268
.. automethod:: get_labels
6369

64-
IDatasetQueryGallery
70+
IQueryGalleryDataset
6571
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66-
.. autoclass:: oml.interfaces.datasets.IDatasetQueryGallery
72+
.. autoclass:: oml.interfaces.datasets.IQueryGalleryDataset
6773
:undoc-members:
6874
:show-inheritance:
6975

70-
.. automethod:: __getitem__
76+
.. automethod:: get_query_ids
77+
.. automethod:: get_gallery_ids
78+
79+
IQueryGalleryLabeledDataset
80+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
81+
.. autoclass:: oml.interfaces.datasets.IQueryGalleryLabeledDataset
82+
:undoc-members:
83+
:show-inheritance:
84+
85+
.. automethod:: get_query_ids
86+
.. automethod:: get_gallery_ids
87+
.. automethod:: get_labels
7188

7289
IPairsDataset
7390
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -78,6 +95,14 @@ IPairsDataset
7895
.. automethod:: __init__
7996
.. automethod:: __getitem__
8097

98+
IVisualizableDataset
99+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100+
.. autoclass:: oml.interfaces.datasets.IVisualizableDataset
101+
:undoc-members:
102+
:show-inheritance:
103+
104+
.. automethod:: visualize
105+
81106
IBasicMetric
82107
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
83108
.. autoclass:: oml.interfaces.metrics.IBasicMetric

oml/const.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import tempfile
33
from pathlib import Path
44
from sys import platform
5-
from typing import Any, Dict, Tuple, Union
5+
from typing import Any, Dict, Optional, Sequence, Tuple, Union
66

77
from omegaconf import DictConfig
88

@@ -50,6 +50,7 @@ def get_cache_folder() -> Path:
5050
GREEN = (0, 255, 0)
5151
BLUE = (0, 0, 255)
5252
GRAY = (120, 120, 120)
53+
BLACK = (0, 0, 0)
5354
PAD_COLOR = (255, 255, 255)
5455

5556
TCfg = Union[Dict[str, Any], DictConfig]
@@ -62,6 +63,9 @@ def get_cache_folder() -> Path:
6263
MEAN_CLIP = (0.48145466, 0.4578275, 0.40821073)
6364
STD_CLIP = (0.26862954, 0.26130258, 0.27577711)
6465

66+
TBBox = Tuple[int, int, int, int]
67+
TBBoxes = Sequence[Optional[TBBox]]
68+
6569
CROP_KEY = "crop" # the format is [x1, y1, x2, y2]
6670

6771
# Required dataset format:

0 commit comments

Comments
 (0)