homa 0.30000000000000004__tar.gz → 2.1__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.
Potentially problematic release.
This version of homa might be problematic. Click here for more details.
- {homa-0.30000000000000004 → homa-2.1}/PKG-INFO +7 -8
- homa-2.1/README.md +5 -0
- homa-2.1/homa/__init__.py +2 -0
- homa-2.1/homa/datasets.py +71 -0
- {homa-0.30000000000000004 → homa-2.1}/homa.egg-info/PKG-INFO +7 -8
- homa-2.1/homa.egg-info/SOURCES.txt +10 -0
- homa-2.1/homa.egg-info/requires.txt +2 -0
- {homa-0.30000000000000004 → homa-2.1}/setup.py +2 -5
- homa-0.30000000000000004/README.md +0 -8
- homa-0.30000000000000004/homa/__init__.py +0 -1
- homa-0.30000000000000004/homa/classes/Collection.py +0 -11
- homa-0.30000000000000004/homa/classes/Logger.py +0 -4
- homa-0.30000000000000004/homa/classes/Repository.py +0 -29
- homa-0.30000000000000004/homa/classes/__init__.py +0 -0
- homa-0.30000000000000004/homa/constants.py +0 -0
- homa-0.30000000000000004/homa/helpers.py +0 -16
- homa-0.30000000000000004/homa/main.py +0 -108
- homa-0.30000000000000004/homa.egg-info/SOURCES.txt +0 -16
- homa-0.30000000000000004/homa.egg-info/requires.txt +0 -2
- {homa-0.30000000000000004 → homa-2.1}/LICENSE +0 -0
- {homa-0.30000000000000004 → homa-2.1}/homa.egg-info/dependency_links.txt +0 -0
- {homa-0.30000000000000004 → homa-2.1}/homa.egg-info/top_level.txt +0 -0
- {homa-0.30000000000000004 → homa-2.1}/setup.cfg +0 -0
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: homa
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.1
|
|
4
4
|
Maintainer: Taha Shieenavaz
|
|
5
5
|
Maintainer-email: tahashieenavaz@gmail.com
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
License-File: LICENSE
|
|
8
|
+
Requires-Dist: torchvision
|
|
9
|
+
Requires-Dist: torch
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
<img
|
|
11
|
-
src="https://raw.githubusercontent.com/tahashieenavaz/homa/main/art/homa.svg"
|
|
12
|
-
width=400
|
|
13
|
-
/>
|
|
14
|
-
</p>
|
|
11
|
+
# Homa
|
|
15
12
|
|
|
16
|
-
<
|
|
13
|
+
<div align="center">
|
|
14
|
+
<img src="art/homa.svg" width="500" />
|
|
15
|
+
</div>
|
homa-2.1/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
from torchvision import transforms
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ImageDataset(torch.utils.data.Dataset):
|
|
6
|
+
def __init__(self, images, labels, transform=None):
|
|
7
|
+
self.images = images
|
|
8
|
+
self.labels = labels
|
|
9
|
+
self.transform = transform
|
|
10
|
+
|
|
11
|
+
def __len__(self):
|
|
12
|
+
return len(self.labels)
|
|
13
|
+
|
|
14
|
+
def __getitem__(self, idx):
|
|
15
|
+
image = self.images[idx]
|
|
16
|
+
label = self.labels[idx]
|
|
17
|
+
|
|
18
|
+
if self.transform:
|
|
19
|
+
image = self.transform(image)
|
|
20
|
+
|
|
21
|
+
return image, torch.tensor(label, dtype=torch.long)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class AugmentedDataset(torch.utils.data.Dataset):
|
|
25
|
+
def __init__(self, dataset, transform_probability=0.6):
|
|
26
|
+
self.original_dataset = dataset
|
|
27
|
+
self.transform_probability = transform_probability
|
|
28
|
+
self.augmented_data = []
|
|
29
|
+
self.transformations = [
|
|
30
|
+
transforms.Compose(
|
|
31
|
+
[
|
|
32
|
+
transforms.RandomHorizontalFlip(),
|
|
33
|
+
transforms.ColorJitter(
|
|
34
|
+
brightness=0.5, contrast=0.5, saturation=0.5, hue=0.2
|
|
35
|
+
),
|
|
36
|
+
transforms.RandomRotation(45),
|
|
37
|
+
]
|
|
38
|
+
),
|
|
39
|
+
transforms.Compose(
|
|
40
|
+
[
|
|
41
|
+
transforms.RandomVerticalFlip(),
|
|
42
|
+
transforms.RandomAffine(
|
|
43
|
+
degrees=30, translate=(0.1, 0.1), scale=(0.8, 1.2)
|
|
44
|
+
),
|
|
45
|
+
transforms.GaussianBlur(kernel_size=(5, 5), sigma=(0.1, 2.0)),
|
|
46
|
+
]
|
|
47
|
+
),
|
|
48
|
+
transforms.Compose(
|
|
49
|
+
[
|
|
50
|
+
transforms.RandomResizedCrop(size=(224, 224), scale=(0.5, 1.0)),
|
|
51
|
+
transforms.RandomPerspective(distortion_scale=0.5, p=1.0),
|
|
52
|
+
transforms.RandomGrayscale(p=0.3),
|
|
53
|
+
]
|
|
54
|
+
),
|
|
55
|
+
]
|
|
56
|
+
self._augment_dataset()
|
|
57
|
+
|
|
58
|
+
def _augment_dataset(self):
|
|
59
|
+
for image, label in self.original_dataset:
|
|
60
|
+
if torch.rand(1).item() < self.transform_probability:
|
|
61
|
+
for transform in self.transformations:
|
|
62
|
+
augmented_image = transform(image)
|
|
63
|
+
self.augmented_data.append((augmented_image, label))
|
|
64
|
+
else:
|
|
65
|
+
self.augmented_data.append((image, label))
|
|
66
|
+
|
|
67
|
+
def __len__(self):
|
|
68
|
+
return len(self.augmented_data)
|
|
69
|
+
|
|
70
|
+
def __getitem__(self, idx):
|
|
71
|
+
return self.augmented_data[idx]
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: homa
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.1
|
|
4
4
|
Maintainer: Taha Shieenavaz
|
|
5
5
|
Maintainer-email: tahashieenavaz@gmail.com
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
7
7
|
License-File: LICENSE
|
|
8
|
+
Requires-Dist: torchvision
|
|
9
|
+
Requires-Dist: torch
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
<img
|
|
11
|
-
src="https://raw.githubusercontent.com/tahashieenavaz/homa/main/art/homa.svg"
|
|
12
|
-
width=400
|
|
13
|
-
/>
|
|
14
|
-
</p>
|
|
11
|
+
# Homa
|
|
15
12
|
|
|
16
|
-
<
|
|
13
|
+
<div align="center">
|
|
14
|
+
<img src="art/homa.svg" width="500" />
|
|
15
|
+
</div>
|
|
@@ -9,7 +9,7 @@ with open("version.txt", "r") as fh:
|
|
|
9
9
|
current_version = float(fh.readline())
|
|
10
10
|
|
|
11
11
|
with open("version.txt", "w") as fh:
|
|
12
|
-
next_version = current_version + 0.
|
|
12
|
+
next_version = round(current_version + 0.01, 2)
|
|
13
13
|
fh.write(str(next_version))
|
|
14
14
|
|
|
15
15
|
setup(
|
|
@@ -18,10 +18,7 @@ setup(
|
|
|
18
18
|
maintainer_email="tahashieenavaz@gmail.com",
|
|
19
19
|
version=next_version,
|
|
20
20
|
packages=find_packages(),
|
|
21
|
-
install_requires=[
|
|
22
|
-
"opencv-python",
|
|
23
|
-
"numpy"
|
|
24
|
-
],
|
|
21
|
+
install_requires=["torchvision", "torch"],
|
|
25
22
|
long_description=description,
|
|
26
23
|
long_description_content_type="text/markdown",
|
|
27
24
|
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .main import *
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
from ..helpers import is_colab
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class RepositoryWrapper:
|
|
5
|
-
def __init__(self):
|
|
6
|
-
self.sigmaX = 0
|
|
7
|
-
self.sigmaY = 0
|
|
8
|
-
|
|
9
|
-
self.directory = "./"
|
|
10
|
-
self.images = {}
|
|
11
|
-
self.cameras = {}
|
|
12
|
-
self.window_counter = 0
|
|
13
|
-
|
|
14
|
-
if is_colab():
|
|
15
|
-
from google.colab.pathces import cv2_imshow as imshow
|
|
16
|
-
else:
|
|
17
|
-
from cv2 import imshow
|
|
18
|
-
|
|
19
|
-
self.imshow = imshow
|
|
20
|
-
|
|
21
|
-
def get_counter(self):
|
|
22
|
-
self.window_counter += 1
|
|
23
|
-
return self.window_counter
|
|
24
|
-
|
|
25
|
-
def __getattr__(self, name: str) -> any:
|
|
26
|
-
pass
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Repository = RepositoryWrapper()
|
|
File without changes
|
|
File without changes
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from typing import List
|
|
3
|
-
from .classes.Collection import Collection
|
|
4
|
-
from .classes.Logger import Logger
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def is_colab() -> bool:
|
|
8
|
-
return 'google.colab' in sys.modules
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def collection(items: List[any]):
|
|
12
|
-
return Collection(items)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def danger(message: str) -> None:
|
|
16
|
-
Logger.danger(message)
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import cv2
|
|
2
|
-
import numpy
|
|
3
|
-
from typing import List
|
|
4
|
-
from .helpers import collection
|
|
5
|
-
from .helpers import danger
|
|
6
|
-
|
|
7
|
-
from .classes.Repository import Repository
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def path(directory: str) -> None:
|
|
11
|
-
Repository.directory = directory
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
def write(key: str, filename: str) -> None:
|
|
15
|
-
cv2.imwrite(
|
|
16
|
-
filename=filename,
|
|
17
|
-
img=Repository.images[key]
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def save(key: str, filename: str) -> None:
|
|
22
|
-
write(key, filename)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def image(filename: str, key: str | None = None, color: bool = True) -> None:
|
|
26
|
-
# TODO: add no extension in the file
|
|
27
|
-
if key is None:
|
|
28
|
-
key = filename
|
|
29
|
-
|
|
30
|
-
Repository.images[key] = cv2.imread(filename, int(color))
|
|
31
|
-
return Repository.images[key]
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def show(key: any = None) -> None:
|
|
35
|
-
# TODO: add functionality to distinguish between camera and images
|
|
36
|
-
|
|
37
|
-
if key is not None and not isinstance(key, str):
|
|
38
|
-
Repository.imshow(f"Window #{Repository.get_counter()}", key)
|
|
39
|
-
|
|
40
|
-
elif key is None:
|
|
41
|
-
for key, image in Repository.images.items():
|
|
42
|
-
Repository.imshow(key, image)
|
|
43
|
-
|
|
44
|
-
elif key is not None:
|
|
45
|
-
if key in Repository.images:
|
|
46
|
-
Repository.imshow(key, Repository.images[key])
|
|
47
|
-
else:
|
|
48
|
-
danger(f"No image found with key {key}")
|
|
49
|
-
|
|
50
|
-
cv2.waitKey(0)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
def camera():
|
|
54
|
-
capture = cv2.VideoCapture()
|
|
55
|
-
_, frame = capture.read()
|
|
56
|
-
Repository.camera_frame = frame
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def stack(keys: List[str], new_key: str, axis: int):
|
|
60
|
-
Repository.images[new_key] = numpy.concatenate(
|
|
61
|
-
collection(keys).map(lambda key: Repository.images[key]),
|
|
62
|
-
axis=axis
|
|
63
|
-
)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def vstack(keys: List[str], new_key: str) -> None:
|
|
67
|
-
stack(keys, new_key, 1)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def hstack(keys: List[str] | str, new_key: str | None = None):
|
|
71
|
-
if isinstance(keys, str) and new_key is None:
|
|
72
|
-
hstack([keys], keys)
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
stack(keys, new_key, 0)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def blur(key: str, kernel: int | List[int] = (7, 7), new_key: str | None = None):
|
|
79
|
-
if new_key is None:
|
|
80
|
-
new_key = key
|
|
81
|
-
|
|
82
|
-
if isinstance(kernel, int):
|
|
83
|
-
kernel = (kernel, kernel)
|
|
84
|
-
|
|
85
|
-
Repository.images[new_key] = cv2.blur(
|
|
86
|
-
Repository.images[key],
|
|
87
|
-
kernel
|
|
88
|
-
)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def sigma(x: float = 0, y: float = 0):
|
|
92
|
-
Repository.sigmaX = x
|
|
93
|
-
Repository.sigmaY = y
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def gaussian(key: str, kernel: None | List[int] = None, new_key: str | None = None):
|
|
97
|
-
if new_key is None:
|
|
98
|
-
new_key = key
|
|
99
|
-
|
|
100
|
-
if isinstance(kernel, int):
|
|
101
|
-
kernel = (kernel, kernel)
|
|
102
|
-
|
|
103
|
-
Repository.images[new_key] = cv2.GaussianBlur(
|
|
104
|
-
Repository.images[key],
|
|
105
|
-
kernel,
|
|
106
|
-
sigmaX=Repository.sigmaX,
|
|
107
|
-
sigmaY=Repository.sigmaY
|
|
108
|
-
)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
LICENSE
|
|
2
|
-
README.md
|
|
3
|
-
setup.py
|
|
4
|
-
homa/__init__.py
|
|
5
|
-
homa/constants.py
|
|
6
|
-
homa/helpers.py
|
|
7
|
-
homa/main.py
|
|
8
|
-
homa.egg-info/PKG-INFO
|
|
9
|
-
homa.egg-info/SOURCES.txt
|
|
10
|
-
homa.egg-info/dependency_links.txt
|
|
11
|
-
homa.egg-info/requires.txt
|
|
12
|
-
homa.egg-info/top_level.txt
|
|
13
|
-
homa/classes/Collection.py
|
|
14
|
-
homa/classes/Logger.py
|
|
15
|
-
homa/classes/Repository.py
|
|
16
|
-
homa/classes/__init__.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|