Skip to content

Commit 6f084c7

Browse files
committed
---
type: fix description: - libraries are imported with a try/catch so development and building be easy to work with. - setup.py packages correctly the impy folder
1 parent eb7fa43 commit 6f084c7

12 files changed

+167
-51
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Builds
2+
build/
3+
dist/
4+
impy.egg-info/
5+
16
# IDE foldres
27
.idea
38
.vscode

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@
1717
</ol>
1818

1919
<h1 id="#installation">Installation</h1>
20-
<p>For now the installation requires you to clone the repository. Follow the next steps:</p>
20+
<h2>Install with pip</h2>
21+
<p>For now I am having trouble uploading my wheel to the impy repository. I will fix this shortly.</p>
22+
23+
<h2>Build a wheel and install with pip</h2>
24+
<p></p>
25+
26+
<h2 id="Clone the repository"></h2>
27+
<p>Follow the next steps:</p>
2128
<ol>
2229
<li>Go to your package path. E.g: for anaconda go to ../Anaconda3/envs/YOUR_ENVIRONMENT/lib/pythonVERSION_OF_YOUR_PYTHON/site-packages/</li>
2330
<li>Clone the library with the following command git clone https://github.com/lozuwa/impy.git</li>

impy/ApplyAugmentation.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@
55
"""
66

77
import numpy as np
8-
from BoundingBoxAugmenters import *
9-
from ColorAugmenters import *
10-
from GeometricAugmenters import *
8+
try:
9+
from .BoundingBoxAugmenters import *
10+
except:
11+
from BoundingBoxAugmenters import *
12+
13+
try:
14+
from .ColorAugmenters import *
15+
except:
16+
from ColorAugmenters import *
17+
18+
try:
19+
from .GeometricAugmenters import *
20+
except:
21+
from GeometricAugmenters import *
1122

1223
bndboxAugmenter = BoundingBoxAugmenters()
1324
colorAugmenter = ColorAugmenters()

impy/BoundingBoxAugmenters.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,25 @@
4141
import cv2
4242
import numpy as np
4343
# Other libraries
44-
from ImagePreprocess import *
45-
# Interface
46-
from BoundingBoxAugmentersMethods import *
47-
from GeometricAugmenters import *
48-
from AssertDataTypes import *
44+
try:
45+
from .ImagePreprocess import *
46+
except:
47+
from ImagePreprocess import *
48+
49+
try:
50+
from .BoundingBoxAugmentersMethods import *
51+
except:
52+
from BoundingBoxAugmentersMethods import *
53+
54+
try:
55+
from .GeometricAugmenters import *
56+
except:
57+
from GeometricAugmenters import *
58+
59+
try:
60+
from .AssertDataTypes import *
61+
except:
62+
from AssertDataTypes import *
4963

5064
# class BoundingBoxAugmenters(implements(BoundingBoxAugmentersMethods)):
5165
class BoundingBoxAugmenters(object):

impy/ColorAugmenters.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,20 @@
4242
import cv2
4343
import numpy as np
4444

45-
from ColorAugmentersMethods import *
46-
from VectorOperations import *
47-
from AssertDataTypes import *
45+
try:
46+
from .ColorAugmentersMethods import *
47+
except:
48+
from ColorAugmentersMethods import *
49+
50+
try:
51+
from .VectorOperations import *
52+
except:
53+
from VectorOperations import *
54+
55+
try:
56+
from .AssertDataTypes import *
57+
except:
58+
from AssertDataTypes import *
4859

4960
# class ColorAugmenters(implements(ColorAugmentersMethods)):
5061
class ColorAugmenters(object):

impy/GeometricAugmenters.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,20 @@
3636
import cv2
3737
import numpy as np
3838

39-
from GeometricAugmentersMethods import *
40-
from VectorOperations import *
41-
from AssertDataTypes import *
39+
try:
40+
from .GeometricAugmentersMethods import *
41+
except:
42+
from GeometricAugmentersMethods import *
43+
44+
try:
45+
from .VectorOperations import *
46+
except:
47+
from VectorOperations import *
48+
49+
try:
50+
from .AssertDataTypes import *
51+
except:
52+
from AssertDataTypes import *
4253

4354
# class GeometricAugmenters(implements(GeometricAugmentersMethods)):
4455
class GeometricAugmenters(object):

impy/ImageDataset.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,20 @@
1111
from interface import implements
1212
from tqdm import tqdm
1313

14-
from AugmentationConfigurationFile import *
15-
from ApplyAugmentation import applyGeometricAugmentation, applyColorAugmentation
16-
from Util import *
14+
try:
15+
from .AugmentationConfigurationFile import *
16+
except:
17+
from AugmentationConfigurationFile import *
18+
19+
try:
20+
from .ApplyAugmentation import applyGeometricAugmentation, applyColorAugmentation
21+
except:
22+
from ApplyAugmentation import applyGeometricAugmentation, applyColorAugmentation
23+
24+
try:
25+
from .Util import *
26+
except:
27+
from Util import *
1728

1829
class ImageDataset(object):
1930
def __init__(self, imagesDirectory = None, dbName = None):

impy/ImageDataset_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ def tearDown(self):
1515
pass
1616

1717
def test_apply_data_augmentation(self):
18-
os.system("rm {}/*".format(os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_single")))
19-
conf_file = os.path.join(os.getcwd(), "../", "confs_examples", \
18+
outputImageDirectory:str=os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_single")
19+
os.system("rm -r {}".format(outputImageDirectory))
20+
os.mkdir(outputImageDirectory)
21+
conf_file:str = os.path.join(os.getcwd(), "../", "confs_examples", \
2022
"aug_multiple_geometric_color_sequential.json")
2123
self.imda.applyDataAugmentation(configurationFile = conf_file, \
22-
outputImageDirectory = os.path.join(os.getcwd(), \
23-
"../", "../", "cars_dataset", "images_single"))
24+
outputImageDirectory = outputImageDirectory)
2425

2526
if __name__ == "__main__":
2627
unittest.main()

impy/ObjectDetectionDataset.py

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,50 @@
1111
# from interface import implements
1212
from tqdm import tqdm
1313

14-
from ObjectDetectionDatasetPreprocessMethods import *
15-
from ObjectDetectionDatasetStatisticsMethods import *
16-
from ImagePreprocess import *
17-
from ImageAnnotation import *
18-
from VectorOperations import *
19-
from Util import *
20-
from AssertDataTypes import *
21-
from AugmentationConfigurationFile import *
22-
from ApplyAugmentation import applyBoundingBoxAugmentation, applyColorAugmentation
14+
try:
15+
from .ObjectDetectionDatasetPreprocessMethods import *
16+
except:
17+
from ObjectDetectionDatasetPreprocessMethods import *
18+
19+
try:
20+
from .ObjectDetectionDatasetStatisticsMethods import *
21+
except:
22+
from ObjectDetectionDatasetStatisticsMethods import *
23+
24+
try:
25+
from .ImagePreprocess import *
26+
except:
27+
from ImagePreprocess import *
28+
29+
try:
30+
from .ImageAnnotation import *
31+
except:
32+
from ImageAnnotation import *
33+
34+
try:
35+
from .VectorOperations import *
36+
except:
37+
from VectorOperations import *
38+
39+
try:
40+
from .Util import *
41+
except:
42+
from Util import *
43+
44+
try:
45+
from .AssertDataTypes import *
46+
except:
47+
from AssertDataTypes import *
48+
49+
try:
50+
from .AugmentationConfigurationFile import *
51+
except:
52+
from AugmentationConfigurationFile import *
53+
54+
try:
55+
from .ApplyAugmentation import applyBoundingBoxAugmentation, applyColorAugmentation
56+
except:
57+
from ApplyAugmentation import applyBoundingBoxAugmentation, applyColorAugmentation
2358

2459
prep = ImagePreprocess()
2560
dataAssertion = AssertDataTypes()

impy/ObjectDetectionDataset_test.py

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Author: Rodrigo Loza
33
Email: lozuwaucb@gmail.com
4-
Description: Testing units for ImageLocalizationDataset.
4+
Description: Unit tests for ObjectDetectionDataset.
55
"""
66
import os
77
import unittest
@@ -11,8 +11,8 @@
1111
class ObjectDetectionDataset_test(unittest.TestCase):
1212

1313
def setUp(self):
14-
self.imgs = os.path.join(os.getcwd(), "tests", "cars_dataset", "images")
15-
self.annts = os.path.join(os.getcwd(), "tests", "cars_dataset", "annotations", "xmls")
14+
self.imgs = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images")
15+
self.annts = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations", "xmls")
1616
self.imda = ObjectDetectionDataset(imagesDirectory = self.imgs,
1717
annotationsDirectory = self.annts,
1818
databaseName = "unit_test")
@@ -21,24 +21,31 @@ def tearDown(self):
2121
pass
2222

2323
def test_bounding_boxes(self):
24-
outputDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "bounding_boxes")
25-
os.system("rm {}/*".format(outputDirectory))
24+
outputDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "bounding_boxes")
25+
os.system("rm -r {}".format(outputDirectory))
26+
os.mkdir("../../cars_dataset/bounding_boxes")
2627
self.imda.saveBoundingBoxes(outputDirectory = outputDirectory, filterClasses = ["pedestrian", "car"])
2728

2829
def test_reduceDatasetByRois(self):
29-
outputImageDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "images_reduced")
30-
outputAnnotationDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "annotations_reduced", "xmls")
31-
os.system("rm {}/*".format(outputImageDirectory))
32-
os.system("rm {}/*".format(outputAnnotationDirectory))
30+
outputImageDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_reduced")
31+
outputAnnotationDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_reduced", "xmls")
32+
os.system("rm -r {}".format(outputImageDirectory))
33+
os.system("rm -r {}".format(os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_reduced")))
34+
os.mkdir("../../cars_dataset/images_reduced/")
35+
os.mkdir("../../cars_dataset/annotations_reduced/")
36+
os.mkdir("../../cars_dataset/annotations_reduced/xmls/")
3337
# Reduce dataset by grouping ROIs into smaller frames.
3438
self.imda.reduceDatasetByRois(offset = [300, 300],
3539
outputImageDirectory = outputImageDirectory,
3640
outputAnnotationDirectory = outputAnnotationDirectory)
3741

3842
def test_reduceImageDataPointByRoi(self):
39-
outputImageDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "images_reduced_single")
40-
outputAnnotationDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "annotations_reduced_single", "xmls")
41-
os.system("rm {}/* {}/*".format(outputImageDirectory, outputAnnotationDirectory))
43+
outputImageDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_reduced_single")
44+
outputAnnotationDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_reduced_single", "xmls")
45+
os.system("rm -r {} {}".format(outputImageDirectory, os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_reduced_single")))
46+
os.mkdir("../../cars_dataset/images_reduced_single/")
47+
os.mkdir("../../cars_dataset/annotations_reduced_single/")
48+
os.mkdir("../../cars_dataset/annotations_reduced_single/xmls/")
4249
offset = 300
4350
for i in range(1):
4451
for each in os.listdir(self.imgs):
@@ -57,11 +64,14 @@ def test_reduceImageDataPointByRoi(self):
5764
offset += 250
5865

5966
def test_applyDataAugmentation(self):
60-
outputImageDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "images_augmented")
61-
outputAnnotationDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "annotations_augmented", "xmls")
62-
os.system("rm {}/*".format(outputImageDirectory))
63-
os.system("rm {}/*".format(outputAnnotationDirectory))
64-
aug_file = os.path.join(os.getcwd(), "tests", "cars_dataset", "aug_configuration_cars.json")
67+
outputImageDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_augmented")
68+
outputAnnotationDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_augmented", "xmls")
69+
os.system("rm -r {}".format(outputImageDirectory))
70+
os.system("rm -r {}".format(os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_augmented")))
71+
os.mkdir("../../cars_dataset/images_augmented/")
72+
os.mkdir("../../cars_dataset/annotations_augmented/")
73+
os.mkdir("../../cars_dataset/annotations_augmented/xmls/")
74+
aug_file = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "aug_configuration_cars.json")
6575
self.imda.applyDataAugmentation(configurationFile = aug_file,
6676
outputImageDirectory = outputImageDirectory,
6777
outputAnnotationDirectory = outputAnnotationDirectory)

impy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
>>> from impy.Images2Dataset import Images2Dataset
1818
1919
"""
20-
# Import libraries
20+
# Import libraries
2121
# from AnnotationProcessing import *
2222
# from ApplyAugmentation import *
2323
# from AssertDataTypes import *

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="impy",
8-
version="0.1",
8+
version="1.0",
99
author="Rodrigo Alejandro Loza Lucero",
1010
author_email="lozuwaucb@gmail.com",
1111
description="A library to apply data augmentation to your image datasets",
@@ -33,4 +33,4 @@
3333
"License :: OSI Approved :: APACHE",
3434
"Operating System :: OS Independent",
3535
],
36-
)
36+
)

0 commit comments

Comments
 (0)