Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lozuwa committed Mar 4, 2019
1 parent eb7fa43 commit 6f084c7
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 51 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Builds
build/
dist/
impy.egg-info/

# IDE foldres
.idea
.vscode
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
</ol>

<h1 id="#installation">Installation</h1>
<p>For now the installation requires you to clone the repository. Follow the next steps:</p>
<h2>Install with pip</h2>
<p>For now I am having trouble uploading my wheel to the impy repository. I will fix this shortly.</p>

<h2>Build a wheel and install with pip</h2>
<p></p>

<h2 id="Clone the repository"></h2>
<p>Follow the next steps:</p>
<ol>
<li>Go to your package path. E.g: for anaconda go to ../Anaconda3/envs/YOUR_ENVIRONMENT/lib/pythonVERSION_OF_YOUR_PYTHON/site-packages/</li>
<li>Clone the library with the following command git clone https://github.com/lozuwa/impy.git</li>
Expand Down
17 changes: 14 additions & 3 deletions impy/ApplyAugmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,20 @@
"""

import numpy as np
from BoundingBoxAugmenters import *
from ColorAugmenters import *
from GeometricAugmenters import *
try:
from .BoundingBoxAugmenters import *
except:
from BoundingBoxAugmenters import *

try:
from .ColorAugmenters import *
except:
from ColorAugmenters import *

try:
from .GeometricAugmenters import *
except:
from GeometricAugmenters import *

bndboxAugmenter = BoundingBoxAugmenters()
colorAugmenter = ColorAugmenters()
Expand Down
24 changes: 19 additions & 5 deletions impy/BoundingBoxAugmenters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,25 @@
import cv2
import numpy as np
# Other libraries
from ImagePreprocess import *
# Interface
from BoundingBoxAugmentersMethods import *
from GeometricAugmenters import *
from AssertDataTypes import *
try:
from .ImagePreprocess import *
except:
from ImagePreprocess import *

try:
from .BoundingBoxAugmentersMethods import *
except:
from BoundingBoxAugmentersMethods import *

try:
from .GeometricAugmenters import *
except:
from GeometricAugmenters import *

try:
from .AssertDataTypes import *
except:
from AssertDataTypes import *

# class BoundingBoxAugmenters(implements(BoundingBoxAugmentersMethods)):
class BoundingBoxAugmenters(object):
Expand Down
17 changes: 14 additions & 3 deletions impy/ColorAugmenters.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,20 @@
import cv2
import numpy as np

from ColorAugmentersMethods import *
from VectorOperations import *
from AssertDataTypes import *
try:
from .ColorAugmentersMethods import *
except:
from ColorAugmentersMethods import *

try:
from .VectorOperations import *
except:
from VectorOperations import *

try:
from .AssertDataTypes import *
except:
from AssertDataTypes import *

# class ColorAugmenters(implements(ColorAugmentersMethods)):
class ColorAugmenters(object):
Expand Down
17 changes: 14 additions & 3 deletions impy/GeometricAugmenters.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,20 @@
import cv2
import numpy as np

from GeometricAugmentersMethods import *
from VectorOperations import *
from AssertDataTypes import *
try:
from .GeometricAugmentersMethods import *
except:
from GeometricAugmentersMethods import *

try:
from .VectorOperations import *
except:
from VectorOperations import *

try:
from .AssertDataTypes import *
except:
from AssertDataTypes import *

# class GeometricAugmenters(implements(GeometricAugmentersMethods)):
class GeometricAugmenters(object):
Expand Down
17 changes: 14 additions & 3 deletions impy/ImageDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,20 @@
from interface import implements
from tqdm import tqdm

from AugmentationConfigurationFile import *
from ApplyAugmentation import applyGeometricAugmentation, applyColorAugmentation
from Util import *
try:
from .AugmentationConfigurationFile import *
except:
from AugmentationConfigurationFile import *

try:
from .ApplyAugmentation import applyGeometricAugmentation, applyColorAugmentation
except:
from ApplyAugmentation import applyGeometricAugmentation, applyColorAugmentation

try:
from .Util import *
except:
from Util import *

class ImageDataset(object):
def __init__(self, imagesDirectory = None, dbName = None):
Expand Down
9 changes: 5 additions & 4 deletions impy/ImageDataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ def tearDown(self):
pass

def test_apply_data_augmentation(self):
os.system("rm {}/*".format(os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_single")))
conf_file = os.path.join(os.getcwd(), "../", "confs_examples", \
outputImageDirectory:str=os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_single")
os.system("rm -r {}".format(outputImageDirectory))
os.mkdir(outputImageDirectory)
conf_file:str = os.path.join(os.getcwd(), "../", "confs_examples", \
"aug_multiple_geometric_color_sequential.json")
self.imda.applyDataAugmentation(configurationFile = conf_file, \
outputImageDirectory = os.path.join(os.getcwd(), \
"../", "../", "cars_dataset", "images_single"))
outputImageDirectory = outputImageDirectory)

if __name__ == "__main__":
unittest.main()
53 changes: 44 additions & 9 deletions impy/ObjectDetectionDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,50 @@
# from interface import implements
from tqdm import tqdm

from ObjectDetectionDatasetPreprocessMethods import *
from ObjectDetectionDatasetStatisticsMethods import *
from ImagePreprocess import *
from ImageAnnotation import *
from VectorOperations import *
from Util import *
from AssertDataTypes import *
from AugmentationConfigurationFile import *
from ApplyAugmentation import applyBoundingBoxAugmentation, applyColorAugmentation
try:
from .ObjectDetectionDatasetPreprocessMethods import *
except:
from ObjectDetectionDatasetPreprocessMethods import *

try:
from .ObjectDetectionDatasetStatisticsMethods import *
except:
from ObjectDetectionDatasetStatisticsMethods import *

try:
from .ImagePreprocess import *
except:
from ImagePreprocess import *

try:
from .ImageAnnotation import *
except:
from ImageAnnotation import *

try:
from .VectorOperations import *
except:
from VectorOperations import *

try:
from .Util import *
except:
from Util import *

try:
from .AssertDataTypes import *
except:
from AssertDataTypes import *

try:
from .AugmentationConfigurationFile import *
except:
from AugmentationConfigurationFile import *

try:
from .ApplyAugmentation import applyBoundingBoxAugmentation, applyColorAugmentation
except:
from ApplyAugmentation import applyBoundingBoxAugmentation, applyColorAugmentation

prep = ImagePreprocess()
dataAssertion = AssertDataTypes()
Expand Down
44 changes: 27 additions & 17 deletions impy/ObjectDetectionDataset_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Author: Rodrigo Loza
Email: [email protected]
Description: Testing units for ImageLocalizationDataset.
Description: Unit tests for ObjectDetectionDataset.
"""
import os
import unittest
Expand All @@ -11,8 +11,8 @@
class ObjectDetectionDataset_test(unittest.TestCase):

def setUp(self):
self.imgs = os.path.join(os.getcwd(), "tests", "cars_dataset", "images")
self.annts = os.path.join(os.getcwd(), "tests", "cars_dataset", "annotations", "xmls")
self.imgs = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images")
self.annts = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations", "xmls")
self.imda = ObjectDetectionDataset(imagesDirectory = self.imgs,
annotationsDirectory = self.annts,
databaseName = "unit_test")
Expand All @@ -21,24 +21,31 @@ def tearDown(self):
pass

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

def test_reduceDatasetByRois(self):
outputImageDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "images_reduced")
outputAnnotationDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "annotations_reduced", "xmls")
os.system("rm {}/*".format(outputImageDirectory))
os.system("rm {}/*".format(outputAnnotationDirectory))
outputImageDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_reduced")
outputAnnotationDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_reduced", "xmls")
os.system("rm -r {}".format(outputImageDirectory))
os.system("rm -r {}".format(os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_reduced")))
os.mkdir("../../cars_dataset/images_reduced/")
os.mkdir("../../cars_dataset/annotations_reduced/")
os.mkdir("../../cars_dataset/annotations_reduced/xmls/")
# Reduce dataset by grouping ROIs into smaller frames.
self.imda.reduceDatasetByRois(offset = [300, 300],
outputImageDirectory = outputImageDirectory,
outputAnnotationDirectory = outputAnnotationDirectory)

def test_reduceImageDataPointByRoi(self):
outputImageDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "images_reduced_single")
outputAnnotationDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "annotations_reduced_single", "xmls")
os.system("rm {}/* {}/*".format(outputImageDirectory, outputAnnotationDirectory))
outputImageDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_reduced_single")
outputAnnotationDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_reduced_single", "xmls")
os.system("rm -r {} {}".format(outputImageDirectory, os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_reduced_single")))
os.mkdir("../../cars_dataset/images_reduced_single/")
os.mkdir("../../cars_dataset/annotations_reduced_single/")
os.mkdir("../../cars_dataset/annotations_reduced_single/xmls/")
offset = 300
for i in range(1):
for each in os.listdir(self.imgs):
Expand All @@ -57,11 +64,14 @@ def test_reduceImageDataPointByRoi(self):
offset += 250

def test_applyDataAugmentation(self):
outputImageDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "images_augmented")
outputAnnotationDirectory = os.path.join(os.getcwd(), "tests", "cars_dataset", "annotations_augmented", "xmls")
os.system("rm {}/*".format(outputImageDirectory))
os.system("rm {}/*".format(outputAnnotationDirectory))
aug_file = os.path.join(os.getcwd(), "tests", "cars_dataset", "aug_configuration_cars.json")
outputImageDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "images_augmented")
outputAnnotationDirectory = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_augmented", "xmls")
os.system("rm -r {}".format(outputImageDirectory))
os.system("rm -r {}".format(os.path.join(os.getcwd(), "../", "../", "cars_dataset", "annotations_augmented")))
os.mkdir("../../cars_dataset/images_augmented/")
os.mkdir("../../cars_dataset/annotations_augmented/")
os.mkdir("../../cars_dataset/annotations_augmented/xmls/")
aug_file = os.path.join(os.getcwd(), "../", "../", "cars_dataset", "aug_configuration_cars.json")
self.imda.applyDataAugmentation(configurationFile = aug_file,
outputImageDirectory = outputImageDirectory,
outputAnnotationDirectory = outputAnnotationDirectory)
Expand Down
2 changes: 1 addition & 1 deletion impy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
>>> from impy.Images2Dataset import Images2Dataset
"""
# Import libraries
# Import libraries
# from AnnotationProcessing import *
# from ApplyAugmentation import *
# from AssertDataTypes import *
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="impy",
version="0.1",
version="1.0",
author="Rodrigo Alejandro Loza Lucero",
author_email="[email protected]",
description="A library to apply data augmentation to your image datasets",
Expand Down Expand Up @@ -33,4 +33,4 @@
"License :: OSI Approved :: APACHE",
"Operating System :: OS Independent",
],
)
)

0 comments on commit 6f084c7

Please sign in to comment.