heavyedge-dataset 0.1.0__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- heavyedge_dataset-1.0.0/PKG-INFO +89 -0
- heavyedge_dataset-1.0.0/README.md +52 -0
- {heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/pyproject.toml +1 -2
- heavyedge_dataset-1.0.0/src/heavyedge_dataset/__init__.py +95 -0
- heavyedge_dataset-1.0.0/src/heavyedge_dataset.egg-info/PKG-INFO +89 -0
- {heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/src/heavyedge_dataset.egg-info/SOURCES.txt +0 -2
- {heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/src/heavyedge_dataset.egg-info/requires.txt +0 -1
- heavyedge_dataset-0.1.0/PKG-INFO +0 -39
- heavyedge_dataset-0.1.0/README.md +0 -1
- heavyedge_dataset-0.1.0/src/heavyedge_dataset/__init__.py +0 -15
- heavyedge_dataset-0.1.0/src/heavyedge_dataset/datasets.py +0 -293
- heavyedge_dataset-0.1.0/src/heavyedge_dataset/landmarks.py +0 -41
- heavyedge_dataset-0.1.0/src/heavyedge_dataset.egg-info/PKG-INFO +0 -39
- {heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/LICENSE +0 -0
- {heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/setup.cfg +0 -0
- {heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/src/heavyedge_dataset.egg-info/dependency_links.txt +0 -0
- {heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/src/heavyedge_dataset.egg-info/top_level.txt +0 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: heavyedge-dataset
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: PyTorch-compatible edge profile dataset API
|
5
|
+
Author-email: Jisoo Song <jeesoo9595@snu.ac.kr>
|
6
|
+
License-Expression: MIT
|
7
|
+
Project-URL: homepage, https://pypi.python.org/pypi/heavyedge-dataset/
|
8
|
+
Project-URL: source, https://github.com/heavyedge/heavyedge-dataset
|
9
|
+
Project-URL: documentation, https://heavyedge-dataset.readthedocs.io
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
12
|
+
Classifier: Programming Language :: Python
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
19
|
+
Classifier: Operating System :: OS Independent
|
20
|
+
Requires-Python: >=3.10
|
21
|
+
Description-Content-Type: text/markdown
|
22
|
+
License-File: LICENSE
|
23
|
+
Requires-Dist: heavyedge>=1.1.2
|
24
|
+
Requires-Dist: torch
|
25
|
+
Provides-Extra: test
|
26
|
+
Requires-Dist: pytest; extra == "test"
|
27
|
+
Provides-Extra: doc
|
28
|
+
Requires-Dist: sphinx; extra == "doc"
|
29
|
+
Requires-Dist: numpydoc; extra == "doc"
|
30
|
+
Requires-Dist: pydata_sphinx_theme; extra == "doc"
|
31
|
+
Provides-Extra: dev
|
32
|
+
Requires-Dist: flake8; extra == "dev"
|
33
|
+
Requires-Dist: black; extra == "dev"
|
34
|
+
Requires-Dist: isort; extra == "dev"
|
35
|
+
Requires-Dist: heavyedge-dataset[doc,test]; extra == "dev"
|
36
|
+
Dynamic: license-file
|
37
|
+
|
38
|
+
# HeavyEdge-Dataset
|
39
|
+
|
40
|
+
[](https://pypi.python.org/pypi/heavyedge-dataset/)
|
41
|
+
[](https://pypi.python.org/pypi/heavyedge-dataset/)
|
42
|
+
[](https://github.com/heavyedge/heavyedge-dataset/blob/master/LICENSE)
|
43
|
+
[](https://github.com/heavyedge/heavyedge-dataset/actions/workflows/ci.yml)
|
44
|
+
[](https://github.com/heavyedge/heavyedge-dataset/actions/workflows/cd.yml)
|
45
|
+
[](https://heavyedge-dataset.readthedocs.io/en/latest/?badge=latest)
|
46
|
+
|
47
|
+
Package to load edge profile data as PyTorch dataset.
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
HeavyEdge-Dataset provides `ProfileDataset` which wraps profile data file.
|
52
|
+
|
53
|
+
A simple use case to load two-dimensional coordinates of profiles and their lengths:
|
54
|
+
|
55
|
+
```python
|
56
|
+
from heavyedge import get_sample_path, ProfileData
|
57
|
+
from heavyedge_dataset import ProfileDataset
|
58
|
+
with ProfileData(get_sample_path("Prep-Type2.h5")) as file:
|
59
|
+
data = ProfileDataset(file, 2)[:]
|
60
|
+
```
|
61
|
+
|
62
|
+
Refer to the package documentation for more information.
|
63
|
+
|
64
|
+
## Documentation
|
65
|
+
|
66
|
+
The manual can be found online:
|
67
|
+
|
68
|
+
> https://heavyedge-dataset.readthedocs.io
|
69
|
+
|
70
|
+
If you want to build the document yourself, get the source code and install with `[doc]` dependency.
|
71
|
+
Then, go to `doc` directory and build the document:
|
72
|
+
|
73
|
+
```
|
74
|
+
$ pip install .[doc]
|
75
|
+
$ cd doc
|
76
|
+
$ make html
|
77
|
+
```
|
78
|
+
|
79
|
+
Document will be generated in `build/html` directory. Open `index.html` to see the central page.
|
80
|
+
|
81
|
+
## Developing
|
82
|
+
|
83
|
+
### Installation
|
84
|
+
|
85
|
+
For development features, you must install the package by `pip install -e .[dev]`.
|
86
|
+
|
87
|
+
### Testing
|
88
|
+
|
89
|
+
Run `pytest` command to perform unit test.
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# HeavyEdge-Dataset
|
2
|
+
|
3
|
+
[](https://pypi.python.org/pypi/heavyedge-dataset/)
|
4
|
+
[](https://pypi.python.org/pypi/heavyedge-dataset/)
|
5
|
+
[](https://github.com/heavyedge/heavyedge-dataset/blob/master/LICENSE)
|
6
|
+
[](https://github.com/heavyedge/heavyedge-dataset/actions/workflows/ci.yml)
|
7
|
+
[](https://github.com/heavyedge/heavyedge-dataset/actions/workflows/cd.yml)
|
8
|
+
[](https://heavyedge-dataset.readthedocs.io/en/latest/?badge=latest)
|
9
|
+
|
10
|
+
Package to load edge profile data as PyTorch dataset.
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
HeavyEdge-Dataset provides `ProfileDataset` which wraps profile data file.
|
15
|
+
|
16
|
+
A simple use case to load two-dimensional coordinates of profiles and their lengths:
|
17
|
+
|
18
|
+
```python
|
19
|
+
from heavyedge import get_sample_path, ProfileData
|
20
|
+
from heavyedge_dataset import ProfileDataset
|
21
|
+
with ProfileData(get_sample_path("Prep-Type2.h5")) as file:
|
22
|
+
data = ProfileDataset(file, 2)[:]
|
23
|
+
```
|
24
|
+
|
25
|
+
Refer to the package documentation for more information.
|
26
|
+
|
27
|
+
## Documentation
|
28
|
+
|
29
|
+
The manual can be found online:
|
30
|
+
|
31
|
+
> https://heavyedge-dataset.readthedocs.io
|
32
|
+
|
33
|
+
If you want to build the document yourself, get the source code and install with `[doc]` dependency.
|
34
|
+
Then, go to `doc` directory and build the document:
|
35
|
+
|
36
|
+
```
|
37
|
+
$ pip install .[doc]
|
38
|
+
$ cd doc
|
39
|
+
$ make html
|
40
|
+
```
|
41
|
+
|
42
|
+
Document will be generated in `build/html` directory. Open `index.html` to see the central page.
|
43
|
+
|
44
|
+
## Developing
|
45
|
+
|
46
|
+
### Installation
|
47
|
+
|
48
|
+
For development features, you must install the package by `pip install -e .[dev]`.
|
49
|
+
|
50
|
+
### Testing
|
51
|
+
|
52
|
+
Run `pytest` command to perform unit test.
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "heavyedge-dataset"
|
7
|
-
version = "
|
7
|
+
version = "1.0.0"
|
8
8
|
authors = [
|
9
9
|
{name = "Jisoo Song", email = "jeesoo9595@snu.ac.kr"}
|
10
10
|
]
|
@@ -45,7 +45,6 @@ doc = [
|
|
45
45
|
"sphinx",
|
46
46
|
"numpydoc",
|
47
47
|
"pydata_sphinx_theme",
|
48
|
-
"matplotlib",
|
49
48
|
]
|
50
49
|
dev = [
|
51
50
|
"flake8",
|
@@ -0,0 +1,95 @@
|
|
1
|
+
"""Package to load :class:`heavyedge.ProfileData` using PyTorch dataset scheme.
|
2
|
+
|
3
|
+
Refer to `PyTorch tutorial <tutorial>`_ for information about custom PyTorch dataset.
|
4
|
+
|
5
|
+
.. _tutorial: https://docs.pytorch.org/tutorials/beginner/data_loading_tutorial.html
|
6
|
+
"""
|
7
|
+
|
8
|
+
import numbers
|
9
|
+
from collections.abc import Sequence
|
10
|
+
|
11
|
+
import numpy as np
|
12
|
+
from torch.utils.data import Dataset
|
13
|
+
|
14
|
+
__all__ = [
|
15
|
+
"ProfileDataset",
|
16
|
+
]
|
17
|
+
|
18
|
+
|
19
|
+
class ProfileDataset(Dataset):
|
20
|
+
"""Edge profile dataset.
|
21
|
+
|
22
|
+
Loads data as a tuple of two numpy arrays:
|
23
|
+
|
24
|
+
1. Profile data, shape: (N, m, L).
|
25
|
+
2. Length of each profile, shape: (N,).
|
26
|
+
|
27
|
+
N is the number of loaded data, m is dimension of coordinates, and
|
28
|
+
L is the maximum length of profiles.
|
29
|
+
|
30
|
+
Data can be indexed either by a single integer, by a slice, or by a sequence.
|
31
|
+
When a single integer index is used, data do not have the first axis.
|
32
|
+
|
33
|
+
Parameters
|
34
|
+
----------
|
35
|
+
file : heavyedge.ProfileData
|
36
|
+
Open hdf5 file.
|
37
|
+
m : {1, 2}
|
38
|
+
Profile data dimension.
|
39
|
+
1 means only y coordinates, and 2 means both x and y coordinates.
|
40
|
+
transform : callable, optional
|
41
|
+
Optional transformation to be applied on samples.
|
42
|
+
|
43
|
+
Examples
|
44
|
+
--------
|
45
|
+
>>> from heavyedge import get_sample_path, ProfileData
|
46
|
+
>>> from heavyedge_dataset import ProfileDataset
|
47
|
+
>>> with ProfileData(get_sample_path("Prep-Type2.h5")) as file:
|
48
|
+
... profiles, _ = ProfileDataset(file, m=2)[:]
|
49
|
+
>>> profiles.shape
|
50
|
+
(22, 2, 3200)
|
51
|
+
"""
|
52
|
+
|
53
|
+
def __init__(self, file, m=1, transform=None):
|
54
|
+
self.file = file
|
55
|
+
self.m = m
|
56
|
+
self.transform = transform
|
57
|
+
self.x = file.x()
|
58
|
+
|
59
|
+
def __len__(self):
|
60
|
+
return len(self.file)
|
61
|
+
|
62
|
+
def __getitem__(self, idx):
|
63
|
+
if isinstance(idx, numbers.Integral):
|
64
|
+
Y, L, _ = self.file[idx]
|
65
|
+
Y = Y[np.newaxis, :]
|
66
|
+
else:
|
67
|
+
# Support multi-indexing
|
68
|
+
idxs = idx
|
69
|
+
needs_sort = isinstance(idx, (Sequence, np.ndarray))
|
70
|
+
if needs_sort:
|
71
|
+
# idxs must be sorted for h5py
|
72
|
+
idxs = np.array(idxs)
|
73
|
+
sort_idx = np.argsort(idxs)
|
74
|
+
idxs = idxs[sort_idx]
|
75
|
+
Y, L, _ = self.file[idxs]
|
76
|
+
if needs_sort:
|
77
|
+
reverse_idx = np.argsort(sort_idx)
|
78
|
+
Y = Y[reverse_idx]
|
79
|
+
L = L[reverse_idx]
|
80
|
+
Y = Y[:, np.newaxis, :]
|
81
|
+
if self.m == 1:
|
82
|
+
pass
|
83
|
+
elif self.m == 2:
|
84
|
+
x = np.tile(self.x, Y.shape[:-1] + (1,))
|
85
|
+
Y = np.concatenate([x, Y], axis=-2)
|
86
|
+
else:
|
87
|
+
raise ValueError(f"Unsupported dimension: {self.m} (Must be 1 or 2).")
|
88
|
+
ret = (Y, L)
|
89
|
+
if self.transform is not None:
|
90
|
+
ret = self.transform(ret)
|
91
|
+
return ret
|
92
|
+
|
93
|
+
def __getitems__(self, idxs):
|
94
|
+
# PyTorch API
|
95
|
+
return self.__getitem__(idxs)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: heavyedge-dataset
|
3
|
+
Version: 1.0.0
|
4
|
+
Summary: PyTorch-compatible edge profile dataset API
|
5
|
+
Author-email: Jisoo Song <jeesoo9595@snu.ac.kr>
|
6
|
+
License-Expression: MIT
|
7
|
+
Project-URL: homepage, https://pypi.python.org/pypi/heavyedge-dataset/
|
8
|
+
Project-URL: source, https://github.com/heavyedge/heavyedge-dataset
|
9
|
+
Project-URL: documentation, https://heavyedge-dataset.readthedocs.io
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
12
|
+
Classifier: Programming Language :: Python
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
19
|
+
Classifier: Operating System :: OS Independent
|
20
|
+
Requires-Python: >=3.10
|
21
|
+
Description-Content-Type: text/markdown
|
22
|
+
License-File: LICENSE
|
23
|
+
Requires-Dist: heavyedge>=1.1.2
|
24
|
+
Requires-Dist: torch
|
25
|
+
Provides-Extra: test
|
26
|
+
Requires-Dist: pytest; extra == "test"
|
27
|
+
Provides-Extra: doc
|
28
|
+
Requires-Dist: sphinx; extra == "doc"
|
29
|
+
Requires-Dist: numpydoc; extra == "doc"
|
30
|
+
Requires-Dist: pydata_sphinx_theme; extra == "doc"
|
31
|
+
Provides-Extra: dev
|
32
|
+
Requires-Dist: flake8; extra == "dev"
|
33
|
+
Requires-Dist: black; extra == "dev"
|
34
|
+
Requires-Dist: isort; extra == "dev"
|
35
|
+
Requires-Dist: heavyedge-dataset[doc,test]; extra == "dev"
|
36
|
+
Dynamic: license-file
|
37
|
+
|
38
|
+
# HeavyEdge-Dataset
|
39
|
+
|
40
|
+
[](https://pypi.python.org/pypi/heavyedge-dataset/)
|
41
|
+
[](https://pypi.python.org/pypi/heavyedge-dataset/)
|
42
|
+
[](https://github.com/heavyedge/heavyedge-dataset/blob/master/LICENSE)
|
43
|
+
[](https://github.com/heavyedge/heavyedge-dataset/actions/workflows/ci.yml)
|
44
|
+
[](https://github.com/heavyedge/heavyedge-dataset/actions/workflows/cd.yml)
|
45
|
+
[](https://heavyedge-dataset.readthedocs.io/en/latest/?badge=latest)
|
46
|
+
|
47
|
+
Package to load edge profile data as PyTorch dataset.
|
48
|
+
|
49
|
+
## Usage
|
50
|
+
|
51
|
+
HeavyEdge-Dataset provides `ProfileDataset` which wraps profile data file.
|
52
|
+
|
53
|
+
A simple use case to load two-dimensional coordinates of profiles and their lengths:
|
54
|
+
|
55
|
+
```python
|
56
|
+
from heavyedge import get_sample_path, ProfileData
|
57
|
+
from heavyedge_dataset import ProfileDataset
|
58
|
+
with ProfileData(get_sample_path("Prep-Type2.h5")) as file:
|
59
|
+
data = ProfileDataset(file, 2)[:]
|
60
|
+
```
|
61
|
+
|
62
|
+
Refer to the package documentation for more information.
|
63
|
+
|
64
|
+
## Documentation
|
65
|
+
|
66
|
+
The manual can be found online:
|
67
|
+
|
68
|
+
> https://heavyedge-dataset.readthedocs.io
|
69
|
+
|
70
|
+
If you want to build the document yourself, get the source code and install with `[doc]` dependency.
|
71
|
+
Then, go to `doc` directory and build the document:
|
72
|
+
|
73
|
+
```
|
74
|
+
$ pip install .[doc]
|
75
|
+
$ cd doc
|
76
|
+
$ make html
|
77
|
+
```
|
78
|
+
|
79
|
+
Document will be generated in `build/html` directory. Open `index.html` to see the central page.
|
80
|
+
|
81
|
+
## Developing
|
82
|
+
|
83
|
+
### Installation
|
84
|
+
|
85
|
+
For development features, you must install the package by `pip install -e .[dev]`.
|
86
|
+
|
87
|
+
### Testing
|
88
|
+
|
89
|
+
Run `pytest` command to perform unit test.
|
{heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/src/heavyedge_dataset.egg-info/SOURCES.txt
RENAMED
@@ -2,8 +2,6 @@ LICENSE
|
|
2
2
|
README.md
|
3
3
|
pyproject.toml
|
4
4
|
src/heavyedge_dataset/__init__.py
|
5
|
-
src/heavyedge_dataset/datasets.py
|
6
|
-
src/heavyedge_dataset/landmarks.py
|
7
5
|
src/heavyedge_dataset.egg-info/PKG-INFO
|
8
6
|
src/heavyedge_dataset.egg-info/SOURCES.txt
|
9
7
|
src/heavyedge_dataset.egg-info/dependency_links.txt
|
heavyedge_dataset-0.1.0/PKG-INFO
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: heavyedge-dataset
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: PyTorch-compatible edge profile dataset API
|
5
|
-
Author-email: Jisoo Song <jeesoo9595@snu.ac.kr>
|
6
|
-
License-Expression: MIT
|
7
|
-
Project-URL: homepage, https://pypi.python.org/pypi/heavyedge-dataset/
|
8
|
-
Project-URL: source, https://github.com/heavyedge/heavyedge-dataset
|
9
|
-
Project-URL: documentation, https://heavyedge-dataset.readthedocs.io
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
11
|
-
Classifier: Intended Audience :: Science/Research
|
12
|
-
Classifier: Programming Language :: Python
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
17
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
18
|
-
Classifier: Topic :: Scientific/Engineering
|
19
|
-
Classifier: Operating System :: OS Independent
|
20
|
-
Requires-Python: >=3.10
|
21
|
-
Description-Content-Type: text/markdown
|
22
|
-
License-File: LICENSE
|
23
|
-
Requires-Dist: heavyedge>=1.1.2
|
24
|
-
Requires-Dist: torch
|
25
|
-
Provides-Extra: test
|
26
|
-
Requires-Dist: pytest; extra == "test"
|
27
|
-
Provides-Extra: doc
|
28
|
-
Requires-Dist: sphinx; extra == "doc"
|
29
|
-
Requires-Dist: numpydoc; extra == "doc"
|
30
|
-
Requires-Dist: pydata_sphinx_theme; extra == "doc"
|
31
|
-
Requires-Dist: matplotlib; extra == "doc"
|
32
|
-
Provides-Extra: dev
|
33
|
-
Requires-Dist: flake8; extra == "dev"
|
34
|
-
Requires-Dist: black; extra == "dev"
|
35
|
-
Requires-Dist: isort; extra == "dev"
|
36
|
-
Requires-Dist: heavyedge-dataset[doc,test]; extra == "dev"
|
37
|
-
Dynamic: license-file
|
38
|
-
|
39
|
-
# HeavyEdge-Dataset
|
@@ -1 +0,0 @@
|
|
1
|
-
# HeavyEdge-Dataset
|
@@ -1,15 +0,0 @@
|
|
1
|
-
"""PyTorch-compatiable dataset API for edge profiles."""
|
2
|
-
|
3
|
-
__all__ = [
|
4
|
-
"ProfileDataset",
|
5
|
-
"PseudoLmDataset",
|
6
|
-
"MathLm1dDataset",
|
7
|
-
"MathLm2dDataset",
|
8
|
-
]
|
9
|
-
|
10
|
-
from .datasets import (
|
11
|
-
MathLm1dDataset,
|
12
|
-
MathLm2dDataset,
|
13
|
-
ProfileDataset,
|
14
|
-
PseudoLmDataset,
|
15
|
-
)
|
@@ -1,293 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Dataset classes
|
3
|
-
---------------
|
4
|
-
|
5
|
-
PyTorch dataset classes for edge profiles.
|
6
|
-
"""
|
7
|
-
|
8
|
-
import abc
|
9
|
-
import numbers
|
10
|
-
from collections.abc import Sequence
|
11
|
-
|
12
|
-
import numpy as np
|
13
|
-
from heavyedge.api import landmarks_type3
|
14
|
-
from torch.utils.data import Dataset
|
15
|
-
|
16
|
-
from .landmarks import math_landmarks_1d, pseudo_landmarks_1d, pseudo_landmarks_2d
|
17
|
-
|
18
|
-
__all__ = [
|
19
|
-
"ProfileDataset",
|
20
|
-
"PseudoLmDataset",
|
21
|
-
"MathLm1dDataset",
|
22
|
-
"MathLm2dDataset",
|
23
|
-
]
|
24
|
-
|
25
|
-
|
26
|
-
class ProfileDatasetBase(abc.ABC):
|
27
|
-
"""Abstract base class for profile dataset."""
|
28
|
-
|
29
|
-
@property
|
30
|
-
@abc.abstractmethod
|
31
|
-
def file(self):
|
32
|
-
"""Profile data file.
|
33
|
-
|
34
|
-
Returns
|
35
|
-
-------
|
36
|
-
heavyedge.ProfileData
|
37
|
-
"""
|
38
|
-
|
39
|
-
@abc.abstractmethod
|
40
|
-
def default_transform(self, profiles, lengths):
|
41
|
-
"""Default transform by the dataset class.
|
42
|
-
|
43
|
-
Parameters
|
44
|
-
----------
|
45
|
-
profiles : (N, M) array
|
46
|
-
Profile data.
|
47
|
-
lengths : (N,) array
|
48
|
-
Length of each profile.
|
49
|
-
"""
|
50
|
-
pass
|
51
|
-
|
52
|
-
@property
|
53
|
-
@abc.abstractmethod
|
54
|
-
def transform(self):
|
55
|
-
"""Optional transformation passed to the dataset instance.
|
56
|
-
|
57
|
-
Returns
|
58
|
-
-------
|
59
|
-
Callable
|
60
|
-
"""
|
61
|
-
|
62
|
-
def __len__(self):
|
63
|
-
return len(self.file)
|
64
|
-
|
65
|
-
def __getitem__(self, idx):
|
66
|
-
if isinstance(idx, numbers.Integral):
|
67
|
-
Y, L, _ = self.file[idx]
|
68
|
-
ret = self.default_transform([Y], [L])
|
69
|
-
if self.transform:
|
70
|
-
ret = self.transform(ret)
|
71
|
-
ret = ret[0]
|
72
|
-
else:
|
73
|
-
ret = self.__getitems__(idx)
|
74
|
-
return ret
|
75
|
-
|
76
|
-
def __getitems__(self, idxs):
|
77
|
-
# PyTorch API
|
78
|
-
needs_sort = isinstance(idxs, (Sequence, np.ndarray))
|
79
|
-
if needs_sort:
|
80
|
-
# idxs must be sorted for h5py
|
81
|
-
idxs = np.array(idxs)
|
82
|
-
sort_idx = np.argsort(idxs)
|
83
|
-
idxs = idxs[sort_idx]
|
84
|
-
else:
|
85
|
-
pass
|
86
|
-
Ys, Ls, _ = self.file[idxs]
|
87
|
-
if needs_sort:
|
88
|
-
reverse_idx = np.argsort(sort_idx)
|
89
|
-
Ys = Ys[reverse_idx]
|
90
|
-
Ls = Ls[reverse_idx]
|
91
|
-
ret = self.default_transform(Ys, Ls)
|
92
|
-
if self.transform:
|
93
|
-
ret = self.transform(ret)
|
94
|
-
return ret
|
95
|
-
|
96
|
-
|
97
|
-
class ProfileDataset(ProfileDatasetBase, Dataset):
|
98
|
-
"""Full profile dataset.
|
99
|
-
|
100
|
-
Parameters
|
101
|
-
----------
|
102
|
-
file : heavyedge.ProfileData
|
103
|
-
Open hdf5 file.
|
104
|
-
m : {1, 2}
|
105
|
-
Profile data dimension.
|
106
|
-
1 means only y coordinates, and 2 means both x and y coordinates.
|
107
|
-
transform : callable, optional
|
108
|
-
Optional transform to be applied on a sample.
|
109
|
-
|
110
|
-
Examples
|
111
|
-
--------
|
112
|
-
>>> from heavyedge import get_sample_path, ProfileData
|
113
|
-
>>> from heavyedge_dataset import ProfileDataset
|
114
|
-
>>> with ProfileData(get_sample_path("Prep-Type2.h5")) as file:
|
115
|
-
... data = ProfileDataset(file, 2)[:]
|
116
|
-
>>> import matplotlib.pyplot as plt # doctest: +SKIP
|
117
|
-
... for coords in data:
|
118
|
-
... plt.plot(*coords, color="gray")
|
119
|
-
"""
|
120
|
-
|
121
|
-
def __init__(self, file, m, transform=None):
|
122
|
-
self._file = file
|
123
|
-
self.m = m
|
124
|
-
self._transform = transform
|
125
|
-
|
126
|
-
self.x = file.x()
|
127
|
-
|
128
|
-
@property
|
129
|
-
def file(self):
|
130
|
-
return self._file
|
131
|
-
|
132
|
-
def default_transform(self, profiles, lengths):
|
133
|
-
if self.m == 1:
|
134
|
-
ret = [Y[:L].reshape(1, -1) for Y, L in zip(profiles, lengths)]
|
135
|
-
elif self.m == 2:
|
136
|
-
ret = [np.stack([self.x[:L], Y[:L]]) for Y, L in zip(profiles, lengths)]
|
137
|
-
else:
|
138
|
-
raise ValueError(f"Invalid dimension: {self.m}")
|
139
|
-
return ret
|
140
|
-
|
141
|
-
@property
|
142
|
-
def transform(self):
|
143
|
-
return self._transform
|
144
|
-
|
145
|
-
|
146
|
-
class PseudoLmDataset(ProfileDatasetBase, Dataset):
|
147
|
-
"""Pseudo-landmark dataset.
|
148
|
-
|
149
|
-
Parameters
|
150
|
-
----------
|
151
|
-
file : heavyedge.ProfileData
|
152
|
-
Open hdf5 file.
|
153
|
-
k : int
|
154
|
-
Number of landmarks to sample.
|
155
|
-
m : {1, 2}
|
156
|
-
Profile data dimension.
|
157
|
-
1 means only y coordinates, and 2 means both x and y coordinates.
|
158
|
-
transform : callable, optional
|
159
|
-
Optional transform to be applied on a sample.
|
160
|
-
|
161
|
-
Examples
|
162
|
-
--------
|
163
|
-
>>> from heavyedge import get_sample_path, ProfileData
|
164
|
-
>>> from heavyedge_dataset import PseudoLmDataset
|
165
|
-
>>> with ProfileData(get_sample_path("Prep-Type2.h5")) as file:
|
166
|
-
... data = PseudoLmDataset(file, 10, 2)[:]
|
167
|
-
>>> import matplotlib.pyplot as plt # doctest: +SKIP
|
168
|
-
... plt.plot(*data.transpose(1, 2, 0), color="gray")
|
169
|
-
"""
|
170
|
-
|
171
|
-
def __init__(self, file, k, m, transform=None):
|
172
|
-
self._file = file
|
173
|
-
self.k = k
|
174
|
-
self.m = m
|
175
|
-
self._transform = transform
|
176
|
-
|
177
|
-
self.x = file.x()
|
178
|
-
|
179
|
-
@property
|
180
|
-
def file(self):
|
181
|
-
return self._file
|
182
|
-
|
183
|
-
def default_transform(self, profiles, lengths):
|
184
|
-
if self.m == 1:
|
185
|
-
ret = pseudo_landmarks_1d(profiles, lengths, self.k)
|
186
|
-
elif self.m == 2:
|
187
|
-
ret = pseudo_landmarks_2d(self.x, profiles, lengths, self.k)
|
188
|
-
else:
|
189
|
-
raise ValueError(f"Invalid dimension: {self.m}")
|
190
|
-
return ret
|
191
|
-
|
192
|
-
@property
|
193
|
-
def transform(self):
|
194
|
-
return self._transform
|
195
|
-
|
196
|
-
|
197
|
-
class MathLm1dDataset(ProfileDatasetBase, Dataset):
|
198
|
-
"""1-D mathematical landmarks dataset.
|
199
|
-
|
200
|
-
Parameters
|
201
|
-
----------
|
202
|
-
file : heavyedge.ProfileData
|
203
|
-
Open hdf5 file.
|
204
|
-
sigma : scalar
|
205
|
-
Standard deviation of Gaussian kernel for landmark detection.
|
206
|
-
transform : callable, optional
|
207
|
-
Optional transform to be applied on a sample.
|
208
|
-
|
209
|
-
Examples
|
210
|
-
--------
|
211
|
-
>>> from heavyedge import get_sample_path, ProfileData
|
212
|
-
>>> from heavyedge_dataset import MathLm1dDataset
|
213
|
-
>>> with ProfileData(get_sample_path("Prep-Type2.h5")) as file:
|
214
|
-
... data = MathLm1dDataset(file, 32)[:]
|
215
|
-
>>> import matplotlib.pyplot as plt # doctest: +SKIP
|
216
|
-
... plt.plot(*data.transpose(1, 2, 0), color="gray")
|
217
|
-
"""
|
218
|
-
|
219
|
-
def __init__(self, file, sigma, transform=None):
|
220
|
-
self._file = file
|
221
|
-
self.sigma = sigma
|
222
|
-
self._transform = transform
|
223
|
-
|
224
|
-
@property
|
225
|
-
def file(self):
|
226
|
-
return self._file
|
227
|
-
|
228
|
-
def default_transform(self, profiles, lengths):
|
229
|
-
return math_landmarks_1d(profiles, lengths, self.sigma)
|
230
|
-
|
231
|
-
@property
|
232
|
-
def transform(self):
|
233
|
-
return self._transform
|
234
|
-
|
235
|
-
|
236
|
-
class MathLm2dDataset(ProfileDatasetBase, Dataset):
|
237
|
-
"""2-D mathematical landmarks dataset.
|
238
|
-
|
239
|
-
Parameters
|
240
|
-
----------
|
241
|
-
file : heavyedge.ProfileData
|
242
|
-
Open hdf5 file.
|
243
|
-
sigma : scalar
|
244
|
-
Standard deviation of Gaussian kernel for landmark detection.
|
245
|
-
transform : callable, optional
|
246
|
-
Optional transform to be applied on a sample.
|
247
|
-
|
248
|
-
Examples
|
249
|
-
--------
|
250
|
-
>>> from heavyedge import get_sample_path, ProfileData
|
251
|
-
>>> from heavyedge_dataset import MathLm2dDataset
|
252
|
-
>>> with ProfileData(get_sample_path("Prep-Type2.h5")) as file:
|
253
|
-
... lm, _ = MathLm2dDataset(file, 32)[:]
|
254
|
-
>>> import matplotlib.pyplot as plt # doctest: +SKIP
|
255
|
-
... plt.plot(*lm.transpose(1, 2, 0), color="gray")
|
256
|
-
"""
|
257
|
-
|
258
|
-
def __init__(self, file, sigma, transform=None):
|
259
|
-
self._file = file
|
260
|
-
self.sigma = sigma
|
261
|
-
self._transform = transform
|
262
|
-
|
263
|
-
self.x = file.x()
|
264
|
-
|
265
|
-
@property
|
266
|
-
def file(self):
|
267
|
-
return self._file
|
268
|
-
|
269
|
-
def default_transform(self, profiles, lengths):
|
270
|
-
# Todo: cythonize this method to avoid python loop.
|
271
|
-
# This will require cythonizing landmarks_type3().
|
272
|
-
lm, center_height = [], []
|
273
|
-
for Y, L in zip(profiles, lengths):
|
274
|
-
Y = Y[:L]
|
275
|
-
indices = np.flip(landmarks_type3(Y, self.sigma))
|
276
|
-
lm.append(np.stack([self.x[indices], Y[indices]]))
|
277
|
-
center_height.append(np.mean(Y[: indices[0]]))
|
278
|
-
return np.array(lm), np.array(center_height)
|
279
|
-
|
280
|
-
def __getitem__(self, idx):
|
281
|
-
if isinstance(idx, numbers.Integral):
|
282
|
-
Y, L, _ = self.file[idx]
|
283
|
-
lm, ch = self.default_transform([Y], [L])
|
284
|
-
if self.transform:
|
285
|
-
lm, ch = self.transform(lm, ch)
|
286
|
-
lm, ch = lm[0], ch[0]
|
287
|
-
else:
|
288
|
-
lm, ch = self.__getitems__(idx)
|
289
|
-
return (lm, ch)
|
290
|
-
|
291
|
-
@property
|
292
|
-
def transform(self):
|
293
|
-
return self._transform
|
@@ -1,41 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Landmark locators
|
3
|
-
-----------------
|
4
|
-
|
5
|
-
Functions to locate landmarks from edge profiles.
|
6
|
-
"""
|
7
|
-
|
8
|
-
import numpy as np
|
9
|
-
from heavyedge.api import landmarks_type3
|
10
|
-
|
11
|
-
__all__ = [
|
12
|
-
"pseudo_landmarks_1d",
|
13
|
-
"pseudo_landmarks_2d",
|
14
|
-
"math_landmarks_1d",
|
15
|
-
]
|
16
|
-
|
17
|
-
|
18
|
-
def pseudo_landmarks_1d(Ys, Ls, k):
|
19
|
-
ret = []
|
20
|
-
for Y, L in zip(Ys, Ls):
|
21
|
-
idxs = np.linspace(0, L - 1, k, dtype=int)
|
22
|
-
ret.append(Y[idxs].reshape(1, -1))
|
23
|
-
return np.array(ret)
|
24
|
-
|
25
|
-
|
26
|
-
def pseudo_landmarks_2d(x, Ys, Ls, k):
|
27
|
-
ret = []
|
28
|
-
for Y, L in zip(Ys, Ls):
|
29
|
-
idxs = np.linspace(0, L - 1, k, dtype=int)
|
30
|
-
ret.append(np.stack([x[idxs], Y[idxs]]))
|
31
|
-
return np.array(ret)
|
32
|
-
|
33
|
-
|
34
|
-
def math_landmarks_1d(Ys, Ls, sigma):
|
35
|
-
ret = []
|
36
|
-
for Y, L in zip(Ys, Ls):
|
37
|
-
Y = Y[:L]
|
38
|
-
indices = np.flip(landmarks_type3(Y, sigma))
|
39
|
-
y = np.concat([[np.mean(Y[: indices[0]])], Y[indices]])
|
40
|
-
ret.append(y.reshape(1, -1))
|
41
|
-
return np.array(ret)
|
@@ -1,39 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: heavyedge-dataset
|
3
|
-
Version: 0.1.0
|
4
|
-
Summary: PyTorch-compatible edge profile dataset API
|
5
|
-
Author-email: Jisoo Song <jeesoo9595@snu.ac.kr>
|
6
|
-
License-Expression: MIT
|
7
|
-
Project-URL: homepage, https://pypi.python.org/pypi/heavyedge-dataset/
|
8
|
-
Project-URL: source, https://github.com/heavyedge/heavyedge-dataset
|
9
|
-
Project-URL: documentation, https://heavyedge-dataset.readthedocs.io
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
11
|
-
Classifier: Intended Audience :: Science/Research
|
12
|
-
Classifier: Programming Language :: Python
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
14
|
-
Classifier: Programming Language :: Python :: 3.10
|
15
|
-
Classifier: Programming Language :: Python :: 3.11
|
16
|
-
Classifier: Programming Language :: Python :: 3.12
|
17
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
18
|
-
Classifier: Topic :: Scientific/Engineering
|
19
|
-
Classifier: Operating System :: OS Independent
|
20
|
-
Requires-Python: >=3.10
|
21
|
-
Description-Content-Type: text/markdown
|
22
|
-
License-File: LICENSE
|
23
|
-
Requires-Dist: heavyedge>=1.1.2
|
24
|
-
Requires-Dist: torch
|
25
|
-
Provides-Extra: test
|
26
|
-
Requires-Dist: pytest; extra == "test"
|
27
|
-
Provides-Extra: doc
|
28
|
-
Requires-Dist: sphinx; extra == "doc"
|
29
|
-
Requires-Dist: numpydoc; extra == "doc"
|
30
|
-
Requires-Dist: pydata_sphinx_theme; extra == "doc"
|
31
|
-
Requires-Dist: matplotlib; extra == "doc"
|
32
|
-
Provides-Extra: dev
|
33
|
-
Requires-Dist: flake8; extra == "dev"
|
34
|
-
Requires-Dist: black; extra == "dev"
|
35
|
-
Requires-Dist: isort; extra == "dev"
|
36
|
-
Requires-Dist: heavyedge-dataset[doc,test]; extra == "dev"
|
37
|
-
Dynamic: license-file
|
38
|
-
|
39
|
-
# HeavyEdge-Dataset
|
File without changes
|
File without changes
|
File without changes
|
{heavyedge_dataset-0.1.0 → heavyedge_dataset-1.0.0}/src/heavyedge_dataset.egg-info/top_level.txt
RENAMED
File without changes
|