{"id":13545705,"url":"https://github.com/lozuwa/impy","last_synced_at":"2025-04-02T16:30:43.324Z","repository":{"id":104774266,"uuid":"100673670","full_name":"lozuwa/impy","owner":"lozuwa","description":"Impy is a Python3 library with features that help you in your computer vision tasks. ","archived":false,"fork":false,"pushed_at":"2019-03-04T23:04:50.000Z","size":95869,"stargazers_count":116,"open_issues_count":6,"forks_count":32,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-03T12:33:08.334Z","etag":null,"topics":["dataset","exploratory-data-analysis","machine-learning","preprocessing","raw-data","statistics","tidy-data"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lozuwa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-08-18T04:46:18.000Z","updated_at":"2024-02-24T15:05:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe060447-cbb3-4f58-a089-149ede0e0d28","html_url":"https://github.com/lozuwa/impy","commit_stats":{"total_commits":136,"total_committers":2,"mean_commits":68.0,"dds":0.007352941176470562,"last_synced_commit":"ddfaedf764c1cb2ced7f644a3a065715758874a5"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lozuwa%2Fimpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lozuwa%2Fimpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lozuwa%2Fimpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lozuwa%2Fimpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lozuwa","download_url":"https://codeload.github.com/lozuwa/impy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246850728,"owners_count":20844135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dataset","exploratory-data-analysis","machine-learning","preprocessing","raw-data","statistics","tidy-data"],"created_at":"2024-08-01T11:01:10.444Z","updated_at":"2025-04-02T16:30:43.315Z","avatar_url":"https://github.com/lozuwa.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003ch1\u003e Impy (Images in python) \u003c/h1\u003e\n\u003cp\u003eImpy is a library used for deep learning projects that use image datasets.\u003c/p\u003e\n\u003cul\u003e\n  \u003cli\u003e\u003cstrong\u003eEmail: \u003c/strong\u003elozuwaucb@gmail.com\u003c/li\u003e\n  \u003cli\u003e\u003cstrong\u003eBug reports: \u003c/strong\u003ehttps://github.com/lozuwa/impy/issues\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eIt provides:\u003c/p\u003e\n\u003cul\u003e\n  \u003cli\u003eData augmentation methods for images with bounding boxes (the bounding boxes are also affected by the transformations so you don't have to label again.)\u003c/li\u003e\n  \u003cli\u003eFast image preprocessing methods useful in a deep learning context. E.g: if your image is too big you need to divide it into patches.\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003col\u003e\n\t\u003cli\u003e\u003ca href=\"installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href=\"tutorial\"\u003eTutorial\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href=\"documentation\"\u003eDocumentation\u003c/a\u003e\u003c/li\u003e\n\t\u003cli\u003e\u003ca href=\"contribute\"\u003eContribute\u003c/a\u003e\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch1 id=\"#installation\"\u003eInstallation\u003c/h1\u003e\n\n\u003ch2\u003eDownload the impy.whl and use pip to install it.\u003c/h2\u003e\n\u003cp\u003eFollow the next steps:\u003c/p\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eDownload the impy.whl from \u003ca href=\"https://github.com/lozuwa/impy/releases/download/impy-0.1/impy-0.1-py3-none-any.whl\"\u003ehere\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eUse pip to install the wheel\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\npip install impy-0.1-py3-none-any.whl\n```\n\n\u003ch1 id=\"#tutorial\"\u003eTutorial\u003c/h1\u003e\n\u003cp\u003eImpy has multiple features that allow you to solve several different problems with a few lines of code. In order to showcase the features of impy we are going to solve common problems that involve both Computer Vision and Deep Learning. \u003c/p\u003e\n\u003cp\u003eWe are going to work with a mini-dataset of cars and pedestrians (available \u003ca href=\"https://github.com/lozuwa/cars_dataset\"\u003ehere\u003c/a\u003e). This dataset has object annotations that make it suitable to solve a localization problem. \u003c/p\u003e\n\n\u003c!-- ![Alt text](static/cars0.png?raw=true \"Car's mini dataset\") --\u003e\n\u003c!-- \u003cimg src=\"static//cars3.png\" alt=\"cars\" height=\"600\" width=\"800\"\u003e\u003c/img\u003e --\u003e\n\n\u003ch2\u003eObject localization\u003c/h2\u003e\n\u003cp\u003eIn this section we are going to solve problems related with object localization.\u003c/p\u003e\n\n\u003ch3\u003eImages are too big\u003c/h3\u003e\n\u003cp\u003eOne common problem in Computer Vision and CNNs is dealing with big images. Let's sample one of the images from our mini-dataset: \u003c/p\u003e\n\n\u003c!-- ![Alt text](static/cars3.png?raw=true \"Example of big image.\") --\u003e\n\u003cimg src=\"static//cars1.png\" alt=\"cars\" height=\"600\" width=\"800\"\u003e\u003c/img\u003e\n\n\u003cp\u003eThe size of this image is 3840x2160. It is too big for training. Most likely, your computer will run out of memory. In order to try to solve the big image problem, we could reduce the size of the mini-batch hyperparameter. But if the image is too big it would still not work. We could also try to reduce the size of the image. But that means the image losses quality and you would need to label the smaller image again. \u003c/p\u003e\n\u003cp\u003eInstead of hacking a solution, we are going to solve the problem efficiently. The best solution is to sample crops of a specific size that contain the maximum amount of bounding boxes possible. Crops of 1032x1032 pixels are usually small enough.\u003c/p\u003e\n\n\u003cp\u003eLet's see how to do this with impy:\u003c/p\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eCreate a folder named \u003cb\u003etesting_cars\u003c/b\u003e. Then enter the folder.\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\n\tmkdir -p $PWD/testing_cars\n\tcd testing_cars\n```\n\n\u003cul\u003e\n\t\u003cli\u003eDownload the cars dataset from \u003ca href=\"https://github.com/lozuwa/cars_dataset\"\u003ehere\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\ngit clone https://github.com/lozuwa/cars_dataset\n```\n\n\u003cul\u003e\n\t\u003cli\u003eCreate a file named reducing_big_images.py and put the next code:\u003c/li\u003e\n\u003c/ul\u003e\n\n```python\nimport os\nfrom impy.ObjectDetectionDataset import ObjectDetectionDataset\n\ndef main():\n\t# Define the path to images and annotations\n\timages_path:str = os.path.join(os.getcwd(), \"cars_dataset\", \"images\")\n\tannotations_path:str = os.path.join(os.getcwd(), \"cars_dataset\", \"annotations\", \"xmls\")\n\t# Define the name of the dataset\n\tdbName:str = \"CarsDataset\"\n\t# Create an object of ObjectDetectionDataset\n\tobda:any = ObjectDetectionDataset(imagesDirectory=images_path, annotationsDirectory=annotations_path, databaseName=dbName)\n\t# Reduce the dataset to smaller Rois of smaller ROIs of shape 1032x1032.\n\toffset:list=[1032, 1032]\n\timages_output_path:str = os.path.join(os.getcwd(), \"cars_dataset\", \"images_reduced\")\n\tannotations_output_path:str = os.path.join(os.getcwd(), \"cars_dataset\", \"annotations_reduced\", \"xmls\")\n\tobda.reduceDatasetByRois(offset = offset, outputImageDirectory = images_output_path, outputAnnotationDirectory = annotations_output_path)\n\nif __name__ == \"__main__\":\n\tmain()\n```\n\n\u003cul\u003e\n\t\u003cli\u003e\u003cb\u003eNote\u003c/b\u003e the paths where we are going to store the reduced images don't exist. Let's create them.\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\nmkdir -p $PWD/cars_dataset/images_reduced/\nmkdir -p $PWD/cars_dataset/annotations_reduced/xmls/\n```\n\n\u003cul\u003e\n\t\u003cli\u003eNow we can run the script and reduce the images to smaller crops.\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\npython reducing_big_images.py\n```\n\n\u003cp\u003eImpy will create a new set of images and annotations with the size specified by offset and will include the maximum number of annotations possible so you will end up with an optimal number of data points. Let's see the results of the example: \u003c/p\u003e\n\n\u003cimg src=\"static//cars11.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars12.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars13.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars14.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars15.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars16.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars17.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars18.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars19.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars20.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\u003cimg src=\"static//cars21.png\" alt=\"cars\" height=\"300\" width=\"300\"\u003e\u003c/img\u003e\n\n\u003cp\u003eAs you can see the bounding boxes have been maintained and small crops of the big image are now available. We can use this images for training and our problem is solved.\u003c/p\u003e\n\n\u003cp\u003e\u003cstrong\u003eNote\u003c/strong\u003e that in some cases you are going to end up with an inefficient amount of crops due to overlapping crops in the clustering algorithm. I am working on this and a better solution will be released soon. Nonetheless, these results are still way more efficient than what is usually done which is crop each bounding box one by one (This leads to inefficient memory usage, repeated data points, lose of context and simpler representation.).\u003c/p\u003e\n\n\u003ch3\u003eData augmentation for bounding boxes\u003c/h3\u003e\n\u003cp\u003eAnother common problem in Computer Vision and CNNs for object localization is data augmentation. Specifically space augmentations (e.g: scaling, cropping, rotation, etc.). For this you would usually make a custom script. But with impy we can make this easier.\u003c/p\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eCreate a json file named \u003cb\u003eaugmentation_configuration.json\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\ntouch augmentation_configuration.json\n```\n\n\u003cul\u003e\n\t\u003cli\u003eInsert the following code in the \u003cb\u003eaugmentation_configuration.json\u003c/b\u003e file\u003c/li\u003e\n\u003c/ul\u003e\n\n```json\n{\n\t\"multiple_image_augmentations\": {\n\t\t\"Sequential\": [\n\t\t\t{\n\t\t\t\t\"image_color_augmenters\": {\n\t\t\t\t\t\"Sequential\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"sharpening\": {\n\t\t\t\t\t\t\t\t\"weight\": 2.0,\n\t\t\t\t\t\t\t\t\"save\": true,\n\t\t\t\t\t\t\t\t\"restartFrame\": false,\n\t\t\t\t\t\t\t\t\"randomEvent\": false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"bounding_box_augmenters\": {\n\t\t\t\t\t\"Sequential\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"scale\": {\n\t\t\t\t\t\t\t\t\"size\": [1.2, 1.2],\n\t\t\t\t\t\t\t\t\"zoom\": true,\n\t\t\t\t\t\t\t\t\"interpolationMethod\": 1,\n\t\t\t\t\t\t\t\t\"save\": true,\n\t\t\t\t\t\t\t\t\"restartFrame\": false,\n\t\t\t\t\t\t\t\t\"randomEvent\": false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"verticalFlip\": {\n\t\t\t\t\t\t\t\t\"save\": true,\n\t\t\t\t\t\t\t\t\"restartFrame\": false,\n\t\t\t\t\t\t\t\t\"randomEvent\": true\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"image_color_augmenters\": {\n\t\t\t\t\t\"Sequential\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"histogramEqualization\":{\n\t\t\t\t\t\t\t\t\"equalizationType\": 1,\n\t\t\t\t\t\t\t\t\"save\": true,\n\t\t\t\t\t\t\t\t\"restartFrame\": false,\n\t\t\t\t\t\t\t\t\"randomEvent\": false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"bounding_box_augmenters\": {\n\t\t\t\t\t\"Sequential\": [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"horizontalFlip\": {\n\t\t\t\t\t\t\t\t\"save\": true,\n\t\t\t\t\t\t\t\t\"restartFrame\": false,\n\t\t\t\t\t\t\t\t\"randomEvent\": false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\"crop\": {\n\t\t\t\t\t\t\t\t\"save\": true,\n\t\t\t\t\t\t\t\t\"restartFrame\": true,\n\t\t\t\t\t\t\t\t\"randomEvent\": false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}\n\t\t\t}\n\t\t]\n\t}\n}\n```\n\n\u003cp\u003eLet's analyze the configuration file step by step. Currently, this is the most complex type of data augmentation you can achieve with the library.\u003c/p\u003e\n\u003cp\u003eNote the file starts with \"multiple_image_augmentations\", then a \"Sequential\" key follows. Inside \"Sequential\" we define an array. This is important, each element of the array is a type of augmenter.\u003c/p\u003e\n\u003cp\u003eThe first augmenter we are going to define is a \"image_color_agumenters\" which is going to execute a sequence of color augmentations. In this case, we have defined only one type of color augmentation which is sharpening with a weight of 2.0.\u003c/p\u003e\n\u003cp\u003eAfter the color augmentation, we have defined a \"bounding_box_augmenters\" which is going to execute a \"scale\" augmentation with zoom  followed by a \"verticalFlip\".\u003c/p\u003e\n\u003cp\u003eWe want to keep going. So we define two more types of image augmenters. Another \"image_color_augmenters\" which applies \"histogramEqualization\" to the image. And another \"bounding_box_agumeneters\" which applies a \"horizontalFlip\" and a \"crop\" augmentation.\u003c/p\u003e\n\n\u003cp\u003eNote there are three types of parameters in each augmenter. These are optional, but I recommend specifying them in order to fully understand your pipeline. These parameters are:\u003c/p\u003e\n\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Save\"\u003c/strong\u003e: saves the current transformation if True.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Restart frame\"\u003c/strong\u003e: restarts the frame to its original space if True, otherwise maintains the augmentation applied so far.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Random event\"\u003c/strong\u003e: uses an stochastic function to randomize whether this augmentation might be applied or not.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003cp\u003eAs you have seen we can define any type of crazy configuration and augment our images with the available methods while choosing whether to save each augmentation, restart the frame to its original space or randomize the event so we make things crazier. Get creative and define your own data augmentation pipelines.\u003c/p\u003e\n\n\u003cp\u003eOnce the configuration file is created, we can apply the data augmentation pipeline with the following code.\u003c/p\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eAfter defining the augmentation file, let's create the code to apply the augmentations. Create a file named: \u003cb\u003eapply_bounding_box_augmentations.py\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eInsert the following code to \u003cb\u003eapply_bounding_box_augmentations.py\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n```python\nimport os\nfrom impy.ObjectDetectionDataset import ObjectDetectionDataset\n\ndef main():\n\t# Define the path to images and annotations\n\timages_path:str=os.path.join(os.getcwd(), \"cars_dataset\", \"images\")\n\tannotations_path:str=os.path.join(os.getcwd(), \"cars_dataset\", \"annotations\", \"xmls\")\n\t# Define the name of the dataset\n\tdbName:str=\"CarsDataset\"\n\t# Create an ObjectDetectionDataset object\n\tobda:any=ObjectDetectionDataset(imagesDirectory=images_path, annotationsDirectory=annotations_path, databaseName=dbName)\n\t# Apply data augmentation by using the following method of the ObjectDetectionDataset class.\n\tconfiguration_file:str=os.path.join(os.getcwd(), \"augmentation_configuration.json\")\n\timages_output_path:str=os.path.join(os.getcwd(), \"cars_dataset\", \"images_augmented\")\n\tannotations_output_path:str=os.path.join(os.getcwd(), \"cars_dataset\", \"annotations_augmented\", \"xmls\")\n\tobda.applyDataAugmentation(configurationFile=configuration_file, outputImageDirectory=images_output_path, outputAnnotationDirectory=annotations_output_path)\n\nif __name__ == \"__main__\":\n\tmain()\n```\n\n\u003cul\u003e\n\t\u003cli\u003eNow execute the scrip running:\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\npython apply_bounding_box_augmentations.py\n```\n\n\u003cp\u003eNext I present the results of the augmentations. Note the transformation does not alter the bounding boxes of the image which saves you a lot of time in case you want to increase the representational complexity of your data.\u003c/p\u003e\n\n\u003ch3\u003eSharpening\u003c/h3\u003e\n\u003cimg src=\"static//carsShar.png\" alt=\"Sharpened\" height=\"300\" width=\"500\"\u003e\u003c/img\u003e\n\n\u003ch3\u003eScaling (image gets a little bit bigger)\u003c/h3\u003e\n\u003cimg src=\"static//carsSc.png\" alt=\"Vertical flip\" height=\"300\" width=\"500\"\u003e\u003c/img\u003e\n\n\u003ch3\u003eVertical flip\u003c/h3\u003e\n\u003cimg src=\"static//carsVert.png\" alt=\"Crop\" height=\"300\" width=\"500\"\u003e\u003c/img\u003e\n\n\u003ch3\u003eHistogram equalization\u003c/h3\u003e\n\u003cimg src=\"static//carsHist.png\" alt=\"Histogram equalization\" height=\"300\" width=\"500\"\u003e\u003c/img\u003e\n\n\u003ch3\u003eHorizontal flip\u003c/h3\u003e\n\u003cimg src=\"static//carsHor.png\" alt=\"Horizontal flip\" height=\"300\" width=\"500\"\u003e\u003c/img\u003e\n\n\u003ch3\u003eCrop bounding boxes\u003c/h3\u003e\n\u003cimg src=\"static//carsCrop.png\" alt=\"Crop\" height=\"300\" width=\"500\"\u003e\u003c/img\u003e\n\n\u003ch1 id=\"#documentation\"\u003eDocumentation\u003c/h1\u003e\n\u003ch2\u003eObject detection dataset\u003c/h2\u003e\n\u003ch3\u003eObjectDetectionDataset class\u003c/h3\u003e\n\u003cp\u003eA class that holds a detection dataset. Parameters: \u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003eimagesDirectory:\u003c/strong\u003e A string that contains a path to a directory of images.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eannotationsDirectory:\u003c/strong\u003e A string that contains a path to a directory of xml annotations.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003edatabaseName:\u003c/strong\u003e A string that contains a name.\u003c/li\u003e\n\u003c/ol\u003e\n\u003cp\u003eClass methods:\u003c/p\u003e\n\u003ch4\u003edataConsistency\u003c/h4\u003e\n\u003cp\u003eChecks the consistency of the image files with the annotation files.\u003c/p\u003e\n\n\u003ch4\u003efindEmptyOrWrongAnnotations\u003c/h4\u003e\nExamines all the annotations in the dataset and detects if any is empty or wrong. A wrong annotation is said to contain a bounding box coordinate that is either greater than width/heigh respectively or is less than zero. \n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003eremoveEmpty:\u003c/strong\u003e A boolean that if True removes the annotations that are considered to be wrong or empty.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003ecomputeBoundingBoxStats\u003c/h4\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003esaveDataFrame:\u003c/strong\u003e A boolean that if True saves the dataframe with the stats. \u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eoutputDirDataFrame:\u003c/strong\u003e A string that contains a valid path.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003esaveBoundingBoxes\u003c/h4\u003e\n\u003cp\u003eSaves the bounding boxes of the data set as images. Parameters:\u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003eoutputDirectory:\u003c/strong\u003e A string that contains a path to a valid directory.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003efilterClasses:\u003c/strong\u003e A list of strings that contains classes that are supposed to be as labels in the dataset annotations.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003ereduceDatasetByRois\u003c/h4\u003e\n\u003cp\u003eIterate over images and annotations and execute redueImageDataPointByRoi for each one.\u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003eoffset:\u003c/strong\u003e A list or tuple of ints.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eoutputImageDirectory:\u003c/strong\u003e A string that contains a valid path.\u003c/li\u003e\t\n\t\u003cli\u003e\u003cstrong\u003eoutputAnnotationDirectory:\u003c/strong\u003e A string that contains a valid path.\u003c/li\u003e\t\n\u003c/ol\u003e\n\n\u003ch4\u003ereduceImageDataPointByRoi\u003c/h4\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003eimagePath:\u003c/strong\u003e A string that contains the path to an image.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eannotationPath:\u003c/strong\u003e A string that contains a path to a xml annotation.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eoffset\u003c/strong\u003e A list or tuple of ints.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eoutputImageDirectory:\u003c/strong\u003e A string that contains a valid path.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eoutputAnnotationDirectory:\u003c/strong\u003e A string that contains a valid path.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003eapplyDataAugmentation\u003c/h4\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003econfigurationFile:\u003c/strong\u003e A string that contains a path to a json file.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eoutputImageDirectory:\u003c/strong\u003e A string that contains a valid path.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eoutputAnnotationDirectory:\u003c/strong\u003e A string that contains a valid path.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003ethreshold:\u003c/strong\u003e A float in the range [0-1].\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003e__applyColorAugmentation__\u003c/h4\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003eframe:\u003c/strong\u003e A numpy tensor that contains an image.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eaugmentationType:\u003c/strong\u003e A string that contains a valid Impy augmentation type.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eparameters:\u003c/strong\u003e A list of strings that contains the respective parameters for the type of augmentation.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch4\u003e__applyBoundingBoxAugmentation__\u003c/h4\u003e\n\u003cp\u003e\u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003eframe:\u003c/strong\u003e A numpy tensor that contains an image.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eboundingBoxes:\u003c/strong\u003e A list of lists of ints that contains coordinates for a bounding box.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eaugmentationType:\u003c/strong\u003e A string that contains a valid Impy augmentation type.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003eparameters:\u003c/strong\u003e A list of strings that contains the respective parameters for the type of augmentation.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch2\u003eTypes of color augmentations\u003c/h2\u003e\n\u003cp\u003eAll of the augmentations ought to implement the following parameters:\u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Save\"\u003c/strong\u003e: saves the current transformation if True.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Restart frame\"\u003c/strong\u003e: restarts the frame to its original space if True, otherwise maintains the augmentation applied so far.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Random event\"\u003c/strong\u003e: uses an stochastic function to randomize whether this augmentation might be applied or not.\u003c/li\u003e\n\u003c/ol\u003e\n\n\u003ch3\u003eInvert color\u003c/h3\u003e\n\u003cp\u003eApply a bitwise_not operation to the pixels in the image. Code example: \u003c/p\u003e\n\n```json\n{\n\t\"invertColor\": {\n\t\t\"Cspace\": [true, true, true]\n\t}\n}\n```\n\n\u003ch3\u003eHistogram equalization\u003c/h3\u003e\n\u003cp\u003eEqualize the color space of the image. Code example: \u003c/p\u003e\n\n```json\n{\n\t\"histogramEqualization\": {\n\t\t\"equalizationType\": 1\n\t}\n}\n```\n\n\u003ch3\u003eChange brightness\u003c/h3\u003e\n\u003cp\u003eMultiply the pixel distribution with a scalar. Code example: \u003c/p\u003e\n\n```json\n{\n\t\"changeBrightness\": {\n\t\t\"coefficient\": 1.2\n\t}\n}\n```\n\n\u003ch3\u003eRandom sharpening\u003c/h3\u003e\n\u003cp\u003eApply a sharpening system to the image. Code example: \u003c/p\u003e\n\n```json\n{\n\t\"sharpening\": {\n\t\t\"weight\": 0.8\n\t}\n}\n```\n\n\u003ch3\u003eAdd gaussian noise\u003c/h3\u003e\n\u003cp\u003eAdd gaussian noise to the image. Code example: \u003c/p\u003e\n```json\n{\n\t\"addGaussianNoise\": {\n\t\t\"coefficient\": 0.5\n\t}\n}\n```\n\n\u003ch3\u003eGaussian blur\u003c/h3\u003e\n\u003cp\u003eApply a Gaussian low pass filter to the image. Code example: \u003c/p\u003e\n\n```json\n{\n\t\"gaussianBlur\": {\n\t\t\"sigma\": 2\n\t}\n}\n```\n\n\u003ch3\u003eShift colors\u003c/h3\u003e\n\u003cp\u003eShift the colors of the image. Code example: \u003c/p\u003e\n\n```json\n{\n\t\"shiftBlur\": {\n\t}\n}\n```\n\n\n\u003ch2\u003eTypes of bounding box augmentations\u003c/h2\u003e\n\u003cp\u003eAll of the augmentations ought to implement the following parameters:\u003c/p\u003e\n\u003col\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Save\"\u003c/strong\u003e: saves the current transformation if True.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Restart frame\"\u003c/strong\u003e: restarts the frame to its original space if True, otherwise maintains the augmentation applied so far.\u003c/li\u003e\n\t\u003cli\u003e\u003cstrong\u003e\"Random event\"\u003c/strong\u003e: uses an stochastic function to randomize whether this augmentation might be applied or not.\u003c/li\u003e\n\u003c/ol\u003e\n\u003ch3\u003eScale\u003c/h3\u003e\n\u003cp\u003eScales the size of an image and maintains the location of its bounding boxes. Code example:\u003c/p\u003e\n\n```json\n{\n\t\"scale\": {\n\t\t\"size\": [1.2, 1.2],\n\t\t\"zoom\": true,\n\t\t\"interpolationMethod\": 1\n\t}\n}\n```\n\n\u003ch3\u003eRandom crop\u003c/h3\u003e\n\u003cp\u003eCrops the bounding boxes of an image. Specify the size of the crop in the size parameter. Code example:\u003c/p\u003e\n\n```json\n{\n\t\"crop\": {\n\t\t\"size\": [50, 50]\n\t}\n}\n```\n\n\u003ch3\u003eRandom pad\u003c/h3\u003e\n\u003cp\u003ePads the bounding boxes of an image. i.e adds pixels from outside the bounding box. Specify the amount of pixels to be added in the size parameter. Code example:\u003c/p\u003e\n\n```json\n{\n\t\"pad\": {\n\t\t\"size\": [20, 20]\n\t}\n}\n```\n\n\u003ch3\u003eFlip horizontally\u003c/h3\u003e\n\u003cp\u003eFlips the bounding boxes of an image in the x axis. Code example:\u003c/p\u003e\n\n```json\n{\n\t\"horizontalFlip\": {\n\t}\n}\n```\n\n\u003ch3\u003eFlip vertically\u003c/h3\u003e\n\u003cp\u003eFlips the bounding boxes of an image in the y axis. Code example:\u003c/p\u003e\n\n```json\n{\n\t\"verticalFlip\": {\n\t}\n}\n```\n\n\u003ch3\u003eRotation\u003c/h3\u003e\n\u003cp\u003eRotates the bounding boxes of an image anti-clockwise. Code example:\u003c/p\u003e\n\n```json\n{\n\t\"rotation\": {\n\t\t\"theta\": 0.5 \n\t}\n}\n```\n\n\u003ch3\u003eJitter boxes\u003c/h3\u003e\n\u003cp\u003eDraws random squares of a specific color and size in the area of the bounding box. Code example: \u003c/p\u003e\n\n```json\n{\n\t\"jitterBoxes\": {\n\t\t\"size\": [10, 10],\n\t\t\"quantity\": 5,\n\t\t\"color\": [255,255,255]\n\t}\n}\n```\n\n\u003ch3\u003eDropout\u003c/h3\u003e\n\u003cp\u003eSet pixels inside the bounding box to zero depending on a probability p extracted from a normal distribution. If p \u003e threshold, then the pixel is changed. Code example: \u003c/p\u003e\n\n```json\n{\n\t\"dropout\": {\n\t\t\"size\": [5, 5],\n\t\t\"threshold\": 0.8,\n\t\t\"color\": [255,255,255]\n\t}\n}\n```\n\n\u003ch1 id=\"#contribute\"\u003eContribute\u003c/h1\u003e\n\u003cp\u003eIf you want to contribute to this library. Please follow the next steps so you can have a development environment.\u003c/p\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eInstall anaconda with python 3.7\u003c (tested with python 3.5 3.6 3.7). Then create an empty environment.\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\nconda create --name=impy python3.7\n```\n\n\u003cul\u003e\n\t\u003cli\u003eActivate the conda environment\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\nsource activate impy\n```\n\n\u003cul\u003e\n\t\u003cli\u003eClone the repository\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\ngit clone https://github.com/lozuwa/impy\n```\n\n\u003cul\u003e\n\t\u003cli\u003eInstall the dependencies that are in setup.py\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eYou are good to go. Note there are unit tests for each script inside the impy folder.\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch2\u003eBuild the project\u003c/h2\u003e\n\n\u003cul\u003e\n\t\u003cli\u003eGo to impy's parent directory and run the following code:\u003c/li\u003e\n\u003c/ul\u003e\n\n```bash\npython setup.py sdist bdist_wheel\n```\n\n\u003cul\u003e\n\t\u003cli\u003eA folder named dist will appear. It contains the .whl and .tar.gz\u003c/li\u003e\n\u003c/ul\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flozuwa%2Fimpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flozuwa%2Fimpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flozuwa%2Fimpy/lists"}